g++ Static Library connection sequence of the giant pits

Source: Internet
Author: User

When compiling the chat sample for the latest version (12.04) of AllJoyn, you want to use bundle daemon to modify the file in the previous experience: alljoyn-14.02.00-src/build/linux/x86_64/debug/ Dist/samples/chat/makefile:

LIBS =-lalljoyn . /.. /lib/bundledrouter.o-lajrouter -lstdc++-LCRYPTO-LPTHREAD-LRT

1). Compile OK, but run the Times wrong:

./Chat.  while loading shared libraries:liballjoyn.so:cannot open Shared object file:no such file or directory

It turns out. /.. There are two libraries in the/lib/directory:

LL.. /.. /lib/71552drwxr-xr-x 2 Z.rao caf     4096 APR  9 19:56./drwxr-xr-x 6 Z.rao CAF     4096 APR  9 18:35.. /-rw-r--r--1 Z.rao CAF   529336 Apr  9 18:36 bundledrouter.o-rw-r--r--1 Z.rao CAF 38765950 Apr  9 18:3 6 libajrouter.a-rw-r--r--1 Z.rao CAF 24335844 Apr  9 18:35 liballjoyn.a-rwxr-xr-x 1 Z.rao caf< c14/>9621229 APR  9 19:56 liballjoyn.so*

The default connection is the dynamic library: liballjoyn.so*

Although it is possible to solve the connection problem of the dynamic library through Ldconfig, but considering the issue of the program release, I decided to connect the static library Liballjoyn.a

2). Then, delete the liballjoyn.so so that the program connects to the static library Liballjoyn.a :

Rm.. /.. /lib/liballjoyn.somake Clean;make

Unfortunately, the error is:

g++-c-wall-pipe-std=c++98-fno-rtti-fno-exceptions-wno-long-long-wno-deprecated-g-dqcc_os_linux-dqcc_os_group_p Osix-dqcc_cpu_x86-i. /.. /inc-o chat.o CHAT.CCG+ +-o chat chat.o-l. /.. /lib-lalljoyn. /.. /lib/bundledrouter.o-lajrouter-lstdc++-lcrypto-lpthread-LRT ./.. /LIB/BUNDLEDROUTER.O:inch function' Bundledrouter::start (ajn::nulltransport*) ':/home/z.rao/work/library/alljoyn-14.02.00-src/alljoyn_core/router/bundled/bundledrouter.cc:263:undefined Reference to ' qcc::loggersetting::getloggersetting (char const*, int, bool, _io_file*) './.. /LIB/BUNDLEDROUTER.O:inch function' Ajn::P asswordmanager::GetPassword () ':/home/z.rao/work/library/alljoyn-14.02.00-src/alljoyn_core/inc/alljoyn/passwordmanager.h:65:undefined Reference To ' Ajn::P asswordmanager::password ' ./.. /LIB/BUNDLEDROUTER.O:inch function' Ajn::P asswordmanager::getauthmechanism () ':/home/z.rao/work/library/alljoyn-14.02.00-src/alljoyn_core/inc/alljoyn/passwordmanager.h:71:undefined Reference To ' Ajn::P asswordmanager::authmechanism ' ./.. /LIB/LIBAJROUTER.A (TCPTRANSPORT.O):inch function' Ajn::tcptransport::getlistenaddresses (ajn::sessionopts const&, std::vector<qcc::string, Std::allocator <qcc::String> >&) const ':/home/z.rao/work/library/alljoyn-14.02.00-src/alljoyn_core/router/tcptransport.cc:1193:undefined reference to ' Qcc::ifconfig (Std::vector<qcc::ifconfigentry, std::allocator<qcc::ifconfigentry> >&) './.. /LIB/LIBAJROUTER.A (TCPTRANSPORT.O):inch function' Ajn::tcptransport::connect (char const*, ajn::sessionopts const&, qcc::managedobj<ajn::_busendpoint> &) ':

Not defined?

See which symbols are exported?

Nm-c. /.. /lib/liballjoyn.a | grep getloggersetting0000000000000476 T qcc::loggersetting::getloggersetting (char const*, int, bool, _io_ file*)0000000000000000 W qcc::loggersetting::getloggersetting ()

Clearly already defined ah ..... Cry...

Before connecting the dynamic library liballjoyn.so can, static library Liballjoyn.a why not? The solution of baffled

3). To think about it, it could be that the connection order of the static library leads to a cyclic dependency, and there seems to be no other possibility.

So the online search for a pass, found

Http://www.cnblogs.com/wujianlundao/archive/2012/06/06/2538125.html

Modify the makefile to the following form:

" -(""-) " -lstdc++-LCRYPTO-LPTHREAD-LRT

It's done!

What do you want to ask-xlinker? Oh, haha.

g++ Static Library connection sequence of the giant pits

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.