[plug] building static binaries

Craig Ringer craig at postnewspapers.com.au
Mon Dec 29 16:11:07 WST 2003


Luke Dudney wrote:
>>>configure:5214: checking for res_mkquery in -lresolv
>>>configure:5245: gcc -o conftest -g -O2  -static conftest.c -lresolv 
>>>-lc  >&5
>>>/tmp/cc2uxyd7.o(.text+0xa): In function `main':
>>>/home/luke/src/etherape-0.9.0/configure:5272: undefined reference to
>>>`res_mkquery'
>>>collect2: ld returned 1 exit status

> Yes, it's definitely there:
> 
> 0=[15:57:34]luke at lukenew:~/src/etherape-0.9.0$ nm -s
> /usr/lib/libresolv.a  |grep res_mkquery
> __res_mkquery in res_data.o
> __res_nmkquery in res_mkquery.o
> 000000a0 T __res_mkquery
> res_mkquery.o:

Actually... isn't __res_mkquery a different symbol to res_mkquery? I 
have vague memories about __ being used to indicate a private symbol or 
something like that. It may be obvious that I'm no C programmer.

If it is a different symbol, that might explain why ld can't find it. I 
wonder, though, why it'd be looking for it in that case - could the 
shared lib work differently to the static one?



James Devenish wrote:
 > Hehe...I see that ./configure uses one-liner compilation/linking, so
 > I'm not sure how you can work
 > around this, other than to ./configure without -static and then insert
 > -static into the Makefiles or Makedefs files.

I've done something similar before, ugly though it is. Generally I just 
do a dynamic build, note what `ld` command it uses to link the final 
binary, and rerun it with '-static' . It seems to work, but ... *ick* .

Craig Ringer




More information about the plug mailing list