need help producing statically linked executable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am having trouble producing a statically linked version of an executable.
Adding the '-static' switch to the linker command produces thousands of
unresolved symbols.
They are all traceable to libcurl.a. This is a Ubuntu 10.4 system.
Example commands/output are below.

When I create the dynamically linked executable, I manually specify
about 10 libraries.
Yet ldd tells me that the dynamically linked executable links to 32
libraries (!).
Presumably the dynamical linker finds the symbols in the dynamically
linked executable.
The system only complains about unresolved symbols when I try static
linking.

How do I figure out how to modify the dynamic link command (in addition
to adding '-static')
to create a statically linked executable?

Thanks,
Charlie

This creates the dynamically linked executable:

zender@givre:~/nco$ gcc -std=c99 -pedantic -D_BSD_SOURCE -D_POSIX_SOURCE
-Wall -W -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual
-Wcast-align -Wwrite-strings -fno-common -g -Wno-switch -m64 -fopenmp -o
/home/zender/bin/LINUXAMD64/ncap /home/zender/obj/LINUXAMD64/ncap.o
/home/zender/obj/LINUXAMD64/ncap_utl.o
/home/zender/obj/LINUXAMD64/ncap_yacc.o
/home/zender/obj/LINUXAMD64/ncap_lex.o -fopenmp
-L/home/zender/lib/LINUXAMD64 -L/usr/local/lib -L/usr/local/lib
-L/usr/lib -lgsl -lgslcblas -lm -L/usr/local/lib  -lnco -lnetcdf
-lhdf5_hl -lhdf5 -lz -lcurl -lgsl -ludunits2 -lm -lgomp -lpthread -m64
zender@givre:~/nco$ ldd `which ncap` | wc
     32     125    1984

Adding the -static flag results in many (thousands) of undefined symbols
in libcurl.a:

zender@givre:~/nco$ gcc -std=c99 -pedantic -D_BSD_SOURCE -D_POSIX_SOURCE
-Wall -W -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual
-Wcast-align -Wwrite-strings -fno-common -g -Wno-switch -m64 -fopenmp -o
/home/zender/bin/LINUXAMD64/ncap /home/zender/obj/LINUXAMD64/ncap.o
/home/zender/obj/LINUXAMD64/ncap_utl.o
/home/zender/obj/LINUXAMD64/ncap_yacc.o
/home/zender/obj/LINUXAMD64/ncap_lex.o -fopenmp
-L/home/zender/lib/LINUXAMD64 -L/usr/local/lib -L/usr/local/lib
-L/usr/lib -lgsl -lgslcblas -lm -L/usr/local/lib  -lnco -lnetcdf
-lhdf5_hl -lhdf5 -lz -lcurl -lgsl -ludunits2 -lm -lgomp -lpthread -m64
-static
/home/zender/lib/LINUXAMD64/libnco.a(nco_fl_utl.o): In function
`nco_fl_mk_lcl':
/home/zender/nco/bld/../src/nco/nco_fl_utl.c:635: warning: Using
'getpwuid' in statically linked applications requires at runtime the
shared libraries from the glibc version used for linking
/usr/lib/libcurl.a(curl_addrinfo.o): In function `Curl_getaddrinfo_ex':
(.text+0x36e): warning: Using 'getaddrinfo' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/libcurl.a(version.o): In function `curl_version_info':
(.text+0x37): undefined reference to `stringprep_check_version'
/usr/lib/libcurl.a(version.o): In function `curl_version':
(.text+0x11b): undefined reference to `stringprep_check_version'
/usr/lib/libcurl.a(version.o): In function `curl_version':
(.text+0x12a): undefined reference to `stringprep_check_version'
/usr/lib/libcurl.a(strerror.o): In function `Curl_idn_strerror':
(.text+0x373): undefined reference to `idna_strerror'
/usr/lib/libcurl.a(url.o): In function `fix_hostname':
(.text+0x1053): undefined reference to `stringprep_check_version'
/usr/lib/libcurl.a(url.o): In function `fix_hostname':
(.text+0x1071): undefined reference to `idna_to_ascii_lz'
/usr/lib/libcurl.a(url.o): In function `fix_hostname':
(.text+0x1079): undefined reference to `stringprep_locale_charset'
/usr/lib/libcurl.a(url.o): In function `fix_hostname':
(.text+0x10ac): undefined reference to `idna_to_unicode_lzlz'
...
thousands of similar undefined references for libcurl.a.

-- 
Charlie Zender, Department of Earth System Science
University of California, Irvine (949) 891-2429 :)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux