Undefined symbols when building

293 views
Skip to first unread message

Ben Ramsey

unread,
Jul 11, 2009, 9:09:47 AM7/11/09
to Strophe
I'm attempting to build my own app with libstrophe, and as a test, I
decided to build the included bot.c, but it seems I'm having linker
problems since it's having undefined symbols. Any help would be
appreciated.

Here's the output when I try to build:

bramsey@pippin:~$ gcc -I$HOME/local/src/libstrophe -L$HOME/local/src/
libstrophe -lstrophe -o bot bot.c
Undefined symbols:
"_SSLv23_client_method", referenced from:
_tls_new in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_library_init", referenced from:
_tls_initialize in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_shutdown", referenced from:
_tls_stop in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_get_error", referenced from:
_tls_new in libstrophe.a(libstrophe_a-tls_openssl.o)
_tls_start in libstrophe.a(libstrophe_a-tls_openssl.o)
_tls_stop in libstrophe.a(libstrophe_a-tls_openssl.o)
_tls_read in libstrophe.a(libstrophe_a-tls_openssl.o)
_tls_write in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_connect", referenced from:
_tls_start in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_CTX_new", referenced from:
_tls_new in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_CTX_ctrl", referenced from:
_tls_new in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_write", referenced from:
_tls_write in libstrophe.a(libstrophe_a-tls_openssl.o)
"_xmlParseChunk", referenced from:
_parser_feed in libstrophe.a(libstrophe_a-parser_libxml2.o)
"_xmlFreeParserCtxt", referenced from:
_parser_free in libstrophe.a(libstrophe_a-parser_libxml2.o)
_parser_reset in libstrophe.a(libstrophe_a-parser_libxml2.o)
"_xmlCreatePushParserCtxt", referenced from:
_parser_reset in libstrophe.a(libstrophe_a-parser_libxml2.o)
"_SSL_set_fd", referenced from:
_tls_new in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_new", referenced from:
_tls_new in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_CTX_free", referenced from:
_tls_free in libstrophe.a(libstrophe_a-tls_openssl.o)
"_res_9_query", referenced from:
_sock_srv_lookup in libstrophe.a(libstrophe_a-sock.o)
"_SSL_load_error_strings", referenced from:
_tls_initialize in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_CTX_set_verify", referenced from:
_tls_new in libstrophe.a(libstrophe_a-tls_openssl.o)
"_SSL_read", referenced from:
_tls_read in libstrophe.a(libstrophe_a-tls_openssl.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

Ben Ramsey

unread,
Jul 13, 2009, 1:10:42 PM7/13/09
to Strophe
It seems I've gotten past my earlier problem, but I'm now unable to
get past this problem. The header file and library are being found
just fine, but it's complaining about undefined references.

$> gcc -I$HOME/src/libstrophe -L$HOME/src/libstrophe -lstrophe -o bot
bot.c
/tmp/cco5DRx5.o: In function `main':
rfid-bot.c:(.text+0x6a): undefined reference to `xmpp_initialize'
rfid-bot.c:(.text+0x76): undefined reference to
`xmpp_get_default_logger'
rfid-bot.c:(.text+0x8c): undefined reference to `xmpp_ctx_new'
rfid-bot.c:(.text+0x9a): undefined reference to `xmpp_conn_new'
rfid-bot.c:(.text+0xaf): undefined reference to `xmpp_conn_set_jid'
rfid-bot.c:(.text+0xc1): undefined reference to `xmpp_conn_set_pass'
rfid-bot.c:(.text+0xeb): undefined reference to `xmpp_connect_client'
rfid-bot.c:(.text+0xf6): undefined reference to `xmpp_run'
rfid-bot.c:(.text+0x101): undefined reference to `xmpp_conn_release'
rfid-bot.c:(.text+0x10c): undefined reference to `xmpp_ctx_free'
rfid-bot.c:(.text+0x111): undefined reference to `xmpp_shutdown'

Ben Ramsey

unread,
Jul 13, 2009, 4:13:18 PM7/13/09
to Strophe
I figured it out on my own!

For those who may have trouble in the future with this, here's the
compile line I used:

gcc -Wall -I$HOME/src/libstrophe -L$HOME/src/libstrophe -lstrophe -
lssl -lresolv -o test test.c $HOME/src/libstrophe/libstrophe.a

I had to explicitly give it the path to libstrophe.a, and I had to
include -lssl and -lresolv. That did the trick.

Ben Ramsey

unread,
Jul 13, 2009, 4:23:56 PM7/13/09
to Strophe
And to manually build the bot.c example, you need to include libexpat:

gcc -Wall -I$HOME/src/libstrophe -L$HOME/src/libstrophe -lstrophe -
lssl -lresolv -lexpat -o bot bot.c $HOME/src/libstrophe/libstrophe.a
$HOME/src/libstrophe/libexpat.a

George Morgan

unread,
Jul 14, 2009, 7:27:58 AM7/14/09
to str...@googlegroups.com
Try putting all the -l<library name> arguments after the source and
see if you can leave off the ".a"s...
--
George Morgan

Ben Ramsey

unread,
Jul 14, 2009, 9:59:51 AM7/14/09
to Strophe
On Jul 14, 7:27 am, George Morgan <gm.v...@gmail.com> wrote:
> Try putting all the -l<library name> arguments after the source and
> see if you can leave off the ".a"s...

Nice. That works! Much better.

gcc -Wall -I$HOME/src/libstrophe -L$HOME/src/libstrophe -o bot bot.c -
lstrophe -lssl -lresolv -lexpat
Reply all
Reply to author
Forward
0 new messages