FreeBSD/Solaris and -lc

Francois Gouget fgouget at codeweavers.com
Wed Apr 3 19:29:49 CST 2002


Marcus Meissner wrote:
[...]
> It should not be linked on Linux.

   I found an application that will crash if I link it in on FreeBSD. So
it does seem that it should not be linked in even on FreeBSD (or maybe
the crash has to do with the order in which it is linked in).
   Confirmed... it is a link order problem for that one.


> Hmm, what about something like:
> 
>     AC_CHECK_FUNC(getpid,,AC_CHECK_LIB(c,getpid))
> 
> or similar?

   Unfortunately this does not work. I get:
checking for getpid... yes
checking for sqrt in -lm... yes

   The problem is that it appears you don't need to specify it if you
don't use -Bsymbolic but you need to link it in if you use it:

This works:

$ gcc -shared advapi32.spec.o advapi.o crypt.o eventlog.o registry.o
security.o service.o -o advapi32.dll.so -L../../dlls -L../../library
-lwine -lm
$ echo $?
0

but this doesn't:

$ gcc -shared -Wl,-Bsymbolic advapi32.spec.o advapi.o crypt.o eventlog.o
registry.o security.o service.o -o advapi32.dll.so -L../../dlls
-L../../library -lwine -lm 
advapi.o: In function `GetUserNameA':
/mnt/home/fgouget/wine/wine.ref/freebsd/dlls/advapi32/../../../src/dlls/advapi32/advapi.c(.text+0x16):
undefined reference to `getuid'
/mnt/home/fgouget/wine/wine.ref/freebsd/dlls/advapi32/../../../src/dlls/advapi32/advapi.c(.text+0x1c):
undefined reference to `getpwuid'
/mnt/home/fgouget/wine/wine.ref/freebsd/dlls/advapi32/../../../src/dlls/advapi32/advapi.c(.text+0x3a):
undefined reference to `strerror'
...
$ echo $?
0

Hmm, $?==0 but it still really bothers me to have all these undefined
reference messages. And if I add -lc everything is fine again:

$ gcc -shared -Wl,-Bsymbolic advapi32.spec.o advapi.o crypt.o eventlog.o
registry.o security.o service.o -o advapi32.dll.so -L../../dlls
-L../../library -lwine -lm -lc
$ echo $?
0

Also, I could not get ldd to work on advapi32.dll.so for any of the
above files.
$ ldd advapi32.dll.so 
advapi32.dll.so:
ldd: advapi32.dll.so: Exec format error
advapi32.dll.so: exit status 1

   What's wrong???

-- 
François Gouget
fgouget at codeweavers.com



More information about the wine-devel mailing list