Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Compilation error - file not found #137

Closed
andortizg opened this issue Feb 10, 2015 · 6 comments
Closed

Compilation error - file not found #137

andortizg opened this issue Feb 10, 2015 · 6 comments

Comments

@andortizg
Copy link

andortizg commented Feb 10, 2015

Hi all,

I am trying to install it under ubuntu 14.04.1 LTS / matlab 2011b but make returns the following:

g++: error: libX11: No such file or directory
g++: error: libICE: No such file or directory
g++: error: libSM: No such file or directory
g++: error: libGL: No such file or directory
g++: error: libGLU: No such file or directory

   mex: link of ' "+cv/adaptiveThreshold.mexa64"' failed.

make: **\* [+cv/adaptiveThreshold.mexa64] Error 1

Of course this is the same error than mexopencv.make returns.
I have also try with my own compiled opencv and with the repository's one. I have also changed the opencv folder in the make.m script.

(I also tried to run the remove_nonfree.sh script before make without success -> same error).

Does anyone know where the problem could be?

Thank you very much!

@amroamroamro
Copy link
Collaborator

Can you provide more info? Please post the verbose output from compilation (edit Makefile and add -v flag to the C_FLAGS line)..

Let's hope it's not again an issue with pkg-config (which was hopefully fixed last time in #110) 🙏

@andortizg
Copy link
Author

andortizg commented Feb 10, 2015

Thank you for answering.

The output with the -v flag is: (please, note that g++:error indicates no such file or directory)

/home/andres/matlab/R2011b/bin/mex -v -cxx -largeArrayDims -Iinclude -I/usr/local/include/opencv -I/usr/local/include   src/+cv/adaptiveThreshold.cpp -lMxArray -Llib -ltbb -lrt -lpthread -lm -ldl -L/usr/lib/x86_64-linux-gnu/ -L/usr/local/lib/  -lopencv_calib3d  -lopencv_contrib  -lopencv_core  -lopencv_features2d  -lopencv_flann  -lopencv_gpu  -lopencv_highgui  -lopencv_imgproc  -lopencv_legacy  -lopencv_ml  -lopencv_nonfree  -lopencv_objdetect  -lopencv_ocl  -lopencv_photo  -lopencv_stitching  -lopencv_superres  -lopencv_ts  -lopencv_video  -lopencv_videostab  -lopencv_viz libXext libX11 libICE libSM libGL libGLU -output +cv/adaptiveThreshold
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
   FILE = /home/andres/.matlab/R2011b/mexopts.sh
----------------------------------------------------------------
->    MATLAB                = /home/andres/matlab/R2011b
->    CC                    = gcc
->    CC flags:
         CFLAGS             = -ansi -D_GNU_SOURCE  -fexceptions -fPIC -fno-omit-frame-pointer -pthread
         CDEBUGFLAGS        = -g
         COPTIMFLAGS        = -O -DNDEBUG
         CLIBS              = -Wl,-rpath-link,/home/andres/matlab/R2011b/bin/glnxa64 -L/home/andres/matlab/R2011b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
         arguments          = 
->    CXX                   = g++
->    CXX flags:
         CXXFLAGS           = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread
         CXXDEBUGFLAGS      = -g
         CXXOPTIMFLAGS      = -O -DNDEBUG
         CXXLIBS            = -Wl,-rpath-link,/home/andres/matlab/R2011b/bin/glnxa64 -L/home/andres/matlab/R2011b/bin/glnxa64 -lmx -lmex -lmat -lm
         arguments          = 
->    FC                    = gfortran
->    FC flags:
         FFLAGS             = -fexceptions -fbackslash -fPIC -fno-omit-frame-pointer
         FDEBUGFLAGS        = -g
         FOPTIMFLAGS        = -O
         FLIBS              = -Wl,-rpath-link,/home/andres/matlab/R2011b/bin/glnxa64 -L/home/andres/matlab/R2011b/bin/glnxa64 -lmx -lmex -lmat -lm
         arguments          = 
->    LD                    = g++
->    Link flags:
         LDFLAGS            = -pthread -shared -Wl,--version-script,/home/andres/matlab/R2011b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined
         LDDEBUGFLAGS       = -g
         LDOPTIMFLAGS       = -O
         LDEXTENSION        = .mexa64
         arguments          =  -lMxArray -Llib -ltbb -lrt -lpthread -lm -ldl -L/usr/lib/x86_64-linux-gnu/ -L/usr/local/lib/ -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lopencv_viz libXext libX11 libICE libSM libGL libGLU
->    LDCXX                 = 
->    Link flags:
         LDCXXFLAGS         = 
         LDCXXDEBUGFLAGS    = 
         LDCXXOPTIMFLAGS    = 
         LDCXXEXTENSION     = 
         arguments          =  -lMxArray -Llib -ltbb -lrt -lpthread -lm -ldl -L/usr/lib/x86_64-linux-gnu/ -L/usr/local/lib/ -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lopencv_viz libXext libX11 libICE libSM libGL libGLU
----------------------------------------------------------------

-> g++ -c  -Iinclude -I/usr/local/include/opencv -I/usr/local/include -I/home/andres/matlab/R2011b/extern/include -I/home/andres/matlab/R2011b/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread  -O -DNDEBUG  "src/+cv/adaptiveThreshold.cpp"

-> g++ -O -pthread -shared -Wl,--version-script,/home/andres/matlab/R2011b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o  "+cv/adaptiveThreshold.mexa64"  adaptiveThreshold.o  -lMxArray -Llib -ltbb -lrt -lpthread -lm -ldl -L/usr/lib/x86_64-linux-gnu/ -L/usr/local/lib/ -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lopencv_viz libXext libX11 libICE libSM libGL libGLU -Wl,-rpath-link,/home/andres/matlab/R2011b/bin/glnxa64 -L/home/andres/matlab/R2011b/bin/glnxa64 -lmx -lmex -lmat -lm

g++: error: libXext: No existe el archivo o el directorio
g++: error: libX11: No existe el archivo o el directorio
g++: error: libICE: No existe el archivo o el directorio
g++: error: libSM: No existe el archivo o el directorio
g++: error: libGL: No existe el archivo o el directorio
g++: error: libGLU: No existe el archivo o el directorio

    mex: link of ' "+cv/adaptiveThreshold.mexa64"' failed.

make: *** [+cv/adaptiveThreshold.mexa64] Error 1

Regards,

@amroamroamro
Copy link
Collaborator

@AndrewOG:
Obviously those libraries should have been specified to the compiler as:

g++ ... -lXext -lX11 -lICE -lSM -lGL -lGLU ...

As I suspected, the cause of the problem is the pkg-config call... You can confirm this by opening a terminal and running:

# assuming PKG_CONFIG_PATH is correctly set
pkg-config --libs opencv

If you want to quickly fix the problem, locate the opencv.pc file installed by OpenCV and manually edit the "libs" line by replacing occurrences of arguments of the form libFOO with -lFOO instead (where FOO are the above libraries that causes the error).

@andortizg
Copy link
Author

andortizg commented Feb 10, 2015

I understand the problem. However, my libs line in opencv.pc looks:

Libs:  ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so ${exec_prefix}/lib/libopencv_viz.so -ltbb /usr/lib/x86_64-linux-gnu/libXext.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so -lrt -lpthread -lm -ldl

I have not -libXXX in opencv.pc file. Moreover, I have checked for lib files in /usr/lib/x86_64-linux-gnu/ and these files exist.

Thank you again!

@amroamroamro
Copy link
Collaborator

@AndrewOG:
That's pretty much the same problem.. When linking against libraries using GCC, the correct syntax is:

g++ file.cpp -L/some/path -lfoo 

as opposed to:

g++ file.cpp /some/path/libfoo.so

So in your case, edit the opencv.pc to say:

Libs: -L${exec_prefix}/lib -L/usr/lib/x86_64-linux-gnu -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lopencv_viz -ltbb -lXext -lX11 -lICE -lSM -lGL -lGLU -lrt -lpthread -lm -ldl

(NOTE: if the opencv.pc file is installed system-wide in a protected folder, you might have to start the editor with sudo)

@andortizg
Copy link
Author

It compiles now.

Thank you very much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants