-1

I'm trying to link opencv libraries in eclipse for a c++ project.
When I link libraries that have one instance in the folder it seems to recognize it, but doesn't recognize when the libraries have few instances (perhaps the term instance isn't so accurate, i'm not quite sure what is the meaning of these different versions of libraries).
Therefore the problem doesn't seem to be related to misuse of lib or wrong path, as i have seen in other questions.

This is what I get when building the project:

12:33:17 **** Incremental Build of configuration Debug for project Test2 ****    
make all     
Building target: Test2    
Invoking: GCC C++ Linker    
g++ -L/usr/local/Matlab/2013b/bin/glnxa64 -o "Test2"  ./BilateralFilter.o ./main.o ./stdafx.o   -lopencv_core -lmwvision_res -lmwvision -lopencv_imgproc -lopencv_highgui    
/usr/bin/ld: cannot find -lopencv_core    
/usr/bin/ld: cannot find -lopencv_imgproc    
/usr/bin/ld: cannot find -lopencv_highgui    
collect2: error: ld returned 1 exit status    
make: *** [Test2] Error 1    

as you can see, the mwvision doesn't seem to have a problem, but the others do, and I think it has to do with them existing in multiple versions in the directory (but perhaps i'm wrong).
opencv_core, opencv_imgproc and opencv_highgui all have .so.2.4 and .so.2.4.2 versions.

These two links unfortunately did not provide an answer:
ld linkage problems: /usr/bin/ld: cannot find [libraryname]

/usr/bin/ld: cannot find shared library

Also I will mention that I have no use in Matlab, it's just where I found the libraries of opencv.

Community
  • 1
  • 1
Achi Even-dar
  • 427
  • 1
  • 10
  • 20
  • Do you have `lib.a` files for all of these in the directory `/usr/local/Matlab/2013b/bin/glnxa64`? You probably need to add another `-L` option specifying where your opencv libs are actually placed. – πάντα ῥεῖ Dec 14 '14 at 10:49
  • no, only .so is what I see. What do you mean by "where your opencv libs are actually placed"? – Achi Even-dar Dec 14 '14 at 10:51
  • For linking, you need the stubs `libopencv_core.a`,`libopencv_imgproc.a`, etc. – πάντα ῥεῖ Dec 14 '14 at 10:54
  • **locate** command only found the **.so** libraries. Any idea of another way to search for it? – Achi Even-dar Dec 14 '14 at 10:58
  • Where did you get the headers from ? – πάντα ῥεῖ Dec 14 '14 at 11:01
  • https://code.google.com/p/bilateralfilter/source/browse/trunk/BilateralFilter.cpp?r=3 – Achi Even-dar Dec 14 '14 at 11:04
  • You had some opencv headers included when compiling `./BilateralFilter.o ./main.o`, didn't you? – πάντα ῥεῖ Dec 14 '14 at 11:05
  • https://code.google.com/p/bilateralfilter/source/browse/trunk/BilateralFilter.cpp?r=3 It's pretty much copy pasted from there. I changed the **TCHAR** use to **char***, but basically it's the same. And now i'm trying to run it. – Achi Even-dar Dec 14 '14 at 11:09
  • "existing in multiple versions in the directory". Which directory? – n. m. could be an AI Dec 14 '14 at 11:11
  • Sigh! https://code.google.com/p/bilateralfilter/source/browse/trunk/InstallingOpenCV.txt?r=3 – πάντα ῥεῖ Dec 14 '14 at 11:11
  • @n.m This directory: **/usr/local/Matlab/2013b/bin/glnxa64** – Achi Even-dar Dec 14 '14 at 11:12
  • Are you sure the libraries have correct architecture for the platform (x86 vs x86_64)? Do you have symbolic links set up correctly (say libopencv_core.so pointing to libopencv_core.so.2 pointing to libopencv_core.so.2.4)? – n. m. could be an AI Dec 14 '14 at 11:16
  • @πάντα ῥεῖ Is there a problem with this website? Not reliable or something? – Achi Even-dar Dec 14 '14 at 11:17
  • @n.m **readlink libopencv_core.so.2.4** returned **libopencv_core.so.2.4.2** Whereas **readlink libopencv_core.so.2.4.2** didn't return anything – Achi Even-dar Dec 14 '14 at 11:24
  • @achie Did you read what's written in the link there? _`Additional Library Directories: "C:\Program Files\OpenCV\lib"`_ – πάντα ῥεῖ Dec 14 '14 at 11:34
  • I didn't find such directory in my download, so I tried to get over it in a different way. Was that a bad idea? What should I have done? – Achi Even-dar Dec 14 '14 at 11:47
  • You need `libopencv_core.so` without any version that is a symbolic link to some specific version like `libopencv_core.so.2.4`. I presume you have verified that the libraries have the right architecture. – n. m. could be an AI Dec 14 '14 at 11:51
  • @n.m I'm sorry, i'm not too strong with technical issues. Regarding right architecture, does commiting "file " any good? here's the output. > 'cs302six2-3:/usr/local/Matlab/2013b/bin/glnxa64> file libopencv_core.so.2.4 > libopencv_core.so.2.4: symbolic link to `libopencv_core.so.2.4.2' > cs302six2-3:/usr/local/Matlab/2013b/bin/glnxa64> file libopencv_core.so.2.4.2 > libopencv_core.so.2.4.2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
    ' Is there a way to isolate the 2.4.2 version as it is not a symbolic link?
    – Achi Even-dar Dec 14 '14 at 12:22
  • Sorry the comment came out not organized, i'm new here and couldn't find a way to break the lines. My intension is: **file libopencv_core.so.2.4** gave output **libopencv_core.so.2.4: symbolic link to `libopencv_core.so.2.4.2'** whereas **file libopencv_core.so.2.4.2** gave output **libopencv_core.so.2.4.2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped**. – Achi Even-dar Dec 14 '14 at 12:31
  • @achie _"Was that a bad idea?"_ Probably, yes. _"What should I have done?"_ Exactly what's written in the link, install the OpenCv library. – πάντα ῥεῖ Dec 14 '14 at 12:40
  • You are probably better off installing OpenCV from the repository. If you for some reason don't want to, then no, 2.4.2 is not and should not be isolated and it is not supposed to be a symbolic link. Files *.so without versions are supposed to be symbolic links. Do you have .so symbolic links without versions? If not, you need to create them (not recommended --- just open your package manager and install OpenCV). – n. m. could be an AI Dec 14 '14 at 13:19

1 Answers1

0

opencv_core, opencv_imgproc and opencv_highgui all have .so.2.4 and .so.2.4.2 versions.

If you read this description of external library versioning, you'll understand that the .so.2.4 is a runtime name of the library, and not its link-time name.

In order to link, you need .so (without the version suffix).

Having .so.2.4 but not .so usually comes about when you have e.g. libopencv-core package installed, but not libopencv-core-dev. The solution is to install the latter.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362