alecjacobson / gptoolbox

Matlab toolbox for Geometry Processing.
MIT License
628 stars 166 forks source link

Mex files dependencies problem #6

Closed ergawy closed 8 years ago

ergawy commented 9 years ago

This is rather a help request than an issue with gptoolbox.

I want to use your blue noise code here: http://www.alecjacobson.com/weblog/?p=4111. For that I compiled the mex file "ambient_occlusion.cpp". I got that working smoothly and here is the output:

compile_gptoolbox_mex
Warning: This is **VERY** experimental. In principle, this should compile all of the mex functions in this
directory. In practice, users will surely have to adjust paths and flags at the top of this file. 
> In compile_gptoolbox_mex (line 73) 
Hit any key to continue...
Verbose mode is on.
No MEX options file identified; looking for an implicit selection.
... Looking for compiler 'g++' ...
... Executing command 'which g++' ...Yes ('/usr/bin/g++').
... Executing command 'g++ -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so').
Found installed compiler 'g++'.
Options file details
-------------------------------------------------------------------
    Compiler location: $GCC_DIR
    Options file: /usr/local/MATLAB/R2015a/bin/glnxa64/mexopts/g++_glnxa64.xml
    CMDLINE1 : /usr/bin/g++ -c -DMEX  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I/home/kareem/libigl/libigl/include -I/usr/include/eigen3 -I/home/kareem/libigl/libigl/external/embree -I/home/kareem/libigl/libigl/external/embree/include/  -I"/usr/local/MATLAB/R2015a/extern/include" -I"/usr/local/MATLAB/R2015a/simulink/include" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -msse4.2 -std=c++11 -O -DNDEBUG /home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.cpp -o /tmp/mex_27949599571242_14566/ambient_occlusion.o
    CMDLINE2 : /usr/bin/g++ -pthread -Wl,--no-undefined  -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2015a/extern/lib/glnxa64/mexFunction.map" /tmp/mex_27949599571242_14566/ambient_occlusion.o   -lembree  -lsys   -L/home/kareem/libigl/libigl/external/embree/build   -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L"/usr/local/MATLAB/R2015a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o ambient_occlusion.mexa64
    CMDLINE3 : rm -f /tmp/mex_27949599571242_14566/ambient_occlusion.o
    CXX : /usr/bin/g++
    DEFINES : -DMEX  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP   -D_GNU_SOURCE -DMATLAB_MEX_FILE 
    MATLABMEX : -DMATLAB_MEX_FILE 
    CXXFLAGS : -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -msse4.2 -std=c++11
    INCLUDE : -I/home/kareem/libigl/libigl/include -I/usr/include/eigen3 -I/home/kareem/libigl/libigl/external/embree -I/home/kareem/libigl/libigl/external/embree/include/  -I"/usr/local/MATLAB/R2015a/extern/include" -I"/usr/local/MATLAB/R2015a/simulink/include"
    CXXOPTIMFLAGS : -O -DNDEBUG
    CXXDEBUGFLAGS : -g
    LDXX : /usr/bin/g++
    LDFLAGS : -pthread -Wl,--no-undefined 
    LDTYPE : -shared
    LINKEXPORT : -Wl,--version-script,"/usr/local/MATLAB/R2015a/extern/lib/glnxa64/mexFunction.map"
    LINKLIBS : -lembree  -lsys   -L/home/kareem/libigl/libigl/external/embree/build   -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L"/usr/local/MATLAB/R2015a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++
    LDOPTIMFLAGS : -O
    LDDEBUGFLAGS : -g
    OBJEXT : .o
    LDEXT : .mexa64
    GCC : /usr/bin/g++
    CPPLIB_DIR : /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so
    MATLABROOT : /usr/local/MATLAB/R2015a
    ARCH : glnxa64
    SRC : /home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.cpp
    OBJ : /tmp/mex_27949599571242_14566/ambient_occlusion.o
    OBJS : /tmp/mex_27949599571242_14566/ambient_occlusion.o 
    SRCROOT : /home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion
    DEF : /tmp/mex_27949599571242_14566/ambient_occlusion.def
    EXP : ambient_occlusion.exp
    LIB : ambient_occlusion.lib
    EXE : ambient_occlusion.mexa64
    ILK : ambient_occlusion.ilk
    MANIFEST : ambient_occlusion.mexa64.manifest
    TEMPNAME : ambient_occlusion
    EXEDIR : 
    EXENAME : ambient_occlusion
    OPTIM : -O -DNDEBUG
    LINKOPTIM : -O
