I have installed opencv in Ubuntu 20.04 following the instructions in OpenCV Installation in Linux. As per the instructions, sudo make install copies all the .so files to /usr/local/lib.
However, when compiling a program, using the command g++ --std c++17 -g opencv/Basic.cpp -o output -I/usr/local/include/opencv4 -L/usr/local/lib/ -llibopencv_calib3d -llibopencv_core -llibopencv_dnn -llibopencv_features2d -llibopencv_flann -llibopencv_highgui -llibopencv_imgcodecs -llibopencv_imgproc -llibopencv_ml -llibopencv_objdetect -llibopencv_photo -llibopencv_stitching -llibopencv_video -llibopencv_videoio I get the following error.
/usr/bin/ld: cannot find -llibopencv_calib3d
/usr/bin/ld: cannot find -llibopencv_core
/usr/bin/ld: cannot find -llibopencv_dnn
/usr/bin/ld: cannot find -llibopencv_features2d
/usr/bin/ld: cannot find -llibopencv_flann
/usr/bin/ld: cannot find -llibopencv_highgui
/usr/bin/ld: cannot find -llibopencv_imgcodecs
/usr/bin/ld: cannot find -llibopencv_imgproc
/usr/bin/ld: cannot find -llibopencv_ml
/usr/bin/ld: cannot find -llibopencv_objdetect
/usr/bin/ld: cannot find -llibopencv_photo
/usr/bin/ld: cannot find -llibopencv_stitching
/usr/bin/ld: cannot find -llibopencv_video
/usr/bin/ld: cannot find -llibopencv_videoio
collect2: error: ld returned 1 exit status
I have also added a .conf file in /etc/ld.so.conf.d/opencv.conf with the line /usr/local/lib/ and issued the command sudo ldconfig. However, the issue remains.
I'd be grateful for any ideas or suggestions to resolve this issue.
-llibopencv_calib3d
make it
-lopencv_calib3d
etc. the lib part in front of it is simply wrong
I'm failing to build a project in c++ where OpenCV is used. Here is what I got:
/usr/bin/ld: cannot find -leigen
/usr/bin/ld: cannot find -lhighgui
/usr/bin/ld: cannot find -lcore
/usr/bin/ld: cannot find -leigen
/usr/bin/ld: cannot find -lhighgui
/usr/bin/ld: cannot find -lcore
But there are only libraries like "-lopencv_core" available nowadays.
Is there any options how to fix this?
I'm using Ubuntu.
How did you install your distribution of OpenCV. The typical way of installing OpenCV is to download git repo and build it yourself.
I think you guys have seen this kind of errors before, but mine is special.
I have a few static libs in my Xcode project, when I tried to build it I got this error. But I have checked all my libs with command xcrun -sdk iphoneos lipo -info $libname, it gave me Architectures in the fat file: /Users/kiwi/Documents/Development/SourceCode/prj/lib.a are: armv7 i386 x86_64 arm64.
Undefined symbols for architecture armv7: "_SSLv2_server_method",
referenced from:
CSSLctx::Create(bool, CSSLctx::sslProtocol) in libudp.a(SSLStream.o) "_SSLv2_client_method", referenced from:
CSSLctx::Create(bool, CSSLctx::sslProtocol) in libudp.a(SSLStream.o) ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
I am trying to develop a simple c++ project which uses opencv.I followed http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html website.
But eclipse shows errors like
/usr/bin/ld: cannot find -llibopencv_photo
/usr/bin/ld: cannot find -llibopencv_stitching
/usr/bin/ld: cannot find -llibopencv_superres
/usr/bin/ld: cannot find -llibopencv_ts
/usr/bin/ld: cannot find -llibopencv_video
/usr/bin/ld: cannot find -llibopencv_videostab
/usr/bin/ld: cannot find -llibopencv_calib3d
/usr/bin/ld: cannot find -llibopencv_contrib
/usr/bin/ld: cannot find -llibopencv_ocl
/usr/bin/ld: cannot find -llibopencv_core
/usr/bin/ld: cannot find -llibopencv_core
/usr/bin/ld: cannot find -llibopencv_flann
/usr/bin/ld: cannot find -llibopencv_gpu
/usr/bin/ld: cannot find -llibopencv_highgui
/usr/bin/ld: cannot find -llibopencv_imgproc
/usr/bin/ld: cannot find -llibopencv_legacy
/usr/bin/ld: cannot find -llibopencv_ml
/usr/bin/ld: cannot find -llibopencv_nonfree
/usr/bin/ld: cannot find -llibopencv_objdetect
collect2: ld returned 1 exit status
make: *** [MyProject] Error 1`
I have included libraries and their paths in the following ways.
Project–>Properties
In C/C++ Build ->Settings.
In GCC C++ Compiler ->Includes.
In Include paths(-l) I have added /usr/local/include/opencv.
In GCC C++ Linker
I have added the path (-L) as /usr/local/lib and also library names.
Can anyone please tell me what the reason for this errors?
you have to add the library names without the prefix 'lib'
Whenever I try to compile my iPhone app which i am porting I get linking errors. The app uses a scripting language called Squirrel (to read the level files, fine by the SDK, no user input). I have linked all the libraries including libsquirrel.a. What am I doing wrong?
(App is SuperTux, source code at supertux.lethargik.org for computer version).
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_12AmbientSoundEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_12ThunderstormEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_13DisplayEffectEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_14ScriptedObjectEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_4TextEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_4WindEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_6CameraEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_6CandleEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_6PlayerEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_7SSectorEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_7TileMapEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_8PlatformEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_9LevelTimeEb", referenced from:
Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_9WillOWispEb", referenced from:
Line Location Tool:0: "__ZN9Scripting25register_supertux_wrapperEP4SQVM", referenced from:
Line Location Tool:0: __ZN9Scripting13expose_objectINS_12AmbientSoundEEEvP4SQVMiPT_RKSsb in ambient_sound.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_12ThunderstormEEEvP4SQVMiPT_RKSsb in thunderstorm-02078462.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_13DisplayEffectEEEvP4SQVMiPT_RKSsb in display_effect.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_14ScriptedObjectEEEvP4SQVMiPT_RKSsb in scripted_object.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_4TextEEEvP4SQVMiPT_RKSsb in text_object.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_4WindEEEvP4SQVMiPT_RKSsb in wind-9E10B675.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_6CameraEEEvP4SQVMiPT_RKSsb in camera-A3560D66.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_6CandleEEEvP4SQVMiPT_RKSsb in candle-06462D68.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_6PlayerEEEvP4SQVMiPT_RKSsb in player.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_7SSectorEEEvP4SQVMiPT_RKSsb in sector.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_7TileMapEEEvP4SQVMiPT_RKSsb in tilemap-8DC8046A.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_8PlatformEEEvP4SQVMiPT_RKSsb in platform-E187A570.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_9LevelTimeEEEvP4SQVMiPT_RKSsb in level_time-2C8E1157.o
Line Location Tool:0: __ZN9Scripting13expose_objectINS_9WillOWispEEEvP4SQVMiPT_RKSsb in willowisp.o
Line Location Tool:0: __ZN9Scripting13init_squirrelEb in squirrel_util.o
Line Location Tool:0: collect2: ld returned 1 exit status
Line Location Tool:0: symbol(s) not found
When I looked at the build output:
Ld "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/Debug-iphonesimulator/SuperTux.app/SuperTux" normal i386
cd "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux"
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk "-L/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/Debug-iphonesimulator" "-L/Users/Thomas/Documents/iPhone Dev Projects./SuperTux" "-L/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Library/Frameworks/SDL.framework/Headers" "-L/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Downloads/SQUIRREL2/lib" -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1 "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/Debug-iphonesimulator" "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Library/Frameworks" "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Downloads" "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux" -F/Applications/SuperTux.app/Contents/Frameworks "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Desktop/SDL2" -filelist <b>"/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/SuperTux.LinkFileList" -Wl,--no-demangle -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework SDL_image -framework Ogg -framework Vorbis -lSDLSimulator -lSDLiPhoneOS -framework SDL -framework OpenAL -lphysfsdevice "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/English.lproj/lphysfssimulator.a" -loggdevice -loggsim -lSDL_imagedevice -lSDL_imagesim -lvorbisdevice -lvorbisencdevice -lvorbisfiledevice -lvorbisencsim -lvorbisfilesim -lvorbissim -lminiswigdevice -lminiswigsim -lsqstdlib -framework SDL_mixer -framework SDL_image -lSDL_mixer -lSDL_mixersim -lstdc++-static -lstdc++ -lz -lSDLmain -framework CoreGraphics -framework CoreAudio -framework AudioToolbox -lsquirrelsim -lsquirreldevice -prebind -o "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/Debug-iphonesimulator/SuperTux.app/SuperTux"</b>
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libSDLiPhoneOS.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libphysfsdevice.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/liboggdevice.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libSDL_imagedevice.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libvorbisdevice.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libvorbisencdevice.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libvorbisfiledevice.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libminiswigdevice.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libSDL_mixer.a, file is not of required architecture
ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libsquirreldevice.a, file is not of required architecture
ld warning: __ZTVSt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(stdexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTISt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(stdexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTSSt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(stdexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTISt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(functexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTVSt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(functexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTSSt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(functexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
Something strange might be going on with libstdc++-static.a. Not even sure what it is.
C++filt is your friend it will unmangle those names to show you what is missing:
> c++filt __ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_12AmbientSoundEb
Scripting::create_squirrel_instance(SQVM*, Scripting::AmbientSound*, bool)
The first line from above seems to indicate that it can't find the definition of the method create_squirrel_instace from the class Scripting.
So the order the libraries are presented to g++ (which is the compiler used on a mac) is important. So have a look at the build output and see if you can find the line where the libraries are linked:
It should look like this:
g++ <STUFF> -l<lib1> -l<lib2> etc.
I reformated the abovre output so it is readable:
In the text I replace
/Users/Thomas/Documents/iPhone Dev Projects./SuperTux with <DIR> to help readability:
A whole bunch of the libraries are not being used becuase they are the wrong architecture:
ld warning: in <DIR>/SuperTux/libSDLiPhoneOS.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/libphysfsdevice.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/liboggdevice.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/libSDL_imagedevice.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/libvorbisdevice.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/libvorbisencdevice.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/libvorbisfiledevice.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/libminiswigdevice.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/libSDL_mixer.a,
file is not of required architecture
ld warning: in <DIR>/SuperTux/libsquirreldevice.a,
file is not of required architecture
Then you also have some warning you should look at:
ld warning: __ZTVSt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(stdexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTISt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(stdexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTSSt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(stdexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTISt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(functexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTVSt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(functexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
ld warning: __ZTSSt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(functexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o