error while compiling libhand examples - compilation

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.

Related

Linking error while ICE project compilation

While compiling my project on Ubuntu 14.04 I got the following error:
/usr/bin/ld: /tmp/ccpU0kVX.o: undefined reference to symbol '_ZN7IceUtil19NullHandleExceptionC1EPKci'
//usr/lib/x86_64-linux-gnu/libIceUtil.so.36: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
While compiling ICE project with a command:
g++ -I. server.cpp -lIce -lpthread
This is propably some problem with linking but I can't figure it out.
With Ice 3.6, you need to link with Ice and IceUtil:
g++ -o server server.cpp -pthread -lIce -lIceUtil
See https://doc.zeroc.com/ice/3.6/ice-release-notes/using-the-linux-binary-distributions#id-.UsingtheLinuxBinaryDistributionsv3.6-C++

Malformed archive while compiling v8

I am trying to build an executable file for Ubuntu machine for v8.
The following is the command executed :
g++ -g -ggdb -o Engine -lm *.o -Wl,--start-group /home/atdesk-83/v8/out/native/obj.target/{tools/gyp/libv8_{base,libbase,snapshot,libplatform},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt -pthread
I am receiving the error :
/home/atdesk-83/v8/out/native/obj.target/tools/gyp/libv8_base.a: error
adding symbols: Malformed archive collect2: error: ld returned 1 exit
status
Can anyone help to solve this?

How do I statically link zstd library to my dynamic library?

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.

Undefined reference errors while linking in makefile

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

Build error for SDL2-2.0.5 in Ubuntu 16.04

uranus#uranus:~/lib/SDL2-2.0.5$ make
/bin/bash build-scripts/updaterev.sh
LTLINK build/libSDL2.la
build/.libs/SDL_mirvideo.o: In function 'MIR_InitDisplayFromOutput':
/home/uranus/lib/SDL2-2.0.5/src/video/mir/SDL_mirvideo.c:258: undefined reference to 'mir_output_get_current_mode'
collect2: error: ld returned 1 exit status
Makefile:147: recipe for target 'build/libSDL2.la' failed
make: *** [build/libSDL2.la] Error 1
SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic power filesystem threads timers file loadso cpuinfo assembly
Assembly Math : mmx 3dnow sse sse2
Audio drivers : disk dummy oss alsa(dynamic) pulse(dynamic) sndio
Video drivers : dummy x11(dynamic) opengl opengl_es2 mir(dynamic)
X11 libraries : xcursor xdbe xinerama xinput2 xinput2_multitouch xrandr xscrnsaver xshape xvidmode
Input drivers : linuxev linuxkd
Using libudev : YES
Using dbus : YES
Using ime : YES
Using ibus : NO
Using fcitx : NO
The linker needs the name of the library where is this function.
I fixed it, adding in my Makefile file "-lmirclient".
# diff Makefile Makefile-ORG
26c26
< EXTRA_LDFLAGS = -Wl,--no-undefined -lm -ldl -lasound -lm -ldl -lpthread -lsndio -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt -lmirclient
---
> EXTRA_LDFLAGS = -Wl,--no-undefined -lm -ldl -lasound -lm -ldl -lpthread -lsndio -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt
#
A quick fix is to set static linking to the mir library when running configure:
./configure --enable-mir-shared=no
This causes the EXTRA_LDFLAGS variable to have the -lmirclient option added to it, as per Juan's answer.
As for why there is a problem, see bug 3539, which was resolved in a patch shortly after.
Looking at the patch, it appears there was a missing definition needed to allow dynamic linking to the 'mir_output_get_current_mode' function mentioned in the error message.
i had the same problem and i couldn't solve
but i used SDL2.0.3 and i didn't face any problems and it worked and Compiled fine with me
You can install it from here
https://sourceforge.net/projects/libsdl/files/SDL/2.0.3/

Resources