-------------------------------------------------------------------
Building with 'g++'.
/usr/bin/g++ -c -DMEX  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I/home/kareem/libigl/libigl/include -I/usr/include/eigen3 -I/home/kareem/libigl/libigl/external/embree -I/home/kareem/libigl/libigl/external/embree/include/  -I"/usr/local/MATLAB/R2015a/extern/include" -I"/usr/local/MATLAB/R2015a/simulink/include" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -msse4.2 -std=c++11 -O -DNDEBUG /home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.cpp -o /tmp/mex_27949599571242_14566/ambient_occlusion.o
/usr/bin/g++ -pthread -Wl,--no-undefined  -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2015a/extern/lib/glnxa64/mexFunction.map" /tmp/mex_27949599571242_14566/ambient_occlusion.o   -lembree  -lsys   -L/home/kareem/libigl/libigl/external/embree/build   -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L"/usr/local/MATLAB/R2015a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o ambient_occlusion.mexa64
rm -f /tmp/mex_27949599571242_14566/ambient_occlusion.o
MEX completed successfully.

I also appended the path to embree to the LD_LIBRARY_PATH and here is the full path:

/usr/local/MATLAB/R2015a/sys/os/glnxa64:/usr/local/MATLAB/R2015a/bin/glnxa64:/usr/local/MATLAB/R2015a/extern/lib/glnxa64:/usr/local/MATLAB/R2015a/runtime/glnxa64:/usr/local/MATLAB/R2015a/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/R2015a/sys/java/jre/glnxa64/jre/lib/amd64/server:/opt/AMDAPPSDK-3.0/lib/x86_64/:/home/kareem/libigl/libigl/external/embree/build

However, when I try to run your blue noise code, I get the following error:

Invalid MEX-file '/home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.mexa64': libembree.so.2:
cannot open shared object file: No such file or directory

To check the dependencies of ambient_occlusion.mexa64, I ran !ldd and here is what I got:

/home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.mexa64: /usr/local/MATLAB/R2015a/sys/os/glnxa64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/kareem/libigl/libigl/external/embree/build/libembree.so.2)
/home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.mexa64: /usr/local/MATLAB/R2015a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/kareem/libigl/libigl/external/embree/build/libembree.so.2)
    linux-vdso.so.1 =>  (0x00007fff4b140000)
    libembree.so.2 => /home/kareem/libigl/libigl/external/embree/build/libembree.so.2 (0x00007f3dd8cdf000)
    libmx.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmx.so (0x00007f3dd8907000)
    libmex.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmex.so (0x00007f3dd86d8000)
    libstdc++.so.6 => /usr/local/MATLAB/R2015a/sys/os/glnxa64/libstdc++.so.6 (0x00007f3dd83d1000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3dd80c9000)
    libgcc_s.so.1 => /usr/local/MATLAB/R2015a/sys/os/glnxa64/libgcc_s.so.1 (0x00007f3dd7eb4000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3dd7aea000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3dd78cc000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f3dd94d8000)
    libmwresource_core.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwresource_core.so (0x00007f3dd76ca000)
    libmwi18n.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwi18n.so (0x00007f3dd73dc000)
    libut.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libut.so (0x00007f3dd711d000)
    libmwfl.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwfl.so (0x00007f3dd6d19000)
    libmwMATLAB_res.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwMATLAB_res.so (0x00007f3dd6674000)
    libboost_date_time.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_date_time.so.1.49.0 (0x00007f3dd6463000)
    libboost_filesystem.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_filesystem.so.1.49.0 (0x00007f3dd6244000)
    libboost_log.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_log.so.1.49.0 (0x00007f3dd5f6c000)
    libboost_signals.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_signals.so.1.49.0 (0x00007f3dd5d54000)
    libboost_system.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_system.so.1.49.0 (0x00007f3dd5b51000)
    libboost_thread.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_thread.so.1.49.0 (0x00007f3dd5936000)
    libmwcpp11compat.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwcpp11compat.so (0x00007f3dd5729000)
    libicudata.so.52 => /usr/local/MATLAB/R2015a/bin/glnxa64/libicudata.so.52 (0x00007f3dd3ec0000)
    libicuuc.so.52 => /usr/local/MATLAB/R2015a/bin/glnxa64/libicuuc.so.52 (0x00007f3dd3b35000)
    libicui18n.so.52 => /usr/local/MATLAB/R2015a/bin/glnxa64/libicui18n.so.52 (0x00007f3dd3712000)
    libicuio.so.52 => /usr/local/MATLAB/R2015a/bin/glnxa64/libicuio.so.52 (0x00007f3dd3505000)
    libtbb.so.2 => /usr/local/MATLAB/R2015a/bin/glnxa64/libtbb.so.2 (0x00007f3dd32ba000)
    libtbbmalloc.so.2 => /usr/local/MATLAB/R2015a/bin/glnxa64/libtbbmalloc.so.2 (0x00007f3dd3068000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f3dd2e4d000)
    libmwservices.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwservices.so (0x00007f3dd2818000)
    libmwmpath.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwmpath.so (0x00007f3dd25d4000)
    libmwm_dispatcher.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwm_dispatcher.so (0x00007f3dd22d0000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3dd20cc000)
    libexpat.so.1 => /usr/local/MATLAB/R2015a/bin/glnxa64/libexpat.so.1 (0x00007f3dd1ea4000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3dd1c9c000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f3dd1a64000)
    libboost_chrono.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_chrono.so.1.49.0 (0x00007f3dd185d000)
    libboost_regex.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_regex.so.1.49.0 (0x00007f3dd1542000)
    libboost_serialization.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_serialization.so.1.49.0 (0x00007f3dd12ca000)
    libunwind.so.8 => /usr/local/MATLAB/R2015a/bin/glnxa64/libunwind.so.8 (0x00007f3dd10ab000)
    libmwdisplay_device.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwdisplay_device.so (0x00007f3dd0ea6000)
    libmwregexp.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwregexp.so (0x00007f3dd0c5e000)
    libmwmlutil.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwmlutil.so (0x00007f3dd058b000)
    libmwsettingscore.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwsettingscore.so (0x00007f3dd0121000)
    libmwms.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwms.so (0x00007f3dcfb4e000)
    libmwMATLAB_settings_res.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwMATLAB_settings_res.so (0x00007f3dcf92c000)
    libmwnativedisplay.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwnativedisplay.so (0x00007f3dcf723000)
    libmwopccore.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwopccore.so (0x00007f3dcf4c3000)
    libmwopcmodel.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwopcmodel.so (0x00007f3dcf23d000)
    libmwopczippackage.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwopczippackage.so (0x00007f3dcf01b000)
    libmwopcmwservices.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwopcmwservices.so (0x00007f3dceb33000)
    libboost_iostreams.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_iostreams.so.1.49.0 (0x00007f3dce91e000)
    libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007f3dce6fa000)
    libssl.so.1.0.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libssl.so.1.0.0 (0x00007f3dce490000)
    libcrypto.so.1.0.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libcrypto.so.1.0.0 (0x00007f3dce0ae000)
    libPocoCrypto.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoCrypto.so.23 (0x00007f3dcde8c000)
    libPocoFoundation.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoFoundation.so.23 (0x00007f3dcdad7000)
    libPocoJSON.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoJSON.so.23 (0x00007f3dcd88a000)
    libPocoNet.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoNet.so.23 (0x00007f3dcd580000)
    libPocoNetSSL.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoNetSSL.so.23 (0x00007f3dcd33f000)
    libPocoUtil.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoUtil.so.23 (0x00007f3dcd0d4000)
    libPocoXML.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoXML.so.23 (0x00007f3dcce46000)
    libxerces-c-3.1.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libxerces-c-3.1.so (0x00007f3dcc7c1000)
    libmwxmlcore.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwxmlcore.so (0x00007f3dcc54d000)
    libavrocpp.so.1.7.5.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libavrocpp.so.1.7.5.0 (0x00007f3dcc26f000)
    libmwflnetwork.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwflnetwork.so (0x00007f3dcbf8d000)
    libminizip.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libminizip.so (0x00007f3dcbd81000)
    libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f3dcbb58000)
    libboost_program_options.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_program_options.so.1.49.0 (0x00007f3dcb8fa000)

