This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 7 years ago.
I am installing OpenEXR_Viewers on Ubuntu 14.04. When running the makefile, I encounter the following error:
/usr/bin/ld: ImageView.o: undefined reference to symbol 'glOrtho'
//usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: error adding symbols: DSO
missing from command line collect2: error: ld returned 1 exit status
Is it likely that my lib tool invocation is not calling GL? If this is the case, how do I set my libtool to build with GL? (Edit the makefile to see OpenGl)
Making all in playexr
make[1]: Entering directory `/home/user/Documents/source/openexr/OpenEXR_Viewers/playexr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/user/Documents/source/openexr/OpenEXR_Viewers/playexr'
Making all in exrdisplay
make[1]: Entering directory `/home/user/Documents/source/openexr/OpenEXR_Viewers/exrdisplay'
/bin/bash ../libtool --tag=CXX --mode=link g++ -pipe -g -O2 -o exrdisplay main.o ImageView.o loadImage.o scaleImage.o applyCtl.o GlWindow3d.o -L/usr/local/lib -pthread -L/usr/local/lib -lIlmImf -lImath-2_2 -lIexMath-2_2 -lHalf -lIex-2_2 -lIlmThread-2_2 -DHAVE_CTL_INTERPRETER=0 -L/usr/local/lib -DHAVE_CTL_INTERPRETER=0 -pthread -L/usr/local/lib -lIlmImf -lImath-2_2 -lIexMath-2_2 -lHalf -lIex-2_2 -lIlmThread-2_2 -Wl,-Bsymbolic-functions -lfltk_gl -lfltk -lX11
*** Warning: Linking the executable exrdisplay against the loadable module
*** libImath-2_2.so is not portable!
*** Warning: Linking the executable exrdisplay against the loadable module
*** libIexMath-2_2.so is not portable!
*** Warning: Linking the executable exrdisplay against the loadable module
*** libHalf.so is not portable!
*** Warning: Linking the executable exrdisplay against the loadable module
*** libIex-2_2.so is not portable!
*** Warning: Linking the executable exrdisplay against the loadable module
*** libIlmThread-2_2.so is not portable!
libtool: link: g++ -pipe -g -O2 -o exrdisplay main.o ImageView.o loadImage.o scaleImage.o applyCtl.o GlWindow3d.o -pthread -DHAVE_CTL_INTERPRETER=0 -DHAVE_CTL_INTERPRETER=0 -pthread -Wl,-Bsymbolic-functions -L/usr/local/lib /usr/local/lib/libIlmImf.so /usr/local/lib/libImath-2_2.so /usr/local/lib/libIexMath-2_2.so /usr/local/lib/libHalf.so /usr/local/lib/libIex-2_2.so /usr/local/lib/libIlmThread-2_2.so -lfltk_gl -lfltk -lX11 -pthread
/usr/bin/ld: ImageView.o: undefined reference to symbol 'glOrtho'
//usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [exrdisplay] Error 1
make[1]: Leaving directory `/home/user/Documents/source/openexr/OpenEXR_Viewers/exrdisplay'
make: *** [all-recursive] Error 1
Try adding -lglut -lGL (and probably -lGLU) to you linker command.
(g++ linker: /usr/lib/libGL.so.1: could not read symbols: Invalid operation)
UPDATE:
Append it to:
FLTK_LDFLAGS = -Wl,-Bsymbolic-functions -lfltk_gl -lfltk -lX11
like
FLTK_LDFLAGS = -Wl,-Bsymbolic-functions -lfltk_gl -lfltk -lX11 -lglut -lGL
Related
I'm trying to compile the examples provided with Libspotify on my Raspberry Pi B. Had a load of errors about alsa to start with, but managed to fix them by installing libasound2-dev.
Now I'm getting the following error when I try to compile - does anyone have any suggestions, please?
The problem seems to be stemming from
/usr/bin/ld: alsa-audio.o: undefined reference to symbol
'pthread_create##GLIBC_2.4' //lib/arm-linux-gnueabihf/libpthread.so.0:
error adding symbols: DSO missing from command line
Terminal output:
for a in jukebox spshell localfiles; do make -C $a all; done
make[1]: Entering directory '/home/username/Downloads/libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release/share/doc/libspotify/examples/jukebox'
cc -I/usr/include/alsa -I/usr/local/include -Wall -L/usr/local/lib jukebox.o appkey.o alsa-audio.o audio.o -o jukebox -lasound -lspotify
/usr/bin/ld: alsa-audio.o: undefined reference to symbol 'pthread_create##GLIBC_2.4'
//lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:21: recipe for target 'jukebox' failed
make[1]: *** [jukebox] Error 1
make[1]: Leaving directory '/home/username/Downloads/libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release/share/doc/libspotify/examples/jukebox'
make[1]: Entering directory '/home/username/Downloads/libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release/share/doc/libspotify/examples/spshell'
cc -I/usr/local/include -Wall -L/usr/local/lib spshell.o spshell_posix.o appkey.o cmd.o browse.o search.o toplist.o inbox.o star.o playlist.o test.o -lreadline -lspotify -o spshell
/usr/bin/ld: spshell_posix.o: undefined reference to symbol 'pthread_create##GLIBC_2.4'
//lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:18: recipe for target 'spshell' failed
make[1]: *** [spshell] Error 1
make[1]: Leaving directory '/home/username/Downloads/libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release/share/doc/libspotify/examples/spshell'
make[1]: Entering directory '/home/username/Downloads/libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release/share/doc/libspotify/examples/localfiles'
make[1]: Leaving directory '/home/username/Downloads/libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release/share/doc/libspotify/examples/localfiles'
I am attempting to compile a library,
http://www.tbi.univie.ac.at/~raim/odeSolver/
this one specifically, I have gotten the necessary libraries for this.
However whenever i attempt to compile it with "make", I get the following error.
Making all in src
make[1]: Entering directory `/home/user/SOSLib/buildSOSlib/src'
/usr/bin/make all-am
make[2]: Entering directory `/home/user/SOSLib/buildSOSlib/src'
/bin/bash ../libtool --tag=CC --mode=link /usr/bin/gcc-4.8 -Wno-unknown-pragmas -Wall -Wextra -ansi -std=iso9899:1990 -g3 -gdwarf-2 -no-undefined -L/usr/lib64 -L/usr/local/lib -o libODES.la -rpath /usr/local/lib ASTIndexNameNode.lo arithmeticCompiler.lo charBuffer.lo compiler.lo cvodeData.lo cvodeSolver.lo daeSolver.lo drawGraph.lo evaluateAST.lo integratorInstance.lo integratorSettings.lo interpol.lo modelSimplify.lo nullSolver.lo odeConstruct.lo odeModel.lo odeSolver.lo processAST.lo sbml.lo sbmlResults.lo sensSolver.lo solverError.lo util.lo data.lo error.lo -lsbml -lxml2 -lsundials_ida -lsundials_kinsol -lsundials_cvodes -lsundials_nvecserial -lm -lm -ldl
libtool: link: /usr/bin/gcc-4.8 -shared -fPIC -DPIC .libs/ASTIndexNameNode.o .libs/arithmeticCompiler.o .libs/charBuffer.o .libs/compiler.o .libs/cvodeData.o .libs/cvodeSolver.o .libs/daeSolver.o .libs/drawGraph.o .libs/evaluateAST.o .libs/integratorInstance.o .libs/integratorSettings.o .libs/interpol.o .libs/modelSimplify.o .libs/nullSolver.o .libs/odeConstruct.o .libs/odeModel.o .libs/odeSolver.o .libs/processAST.o .libs/sbml.o .libs/sbmlResults.o .libs/sensSolver.o .libs/solverError.o .libs/util.o .libs/data.o .libs/error.o -L/usr/lib64 -L/usr/local/lib -lsbml -lxml2 /usr/local/lib/libsundials_ida.a /usr/local/lib/libsundials_kinsol.a /usr/local/lib/libsundials_cvodes.a /usr/local/lib/libsundials_nvecserial.a -lm -ldl -Wl,-soname -Wl,libODES.so.0 -o .libs/libODES.so.0.0.0
/usr/bin/ld: /usr/local/lib/libsundials_ida.a(ida.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libsundials_ida.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [libODES.la] Error 1
make[2]: Leaving directory `/home/user/SOSLib/buildSOSlib/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/user/SOSLib/buildSOSlib/src'
make: *** [all-recursive] Error 1
What is happening here?
You are trying to build a shared library, and shared libraries must be built as position-independent code so they an be loaded and run anywhere in memory. This is achieved passing the -fPIC flag to GCC. It seems that one of the libraries (libsundials_ida.a) was not built with it.
I am trying to compile a project that links the nsl lib but it seems to fail to link the library:
/bin/sh ../../libtool --tag=CXX --mode=link g++ -DNDEBUG -std=c++11 -L/usr/lib -R/usr/lib -L../../lib -all-static -lnsl -o Client client.o nettools.o -lgmm -lboost_program_options
libtool: link: g++ -DNDEBUG -std=c++11 -static -o Client client.o nettools.o -L/usr/lib -L../../lib -lnsl -lgmm -lboost_program_options -Wl,-rpath -Wl,/usr/lib
/bin/sh ../../libtool --tag=CXX --mode=link g++ -DNDEBUG -std=c++11 -L/usr/lib -R/usr/lib -L../../lib -all-static -lnsl -o Serveur serveur.o nettools.o -lgmm -lboost_program_options
/bin/ld: cannot find -lnsl
nettools.o: In function `creatSocketCom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int)':
nettools.cc:(.text+0x30e): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Makefile:426: recipe for target 'Client' failed
make[2]: *** [Client] Error 1
make[2]: *** Waiting for unfinished jobs....
libtool: link: g++ -DNDEBUG -std=c++11 -static -o Serveur serveur.o nettools.o -L/usr/lib -L../../lib -lnsl -lgmm -lboost_program_options -Wl,-rpath -Wl,/usr/lib
/bin/ld: cannot find -lnsl
nettools.o: In function `creatSocketCom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int)':
nettools.cc:(.text+0x30e): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
I know this library doesn't need to be linked on Mac OS X but I'm running Arch Linux.
I have 2 questions:
Why does nsl fail to be linked even though λ ld --verbose -lnsl seems to show it's there?
attempt to open /usr/x86_64-unknown-linux-gnu/lib64/libnsl.so failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib64/libnsl.a failed
attempt to open /usr/lib/libnsl.so succeeded
-lnsl (/usr/lib/libnsl.so)
libc.so.6 needed by /usr/lib/libnsl.so
found libc.so.6 at /usr/lib/libc.so.6
ld-linux-x86-64.so.2 needed by /usr/lib/libc.so.6
found ld-linux-x86-64.so.2 at /usr/lib/ld-linux-x86-64.so.2
ld: warning: cannot find entry symbol _start; not setting start address
What's the purest way to tell autoconf not to link nsl on systems where it's not needed?
The problem was with the -all-static option in the Makefile.am.
Arch Linux doesn't ship the static libraries (while debian's current stable release does).
I am trying to install re2 on a centos7 vm, and I am having some trouble solving these dependencies:
[root#roller re2]# make testinstall
cp testinstall.cc obj
(cd obj && g++ -I/usr/local/include -L/usr/local/lib testinstall.cc -lre2 -pthread -static -o testinstall)
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make: *** [testinstall] Error 1
Any help would be great! :)
thanks!
I'm trying to install mysql-workbench-gpl-5.2.45 from the source code on Linux debian 2.6.32-5-amd64. The problem appears at the "make" step with error message:
/usr/bin/ld: cannot find -lpython2.7.a
collect2: ld returned 1 exit status
make[4]: *** [libgrt.la] Error 1
make[4]: Leaving directory `/home/user/data/workbench/mysql-workbench-gpl-5.2.45-src/library/grt/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/user/data/workbench/mysql-workbench-gpl-5.2.45-src/library/grt'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/user/data/workbench/mysql-workbench-gpl-5.2.45-src/library'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/user/data/workbench/mysql-workbench-gpl-5.2.45-src'
make: *** [all] Error 2
The last make command before error is:
make[4]: Entering directory `/home/user/data/workbench/mysql-workbench-gpl-5.2.45-src/library/grt/src'
/bin/bash ../../../libtool --tag=CXX --mode=link g++ -Wextra -Wall -Wno-unused -Wno-deprecated -DTIXML_USE_STL=1 -o libgrt.la -rpath /usr/local/lib/mysql-workbench grtpp_grt.lo grtpp_helper.lo grtpp_metaclass.lo grtpp_util.lo grtpp_value.lo grtpp_shell.lo grtpp_shell_lua.lo grtpp_shell_lua_help.lo grtpp_module.lo grtpp_module_cpp.lo grtpp_module_lua.lo grtpp_notifications.lo lua_context.lo serializer.lo unserializer.lo grtpp_undo_manager.lo changefactory.lo changelistobjects.lo diffchange.lo grtdiff.lo grtlistdiff.lo grtpp_module_python.lo grtpp_shell_python.lo grtpp_shell_python_help.lo python_context.lo python_grtdict.lo python_grtlist.lo python_grtobject.lo python_module.lo -llua5.1 -luuid -pthread -Wl,--export-dynamic -lgthread-2.0 -lgmodule-2.0 -lrt -lglib-2.0 -lxml2 -lsigc-2.0 -llua5.1 -luuid -L/usr/local/lib -lpython2.7.a ../../../library/base/libwbbase.la
libtool: link: g++ -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtbeginS.o .libs/grtpp_grt.o .libs/grtpp_helper.o .libs/grtpp_metaclass.o .libs/grtpp_util.o .libs/grtpp_value.o .libs/grtpp_shell.o .libs/grtpp_shell_lua.o .libs/grtpp_shell_lua_help.o .libs/grtpp_module.o .libs/grtpp_module_cpp.o .libs/grtpp_module_lua.o .libs/grtpp_notifications.o .libs/lua_context.o .libs/serializer.o .libs/unserializer.o .libs/grtpp_undo_manager.o .libs/changefactory.o .libs/changelistobjects.o .libs/diffchange.o .libs/grtdiff.o .libs/grtlistdiff.o .libs/grtpp_module_python.o .libs/grtpp_shell_python.o .libs/grtpp_shell_python_help.o .libs/python_context.o .libs/python_grtdict.o .libs/python_grtlist.o .libs/python_grtobject.o .libs/python_module.o -Wl,-rpath -Wl,/home/user/data/workbench/mysql-workbench-gpl-5.2.45-src/library/base/.libs -Wl,-rpath -Wl,/usr/local/lib/mysql-workbench /usr/lib/libgthread-2.0.so /usr/lib/libgmodule-2.0.so -lrt /usr/lib/libglib-2.0.so /usr/lib/libxml2.so /usr/lib/libsigc-2.0.so /usr/lib/liblua5.1.so -luuid -L/usr/local/lib -lpython2.7.a ../../../library/base/.libs/libwbbase.so -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../.. -L/usr/lib/x86_64-linux-gnu -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crtn.o -pthread -Wl,--export-dynamic -pthread -Wl,-soname -Wl,libgrt.so.0 -o .libs/libgrt.so.0.0.0
I have checked library location:
locate lpython2.7.a
The result is:
/usr/local/lib/lpython2.7.a
The python2.7.3 was downloaded here:
http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
The python2.7.3 installation steps:
tar -xvjpf Python-2.7.3.tar.bz2 && cd Python-2.7.3 && ./configure && make && make install
Any ideas why WB can't find the library?
The problem is solved. Before mysql-workbench installation it is important to install python2.7 properly. Installation instruction here: https://gist.github.com/1069219