PROBLEM SOLVED:::
I am using LEDA library in c++.
command used to make object file.
g++ -I$LEDAROOT/incl -c mult.cpp
this command runs fine
I am getting eroor while linking step.
HERE IS THE EROOR
varun#Kinley:~/Documents/LEDA/test/numbers$ g++ -L$LEDAROOT mult.o -lleda -lX11 -lm
/usr/bin/ld: cannot find -lX11
collect2: error: ld returned 1 exit status
I think I need to install some package,because when I googled this error the most of problems are solved by installing some package .
I didn't find lx11 error
some of the eroor messages that I googled.
error 1
/usr/bin/ld: cannot find -lfreetype collect2: ld returned 1 exit
status
error 2
/usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status
Links where I find these posts
http://www.qtcentre.org/threads/21069-collect2-ld-returned-1-exit-status
http://www.cyberciti.biz/faq/centos-rhel-redhat-usrbinld-cannot-findlc-error/
Do I need to install some package or there is some other problem
Could be two things
1) The X11 library is installed in a non-standard path. Use the search command to see if libX11.a or libX11.so is available on your system. If yes add the directory path to the -L option.
2) You are missing the libX11 library.
In this case, login as admin and use yum (assuming linux) to install this library.
Eg:
"yum install libX11.i386" or "yum install libX11.x86_64", depending on your architecture (32 bit or 64 bit).
Related
I was trying to follow the instructions here to setup WxWidgets.
I've managed to run the commands wx-config --version and wx-config --list but not the commands to compile the minimal example, which are:
cd gtk-build/samples/minimal
make
./minimal
After lots of display messages I arrive at:
/usr/bin/ld: cannot find -lwxtiff-3.1
/usr/bin/ld: cannot find -lwxjpeg-3.1
/usr/bin/ld: cannot find -lwxregexu-3.1
collect2: error: ld returned 1 exit status
make: *** [minimal] Error 1
Makefile:149: recipe for target 'minimal' failed
The command '/bin/sh -c make' returned a non-zero code: 2
Did I miss the installation of some library?
There is a similar question for windows here, but the answers there seem not to apply for linux.
First of all, please look at the official instructions rather than the wiki which may, or not, be up to date.
Second, by running make clean you removed the libraries used by the in-tree makefiles. So, unsurprisingly, you can't use them any more, but you can use makefile.unx from the source tree, i.e. if wx-config is in your PATH, just use make -f makefile.unx in $wx/samples/minimal (and not under gtk-build/samples/minimal).
So I am not working on a computer but on an embedded device running ubuntu.
I am trying to compile openCV code but I have the feeling that I am in a deadlock!
This is the error I get:
problem:
/usr/bin/ld: warning: libopencv_core.so.3.2, needed by //usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_core.so.2.4
/usr/bin/ld: /tmp/ccYlsBYW.o: undefined reference to symbol '_ZN2cv11setIdentityERKNS_17_InputOutputArrayERKNS_7Scalar_IdEE'
/usr/local/lib//libopencv_core.so.3.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
rename 2.4 libraries:
ubuntu#tegra-ubuntu:/usr/lib$ sudo mv libopencv_core.so libopencv_core.soMyOld
ubuntu#tegra-ubuntu:/usr/lib$ sudo mv libopencv_core.so.2.4 libopencv_core.so.2.4MyOld
ubuntu#tegra-ubuntu:/usr/lib$ sudo mv libopencv_core.so.2.4.10 libopencv_core.so.2.4.10MyOld
recompile code
/usr/bin/ld: warning: libopencv_core.so.2.4, needed by /usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../../lib/libopencv_imgproc.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libopencv_imgproc.so.3.2, needed by //usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_imgproc.so.2.4
/usr/bin/ld: /tmp/ccmcvWug.o: undefined reference to symbol '_ZN2cv6circleERKNS_17_InputOutputArrayENS_6Point_IiEEiRKNS_7Scalar_IdEEiii'
/usr/local/lib//libopencv_imgproc.so.3.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
renaming 3.2 libraries:
ubuntu#tegra-ubuntu:/usr/local/lib$ sudo mv libopencv_core.so
ubuntu#tegra-ubuntu:/usr/local/lib$ sudo mv libopencv_core.so.3.2 libopencv_core.so.3.2MyOld
ubuntu#tegra-ubuntu:/usr/local/lib$ sudo mv libopencv_core.so.3.2.0 libopencv_core.so.3.2.0MyOld
recompile
/usr/bin/ld: warning: libopencv_core.so.3.2, needed by //usr/local/lib/libopencv_imgcodecs.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libopencv_imgproc.so.3.2, needed by //usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_imgproc.so.2.4
/usr/bin/ld: /tmp/cclHSHtB.o: undefined reference to symbol '_ZN2cv6circleERKNS_17_InputOutputArrayENS_6Point_IiEEiRKNS_7Scalar_IdEEiii'
/usr/local/lib//libopencv_imgproc.so.3.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
What can I do to solve this issue? Uninstalling everything and reinstalling is not an option...
EDIT:
I compile with this command:
g++ src/personDetection.cpp src/personRecognition.cpp main.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_calib3d -lopencv_features2d -lopencv_video -lopencv_videoio -pthread -o main
-L option is used to specify the directory path. Compiler will search this directory with other system standard directories, such as directories in LIBRARY_PATH. But it searches directories specified with -L first.
-l option is used to specify the name of the library.
In your case, 2.4 version libraries are in /usr/lib and 3.2 version libraries are in /usr/local/lib. Your code, probably, is expecting 2.4 version, but your system may be set to search /usr/local/lib before searching /usr/lib and this may be the cause of your problem.
By specifying -L/usr/lib you are telling compiler to search /usr/lib first, resulting in using 2.4 version libraries.
UPDATE
$ gcc -m64 -Xlinker --verbose 2>/dev/null | grep SEARCH | sed 's/SEARCH_DIR("=\?\([^"]\+\)"); */\1\n/g' | grep -vE '^$'
Above command will show you the list of default searched directories when linking. (copied the command from this article)
In my machine(Ubuntu 16.04, 64-bit), /usr/local/lib appears before /usr/lib. This means that a library in /usr/local/lib can override libraries in /usr/lib. (link)
I've attempted to build g++ v5.1.0 on my Centos 6 system. The build seems to have worked, but when I try to compile and >link< a program, the linker fails thus:
[seesdev#sees15-lin ~]$ g++ -o testcpp testcpp.cpp
/usr/bin/ld: unrecognized option '-plugin'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
Do I have to get a newer version of "ld"? How?
I am trying to debug why protobuf is not being linked in my C++ project.
So I tried this in cygwin:
$ gcc -libprotobuf
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -libprotobuf
collect2: error: ld returned 1 exit status
I built and installed protobuf on cygwin.
it should be -lprotobuf, find libprotobuf.so in /usr/lib or /usr/lib64/
I got the following error when compiling a simple hello world program on debian amd64 wheezy(testing) with g++ -m32:
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
I don't have any problems with gcc -m32. I also installed lib32stdc++ package, but it does not seem to work. Thanks.
Pretty sure you need to install g++-4.6-multilib (it would appear you already have gcc-4.6-multilib).
Try installing ia32-libs-dev package.