I have a set of cross compiled dynamic libraries generated. While trying to link it, I am getting the following error:
arm-linux-ld: xxx.so: undefined reference to symbol '__aeabi_uldivmod##GCC_3.5'
Does anybody have any idea what I am missing?
Below is the libraries I am linking and the order of linking:
some user defined libraries + -lcrypto -lssl -lz -lpthread -lxml2
-lcsvparser -lubox -lini -lyuarel -lsqlite3 -lcurl -lm -ldl -lrt -lc -lgcc
Related
compile the latest v8 failed on linux platform.
linux, v8 using ninjia
ninja: Entering directory `out.gn/x64.release'
[14/571] LINK ./mksnapshot
o/x/args.gn+ buffers
FAILED: mksnapshot
../../third_party/llvm-build/Release+Asserts/bin/clang++ -pie -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -m64 -rdynamic -pie -Wl,--disable-new-dtags -Wl,-O2 -Wl,--gc-sections -o "./mksnapshot" -Wl,--start-group #"./mksnapshot.rsp" -Wl,--end-group -latomic -ldl -lpthread -lrt
ld.lld: error: undefined symbol: void std::atomic_init(std::atomic*, bool)
referenced by module-compiler.cc:260 (../../src/wasm/module-compiler.cc:260)
obj/v8_base_without_compiler/module-compiler.o:(v8::internal::wasm::CompilationState::New(std::shared_ptr const&, std::shared_ptr))
link error
This problem has been solved by replacing std::atomic_init with straight assignment.
I am trying to statically link zstd library(I have libzstd.a or libzstd.so) to my shared library libtest.so. The idea is that when deploying libtest.so in our application, we don't have to depend on libzstd.a or libzstd.so any more, so we have to statically link the zstd library.
I tried these:
cc -fPIC -Wl,-soname=libtest.so -static-libgcc -shared -o libtest.so myobjects.o -ldl -lc -L/path/to/libzstd -l:libzstd.a
cc -fPIC -Wl,-soname=libtest.so -static-libgcc -shared -o libtest.so myobjects.o -ldl -lc -Wl,-Bstatic -L/path/to/libzstd -l:libzstd.a
cc -fPIC -Wl,-soname=libtest.so -static-libgcc -shared -o libtest.so myobjects.o -ldl -lc /path/to/libzstd/libzstd.a
But they're all giving me this error:
/bin/ld: /path/to/libzstd/libzstd.a(zstd_common.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object;
recompile with -fPIC
/path/to/libzstd/libzstd.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [libtest.so] Error 1
What are the problem here? Thank you!
All object files that are linked into a shared library must be compiled
as Position Independent Code (compiler option -fPIC).
The linker error:
/bin/ld: /path/to/libzstd/libzstd.a(zstd_common.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object;
recompile with -fPIC
is telling you that the linkage of the shared library libtest.so needs the object file zstd_common.o from the
archive libzstd.a, but that object file was not compiled with -fPIC.
So you must rebuild libzstd.a from source, this time compiling the object
files that it contains with -fPIC.
I am trying to compile the examples of libhand, but I get the following output:
/usr/bin/ld: /usr/local/lib/libOgreMainStatic.a(OgreDynLib.cpp.o): undefined reference to symbol 'dlopen##GLIBC_2.1'
/usr/bin/ld: note: 'dlopen##GLIBC_2.1' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libdl.so so try adding it to the linker command line
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libdl.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [bend_one_finger] Error 1
make[1]: *** [CMakeFiles/bend_one_finger.dir/all] Error 2
make: *** [all] Error 2
The same thing happens when I try to compile my own example using the direction from libhand example. I believe it has something to do with the configuration file of libhand (LibHandConfig.cmake).
The same example compiles fine when I build it as a part of libhand, the problem occurs when I try to use libhand as a package (using cmake's FIND_PACKAGE() )
Not a complete answer, but just a step toward:
try to issue the following command after you got the make error:
/usr/bin/c++ CMakeFiles/example.dir/example.cc.o -o example -rdynamic -ldl -lXt /path/libs/libHand/hand_cpp/dist/libhand_hog.a /path/libs/libHand/hand_cpp/dist/libhand_renderer.a /path/libs/libHand/hand_cpp/dist/libhand_utils.a -lopencv_core -lopencv_flann -lopencv_imgproc -lopencv_highgui -lopencv_features2d -lopencv_calib3d -lopencv_cudaarithm -lopencv_cudawarping -lopencv_ml -lopencv_objdetect -lopencv_cuda -lopencv_cudafilters -lopencv_cudaimgproc -lopencv_video -lopencv_legacy -lopencv_cudaoptflow -lopencv_photo -lopencv_videostab -lopencv_ts -lopencv_cudacodec -lopencv_ocl -lopencv_superres -lopencv_cudafeatures2d -lopencv_nonfree -lopencv_stitching -lopencv_softcascade -lopencv_shape -lopencv_optim -lopencv_cudastereo -lopencv_cudabgsegm -lopencv_contrib -lopencv_bioinspired /path/libs/libHand/hand_cpp/dist/libdot_sceneloader.a /path/libs/libHand/hand_cpp/dist/libtinyxml.a /usr/local/lib/libOgreMainStatic.a -lzzip -lz -lfreeimage -lfreetype -lSM -lICE -lX11 -lXext -lXaw -lXrandr -ltbb /usr/local/lib/OGRE/libRenderSystem_GLStatic.a -lGLU -lGL /usr/local/lib/libOgreMainStatic.a -lzzip -lz -lfreeimage -lfreetype -lSM -lICE -lX11 -lXext -lXaw -lXrandr -ltbb /usr/local/lib/OGRE/libRenderSystem_GLStatic.a -lGLU -lGL /usr/local/lib/OGRE/libPlugin_OctreeSceneManagerStatic.a -ldl
If it succeeds than you have to manually add -ldl to the end of your libraries list ( target_link_libraries(example ${SOME_LIBS} ${OTHER_LIBS} -ldl) ). It seems that the configuration part of LibOGRE is slightly incorrect (it doesn't include a library libdl necessary to carelessly link application with it.
I would understand this error message if I had not put the -lboost_system flag, but it is really here:
g++ -o build/myproject build/main/main.o -L/usr/local/boost/boost_1_52_0/boost/libs -L/usr/lib -Lbuild -L. -lboost_system -lboost_thread -lpthread -lboost_regex -lpq -lmylibrary
build/libmylibrary.a(library.o): In function `__static_initialization_and_destruction_0(int, int)':
library.cpp:(.text+0x25f): undefined reference to `boost::system::generic_category()'
library.cpp:(.text+0x269): undefined reference to `boost::system::generic_category()'
library.cpp:(.text+0x273): undefined reference to `boost::system::system_category()'
Do you have any idea what should I investigate to solve the problem ? (I use gcc 4.6.3)
The order at which you link your libraries matters, in your case you have library.cpp that apparently uses the boost_system library
library.cpp:(.text+0x25f): undefined reference to `boost::system::generic_category()'
library.cpp:(.text+0x269): undefined reference to `boost::system::generic_category()'
library.cpp:(.text+0x273): undefined reference to `boost::system::system_category()'
To solve this you should move the boost_system library to the end of your link line
g++ -o build/myproject build/main/main.o -L/usr/local/boost/boost_1_52_0/boost/libs -L/usr/lib -Lbuild -L. -lboost_thread -lpthread -lboost_regex -lpq -lmylibrary **-lboost_system**
Alternatively, build libmylibrary.so as a shared library and link to the boost_system library directly.
I have installed
libpam0g-dev libpam0g
But when I am linking to libpam I am getting error undefined reference to `pam_start'
and I am linker flags include -lpam.
Same code is working in Ubuntu 11.
Linking flags
-Wl,--start-group -lssl -lpam -lcrypto -lnspr4 -licui18n -licuuc -licudata -lcurl -lcares -lpthread -lpcrecpp -loauth -ldl -lrt -lz -Wl,--end-group
don't works
but this works
-Wl,--start-group -lssl -lpam -lcrypto -lnspr4 -licui18n -licuuc -licudata -lcurl -lcares -lpthread -lpcrecpp -loauth -ldl -lrt -lz -lpam -Wl,--end-group