curl-users
undefined reference to `curl_global_init'
Date: Sat, 11 Feb 2012 02:04:43 +0800
Hi,
I encounter a problem while compile attached sourcecode which require
libcurl
From following log generated by ld, libcurl.so was loaded, definition of
'curl_global_init' was also there,
but the compiler still complain without any success
Thanks for any help
Package for libcurl:
libcurl4-openssl-dev
Compile Command:
gcc -L/usr/lib/i386-linux-gnu -lcurl -Wl,-M,-t,-y,curl_global_init
couch_example1.c
Log:
/usr/bin/ld: mode elf_i386
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crti.o
/usr/lib/gcc/i686-linux-gnu/4.6.1/crtbegin.o
-lcurl (/usr/lib/i386-linux-gnu/libcurl.so)
/tmp/ccT5ZAF5.o
-lgcc_s (/usr/lib/gcc/i686-linux-gnu/4.6.1/libgcc_s.so)
/lib/i386-linux-gnu/libc.so.6
Archive member included because of file (symbol)
/usr/lib/i386-linux-gnu/libc_nonshared.a(elf-init.oS)
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o
(__libc_csu_init)
(/usr/lib/i386-linux-gnu/libc_nonshared.a)elf-init.oS
/usr/lib/i386-linux-gnu/libc_nonshared.a(stat.oS)
/tmp/ccT5ZAF5.o (stat)
(/usr/lib/i386-linux-gnu/libc_nonshared.a)stat.oS
/lib/i386-linux-gnu/ld-linux.so.2
-lgcc_s (/usr/lib/gcc/i686-linux-gnu/4.6.1/libgcc_s.so)
/usr/lib/gcc/i686-linux-gnu/4.6.1/crtend.o
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crtn.o
Allocating common symbols
Common symbol size file
fp 0x4 /tmp/ccT5ZAF5.o
curl 0x4 /tmp/ccT5ZAF5.o
file_info 0x58 /tmp/ccT5ZAF5.o
Discarded input sections
.note.GNU-stack
0x0000000000000000 0x0
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o
.gnu_debuglink
0x0000000000000000 0xc
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o
.note.GNU-stack
0x0000000000000000 0x0
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crti.o
.gnu_debuglink
0x0000000000000000 0xc
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crti.o
.note.GNU-stack
0x0000000000000000 0x0
/usr/lib/gcc/i686-linux-gnu/4.6.1/crtbegin.o
.note.GNU-stack
0x0000000000000000 0x0 /tmp/ccT5ZAF5.o
.group 0x0000000000000000 0x8
/usr/lib/i386-linux-gnu/libc_nonshared.a(elf-init.oS)
.note.GNU-stack
0x0000000000000000 0x0
/usr/lib/i386-linux-gnu/libc_nonshared.a(elf-init.oS)
.group 0x0000000000000000 0x8
/usr/lib/i386-linux-gnu/libc_nonshared.a(stat.oS)
.text.__i686.get_pc_thunk.bx
0x0000000000000000 0x4
/usr/lib/i386-linux-gnu/libc_nonshared.a(stat.oS)
.note.GNU-stack
0x0000000000000000 0x0
/usr/lib/i386-linux-gnu/libc_nonshared.a(stat.oS)
.note.GNU-stack
0x0000000000000000 0x0
/usr/lib/gcc/i686-linux-gnu/4.6.1/crtend.o
.note.GNU-stack
0x0000000000000000 0x0
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crtn.o
.gnu_debuglink
0x0000000000000000 0xc
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crtn.o
Memory Configuration
Name Origin Length Attributes
*default* 0x0000000000000000 0xffffffffffffffff
Linker script and memory map
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crti.o
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/crtbegin.o
LOAD /usr/lib/i386-linux-gnu/libcurl.so
LOAD /tmp/ccT5ZAF5.o
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/libgcc.a
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/libgcc_s.so
LOAD /usr/lib/i386-linux-gnu/libc.so
START GROUP
LOAD /lib/i386-linux-gnu/libc.so.6
LOAD /usr/lib/i386-linux-gnu/libc_nonshared.a
LOAD /lib/i386-linux-gnu/ld-linux.so.2
END GROUP
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/libgcc.a
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/libgcc_s.so
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/crtend.o
LOAD /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crtn.o
...
.gnu.attributes
*(.gnu.attributes)
/DISCARD/
*(.note.GNU-stack)
*(.gnu_debuglink)
*(.gnu.lto_*)
OUTPUT(a.out elf32-i386/usr/lib/i386-linux-gnu/libcurl.so: definition of
curl_global_init
/tmp/ccT5ZAF5.o: reference to curl_global_init
/tmp/ccT5ZAF5.o: In function `main':
couch_example1.c:(.text+0xa0): undefined reference to `curl_global_init'
couch_example1.c:(.text+0xd5): undefined reference to `curl_easy_init'
couch_example1.c:(.text+0x10c): undefined reference to `curl_easy_setopt'
couch_example1.c:(.text+0x131): undefined reference to `curl_easy_setopt'
couch_example1.c:(.text+0x158): undefined reference to `curl_easy_setopt'
couch_example1.c:(.text+0x17f): undefined reference to `curl_easy_setopt'
couch_example1.c:(.text+0x19b): undefined reference to `curl_slist_append'
couch_example1.c:(.text+0x1c4): undefined reference to `curl_easy_setopt'
couch_example1.c:(.text+0x1d1): undefined reference to `curl_easy_perform'
couch_example1.c:(.text+0x1dd): undefined reference to `curl_slist_free_all'
couch_example1.c:(.text+0x1ea): undefined reference to `curl_easy_cleanup'
couch_example1.c:(.text+0x1fc): undefined reference to `curl_global_cleanup'
/usr/bin/ld: link errors found, deleting executable `a.out'
collect2: ld returned 1 exit status
)
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
- text/x-csrc attachment: couch_example1.c