From: David Garamond Date: 2004-03-05T19:51:08+09:00 Subject: Re: non-root binary distribution nobu.nokada@softhome.net wrote: >>Based on your suggestion, I've created a C wrapper like below. The real >>ruby is renamed to "ruby.real". Advice welcome, since this is probably >>only the 7th or 8th C program I've written, ever. :-) > > I recommend static-linked binary after all. You'd have no merit > of shared library at all if you put the copy in each users' > space. But will static Ruby be problematic when building extensions? For example, I tried with plruby and it didn't produce a proper plruby.so. Maybe most Ruby extensions are developed with a shared Ruby in mind. >>#include >>#include >> >>int main(int argc, char *argv[]) { >> static char binpath[512+5], libpath[512+6]; > > You'd better to get rid of magic numbers. > >> p = (char *)getenv("LD_LIBRARY_PATH"); >> if ((env = (char *)malloc(512+1+(p==NULL ? 0:strlen(p)))) == NULL) { >> fprintf(stderr, "malloc() failed: %s\n", strerror(errno)); >> exit(1); >> } >> strcat(env, "LD_LIBRARY_PATH="); > > Use strcpy instead of strcat here, content of malloc'ed area is > not guaranteed. Thanks for the suggestions. -- dave