Initial MATLAB compilation

315 views
Skip to first unread message

Eric Schneider

unread,
Nov 28, 2021, 6:54:50 PM11/28/21
to gtsam users
Hi,

I'm trying to get basic MATLAB examples running, and am having some trouble getting off the ground. Please let me know if I'm making any stupid mistakes! I'm trying to follow the instructions here (https://github.com/borglab/gtsam/blob/develop/matlab/README.md) so I started off with

~/gtsam/build$ make clean
~/gtsam/build$ cmake .. -DGTSAM_INSTALL_MATLAB_TOOLBOX=ON
-- GTSAM_POSE3_EXPMAP=ON, enabling GTSAM_ROT3_EXPMAP as well
-- Found Eigen version: 3.3.7
...
-- pybind11 v2.6.0 dev1
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find Matlab (missing: Matlab_INCLUDE_DIRS Matlab_MEX_LIBRARY
  Matlab_MEX_EXTENSION Matlab_ROOT_DIR Matlab_MX_LIBRARY MEX_COMPILER) (found
  version "NOTFOUND")
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindMatlab.cmake:1802 (find_package_handle_standard_args)
  wrap/cmake/MatlabWrap.cmake:10 (find_package)
  wrap/cmake/MatlabWrap.cmake:67 (find_and_configure_matlab)
  matlab/CMakeLists.txt:68 (matlab_wrap)

With some googling that was resolved (perhaps incorrectly?) with

~/gtsam/build$ export LD_LIBRARY_PATH=/usr/local/MATLAB/R2021a/bin/glnxa64:/usr/local/MATLAB/R2021a/sys/os/glnxa64:$LD_LIBRARY_PATH
~/gtsam/build$ cmake .. -DGTSAM_INSTALL_MATLAB_TOOLBOX=ON
cmake: /usr/local/MATLAB/R2021a/bin/glnxa64/libcurl.so.4: version `CURL_OPENSSL_4' not found (required by cmake)

There were a few more "version not found" errors initially but removing the libstdc++ files as suggested in the instructions removed those. I think the further "Adding the toolbox to your MATLAB path" instructions are only useful once you've built with MATLAB, though I may be wrong there. My goal with all of this is to be able to run the examples in gtsam/matlab/gtsam_examples.

Thanks!
Eric

Eric Schneider

unread,
Nov 29, 2021, 5:06:27 PM11/29/21
to gtsam users
Some additional information. libcurl-openssl-dev is installed:

~/gtsam/build$ sudo apt-get install libcurl-dev ... Package libcurl-dev is a virtual package provided by: libcurl4-openssl-dev 7.68.0-1ubuntu2.7 libcurl4-nss-dev 7.68.0-1ubuntu2.7 libcurl4-gnutls-dev 7.68.0-1ubuntu2.7 You should explicitly select one to install. E: Package 'libcurl-dev' has no installation candidate ~/gtsam/build$ sudo apt-get install libcurl4-openssl-dev ... libcurl4-openssl-dev is already the newest version (7.68.0-1ubuntu2.7). libcurl4-openssl-dev set to manually installed. ... 0 upgraded, 0 newly installed, 0 to remove and 152 not upgraded.

And there are also multiple versions of libcurl around:

~/gtsam/build$ locate libcurl.so.4 /usr/lib/x86_64-linux-gnu/libcurl.so.4 /usr/lib/x86_64-linux-gnu/libcurl.so.4.6.0 /usr/local/MATLAB/R2021a/bin/glnxa64/libcurl.so.4 /usr/local/MATLAB/R2021a/bin/glnxa64/libcurl.so.4.6.0 /usr/local/MATLAB/R2021a/sys/ros2/glnxa64/ros2/opt/libcurl_vendor/lib/libcurl.so.4 /usr/local/MATLAB/R2021a/sys/ros2/glnxa64/ros2/opt/libcurl_vendor/lib/libcurl.so.4.6.0 /usr/local/MATLAB/R2021a/toolbox/compiler_sdk/mps_clients/c/glnxa64/lib/libcurl.so.4 /usr/local/MATLAB/R2021a/toolbox/compiler_sdk/mps_clients/c/glnxa64/lib/libcurl.so.4.6.0

I tried making a backup of the versions of /usr/local/MATLAB/R2021a/bin/glnxa64/ and copied in the /usr/lib/x86_64-linux-gnu/ versions, thinking maybe I needed to use the latest installed version. The Could NOT find Matlab (missing: Matlab_INCLUDE_DIRS Matlab_MEX_LIBRARY error from the first post came up again.

Eric Schneider

unread,
Dec 2, 2021, 11:27:44 AM12/2/21
to gtsam users
There may be other ways to solve it, but doing export Matlab_ROOT_DIR=/usr/local/MATLAB/R2021a/ instead of the originally mentioned LD_LIBRARY_PATH export gets cmake .. -DGTSAM_INSTALL_MATLAB_TOOLBOX=ON to run. However, the make step fails. Should there be some step between cmake and make? Actually, looking at the instructions again I'm confused by the steps - "To build [the MATLAB toolbox], enable GTSAM_INSTALL_MATLAB_TOOLBOX=ON in CMake. The interface to the toolbox is generated automatically by the wrap tool which directly parses C++ header files." - should the toolbox already be available after cmake with no make needed?

~/gtsam/build$ make
...
[ 97%] Built target pybind_wrap_gtsam_unstable [ 97%] Built target gtsam_unstable_header [ 97%] Built target gtsam_unstable_py
[ 97%] Generating ../wrap/gtsam/gtsam_wrapper.cpp
Traceback (most recent call last):
  File "/home/eric/gtsam/wrap/scripts/matlab_wrap.py", line 11, in <module>
    from gtwrap.matlab_wrapper import MatlabWrapper
ModuleNotFoundError: No module named 'gtwrap'
make[2]: *** [matlab/CMakeFiles/gtsam_matlab_wrapper.dir/build.make:75: wrap/gtsam/gtsam_wrapper.cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:31784: matlab/CMakeFiles/gtsam_matlab_wrapper.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Prior to the MATLAB cmake call these cmake/make steps have already been run, mostly without incident (test_Cal3Fisheye.py failed but didn't seem relevant)

mkdir build; cd build; cmake ..; make check; sudo make install cmake .. -DGTSAM_BUILD_PYTHON=1; make; sudo make python-install; make python-test

Any suggestions would be appreciated!
Thanks,
Eric

Reply all
Reply to author
Forward
0 new messages