I am trying to build 32bit application on 64bit Debian 7 and something goes wrong:
/usr/bin/ld: cannot find -lxml2
locate~
/usr/lib/x86_64-linux-gnu/libxml2.a
/usr/lib/x86_64-linux-gnu/libxml2.so
/usr/lib/x86_64-linux-gnu/libxml2.so.2
/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
Makefile:
CFLAGS=-I. -I/usr/include/libxml2 -I/usr/include/lua50 -I/usr/local/include
LIBLINK=-L/usr/lib64 -lxml2 -lz -lpthread -lm -llualib50 -llua50 -ldl -lboost_thread -lmysqlclient -Wl,-Map=otserv.map
ENDFLAGS=-m32 -Winvalid-pch -O2 -include "preheaders.h"
Related
I am on Fedora and trying to compile and link a project with Poco libraries installed on my system. Everything works fine with I compile and link my project with GCC 6. However, there's a linking error when I use clang-3.9 to compile and link my project:
undefined reference to `Poco::JSON::Object::operator Poco::Dynamic::Struct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&() const'
I checked the symbols in libPocoJSON.so and it contains this:
0000000000022d80 T Poco::JSON::Object::operator Poco::Dynamic::Struct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&[abi:cxx11]() const
So, the problem is that when I'm compiling with clang, it's looking for a symbol which doesn't exist in library.
I tried supplying -D_GLIBCXX_USE_CXX11_ABI=1 to my program hoping that it will force it to look for symbols with the abi:cxx11 tag but it doesn't help. I am confused now, whether this is a POCO issue, or clang++ issue?
Edit:
Output of clang -v
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/6.4.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1
Candidate multilib: .;#m64
Candidate multilib: 32;#m32
Selected multilib: .;#m64
Edit2:
Compile and link commands:
/bin/sh ../libtool --tag=CXX --mode=link clang++ -DTDOC=\"../test/data\" -I../common -I../net -I../wsd -I../kit -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11 -pthread -module -rpath /dummy -lz -o test test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o -lcppunit -lcap -lpng -ldl -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre
libtool: link: clang++ -DTDOC=\"../test/data\" -I../common -I../net -I../wsd -I../kit -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11 -pthread -o test test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o -lz -lcppunit -lcap -lpng -ldl -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre -pthread -Wl,-rpath -Wl,/dummy
Edit3:
Linker Invcation:
"/usr/bin/ld" --hash-style=gnu --no-add-needed --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crt1.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crti.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o -lz -lcppunit -lcap -lpng -ldl -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre -rpath /dummy -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/crtend.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crtn.o
I can build a Linux executable with g++ like below without any problem:
g++ -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -o '2016_02_06a_1st_Window' '2016_02_06a_1st_Window.cxx' /usr/local/lib/libfltk.a -lXext -lXft -lfontconfig -lpthread -ldl -lm -lX11
But When I try to build a MS Windows executable with MinGW like below and error happens:
i586-mingw32msvc-g++ -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT 2016_02_06a_1st_Window.cxx -L/usr/local/lib -lfltk -lXext -lXft -lfontconfig -lpthread -ldl -lm -lX11 -o 2016_02_06a_1st_Window.exe
The error of MinGW is:
Compiling and linking..
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -lXext
collect2: ld returned 1 exit status
I have installed all kinds of Xext libraries like these:
I have the following Xext libraries on my machine:
user#computer:~$ locate *Xext*
/usr/include/X11/extensions/Xext.h
/usr/lib/i386-linux-gnu/libXext.a
/usr/lib/i386-linux-gnu/libXext.so
/usr/lib/i386-linux-gnu/libXext.so.6
/usr/lib/i386-linux-gnu/libXext.so.6.4.0
I feel like g++ knows where Xext libraries are, but MinGW doesn't know. Any idea would be helpful.
you are running a cross compiler, which host is linux and target is windows, so when you link your target binaries, you should have target libraries. in your case, you should have libX for windows, and you listed are linux libraries, that's why your cross compiler cannot find libraries to link.
I have tried to build the stmd library (http://getassoc.cs.nii.ac.jp/package/stmd-1.1.5.tar.gz) on Ubuntu 12.04.2 amd64 which use the ICU library.
I have installed libicu-dev (version: 48) from Ubuntu repository and using the following configuration.
./configure --with-icu-config=/usr/bin/icu-config --with-defaultstemmer=SNOWBALL --enable-snowball=yes --enable-kill3number=yes
and then,
make
I got the following errors..
/bin/bash ./libtool --mode=link g++ -I. -g -O2 -Wall -Wno-parentheses -Wdeclaration-after- statement -g -O -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 '-DDEFAULT_STEMMER=SNOWBALL' '-DSTMD_MYSTEMMER_DIR="/usr/local/bin"' -g -Wall -O2 -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long -D_REENTRANT -I/usr/include '-DUSE_SNOWBALL=1' -I/usr/local/include -DKILL3NUMBER=1 -L/usr/lib -ldl -lm -L/usr/lib -licui18n -licuuc -licudata -ldl -lm -L/usr/local/lib -o stmd stmd.o stmc.o sigflg.o nio.o -L. -L/usr/lib -ldl -lm -L/usr/lib -licui18n -licuuc -licudata -ldl -lm -L/usr/local/lib -lystem -lstemmer -lexpat -ldl
libtool: link: g++ -I. -g -O2 -Wall -Wno-parentheses -Wdeclaration-after-statement -g -O -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -DDEFAULT_STEMMER=SNOWBALL -DSTMD_MYSTEMMER_DIR=\"/usr/local/bin\" -g -Wall -O2 -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long -D_REENTRANT -I/usr/include -DUSE_SNOWBALL=1 -I/usr/local/include -DKILL3NUMBER=1 -o stmd stmd.o stmc.o sigflg.o nio.o -L/usr/lib -L/usr/local/lib -L/home/kobkrit/stmd-1.1.5 -licui18n -licuuc -licudata -lm -lystem -lstemmer /usr/lib/x86_64-linux-gnu/libexpat.so -ldl
/home/kobkrit/stmd-1.1.5/libystem.a(normalizer.o): In function `utf8toutf16':
/home/kobkrit/stmd-1.1.5/normalizer.c:177: undefined reference to `utf8_nextCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:191: undefined reference to `u_errorName_48'
/home/kobkrit/stmd-1.1.5/libystem.a(normalizer.o): In function `utf16toutf8':
/home/kobkrit/stmd-1.1.5/normalizer.c:227: undefined reference to `u_errorName_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:219: undefined reference to `utf8_appendCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:223: undefined reference to `utf8_appendCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/libystem.a(normalizer.o): In function `normalizer_sparse_tostr':
/home/kobkrit/stmd-1.1.5/normalizer.c:125: undefined reference to `unorm_normalize_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:138: undefined reference to `unorm_normalize_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:140: undefined reference to `u_errorName_48'
/home/kobkrit/stmd-1.1.5/libystem.a(ngram.o): In function `nextchar':
/home/kobkrit/stmd-1.1.5/ngram.c:158: undefined reference to `utf8_nextCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/ngram.c:150: undefined reference to `utf8_nextCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/libystem.a(ngram.o): In function `ng_output':
/home/kobkrit/stmd-1.1.5/ngram.c:182: undefined reference to `utf8_appendCharSafeBody_48'
collect2: ld returned 1 exit status
make: *** [stmd] Error 1
It seems about the problem between linker to ICU library, so I take a look on Makefile, I found
...
CFLAGS+=$(shell /usr/bin/icu-config --cflags)
CFLAGS+=$(shell /usr/bin/icu-config --cppflags)
LDFLAGS+=$(shell /usr/bin/icu-config --ldflags-searchpath)
LDFLAGS+=$(shell /usr/bin/icu-config --ldflags)
...
(I don't quite sure, does it relate to the problem or not?)
I tried build the stmd library on Ubuntu 10.04.4 LTS amd64 and it went fine and work perfectly. But sadly my server's hardware is not compatible with the old Ubuntu. Please help.
Your command line:
g++ ... -licui18n -licuuc -licudata -ldl -lm ... -o stmd stmd.o stmc.o ...
is incorrect: the order of object files and libraries on command line matters.
I just installed manually apr and apr_util so i can install activemq c++ library.
When i try to make the cpp library i get the following error:
**
libtool: link: g++ -ansi -pedantic -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -I/usr/local/apr/include/apr-1 -I/usr/local/apr/include/apr-1 -I/usr/kerberos/include -W -Wall -Wextra -Wconversion -fPIC -fstrict-aliasing -Wstrict-aliasing=2 -Wno-long-long -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -I/usr/local/apr/include/apr-1 -I/usr/local/apr/include/apr-1 -I/usr/kerberos/include -Wno-non-virtual-dtor -Wno-unused-parameter -Wno-uninitialized -I./../main -g -O2 -pthread -o .libs/example example-main.o ../main/.libs/libactivemq-cpp.so -lexpat -L/usr/kerberos/lib64 /usr/local/apr/lib/libaprutil-1.so /usr/local/apr/lib/libapr-1.so -luuid -lrt -lcrypt /usr/local/apr/lib/libexpat.so -lssl -lcrypto -ldl -lz -lpthread -pthread -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/apr/lib
/usr/bin/ld: cannot find -lexpat
collect2: ld returned 1 exit status
**
and expat is within apr-util and not being linked. how can i update the ld path so that make or environment will find it?
or in short: how can i resolve this?
Usually you'll need to manually specify the library path using -L option.
It would look like ld filename -Lpath -llibname in a single ld operation. Or in this case you may need to add the paths of your library(apr-util here) to the constant of library paths in a Makefile.
I have a project that is a library that links against libresolv,
It works fine on recent distros: Ubuntu 10.x Fedora 13, Mandriva
2010.1 but on Centos 5.x I get the following errors
glibc installed is: glibc-2.5-18.el5_1.1
g++ -DHAVE_CONFIG_H -I. -I./include -I/usr/include/postgresql -O3
-ansi -Wall -Wno-deprecated -D_FORTIFY_SOURCE=0 -MT testUpLog.o -MD
-MP -MF .deps/testUpLog.Tpo -c -o testUpLog.o testUpLog.cc
mv -f .deps/testUpLog.Tpo .deps/testUpLog.Po
/bin/sh ./libtool --tag=CXX --mode=link g++ -O3 -ansi -Wall
-Wno-deprecated -D_FORTIFY_SOURCE=0 -L/usr/lib64 -L/lib64
-L/usr/lib64/mysql -o testUpLog testUpLog.o libUpTools.la -lpq
-lmysqlclient -lssl -lpthread
libtool: link: g++ -O3 -ansi -Wall -Wno-deprecated -D_FORTIFY_SOURCE=0
-o .libs/testUpLog testUpLog.o -L/usr/lib64 -L/lib64
-L/usr/lib64/mysql ./.libs/libUpTools.so -lpq -lmysqlclient -lssl
-lpthread
./.libs/libUpTools.so: undefined reference to `__ns_name_uncompress'
./.libs/libUpTools.so: undefined reference to `__ns_initparse'
./.libs/libUpTools.so: undefined reference to `__ns_parserr'
collect2: ld returned 1 exit status
make[1]: *** [testUpLog] Error 1
make[1]: Leaving directory `/tmp/UpTools-8.5.3'
make: *** [check-am] Error 2
library.la file contains:
dlname='libUpTools.so.0'
library_names='libUpTools.so.0.0.0 libUpTools.so.0 libUpTools.so'
old_library='libUpTools.a'
inherited_linker_flags=''
dependency_libs=' -L/usr/lib64 -L/lib64 -L/usr/lib64/mysql -lpq
-lmysqlclient -lssl -lpthread'
weak_library_names=''
current=0
age=0
revision=0
installed=no
shouldnotlink=no
dlopen=''
dlpreopen=''
libdir='/usr/lib'
You can read configure.ac on
http://pastebin.com/hs5q21Rq
Thanks in advance
If libUpTools uses functions lib libresolv, you need to say so:
libUpTools_la_LIBADD = -lresolv (of course -lresolv may be replaced by variables determined by configure etc.)
That way, -lresolv will end up in the .la file and also in the .so file (if you chose to build it) that you can run ldd on for verification.