Please note the first 2 lines of the above !ldd output. This is strange to me and I tried to solve it using the suggestions here: http://stackoverflow.com/questions/23494103/version-cxxabi-1-3-8-not-found-required-by with no success.

Any pointers on how can I solve this?

alecjacobson commented 9 years ago

First, the ambient_occlusion function is only for making the rendering fancier and is not needed for the blue noise function.

Second, it seems like a path issue. Are you checking that LD_LIBRARY_PATH is what you think you've set it to from within matlab? I know on Mac OS X it is not enough to set the path in your .bashrc or .profile.

You can check by issuing in matlab,

system('echo $LD_LIBRARY_PATH')
ergawy commented 9 years ago

Thank you for the reply. It is just my first time working with mex files so I wanted to get it to the end. I know that ambient occlusion is auxiliary here.

Here is what system('echo $LD_LIBRARY_PATH') prints:

/usr/local/MATLAB/R2015a/sys/os/glnxa64:/usr/local/MATLAB/R2015a/bin/glnxa64:/usr/local/MATLAB/R2015a/extern/lib/glnxa64:/usr/local/MATLAB/R2015a/runtime/glnxa64:/usr/local/MATLAB/R2015a/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/R2015a/sys/java/jre/glnxa64/jre/lib/amd64/server:/opt/AMDAPPSDK-3.0/lib/x86_64/:/home/kareem/libigl/libigl/external/embree

So I guess the path to embree is correctly configured. I am on a Linux machine so maybe the problem you mentioned is not present.

Anyway, I don't want to waste your time so I will try to find the reason for this and get back to the thread if I find out the problem.

alecjacobson commented 8 years ago

@KareemErgawy Did you end up finding a solution for this?