Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matlab 2017b - Ubuntu 18.04 - Tutorial fails #270

Closed
NicolasRiel opened this issue May 3, 2019 · 8 comments
Closed

Matlab 2017b - Ubuntu 18.04 - Tutorial fails #270

NicolasRiel opened this issue May 3, 2019 · 8 comments

Comments

@NicolasRiel
Copy link

Hi everyone,

I was able to install NLopt with matlab 2017b using this command:

sudo cmake .. -DMatlab_ROOT_DIR=/home/seph/MATLAB/R2017b/

However, when I try to run the example from the tutorial I get the following error message.

I was wondering if anyone had an idea on how to fix it?

Cheers!

_Invalid MEX-file '/home/seph/MATLAB/R2017b/bin/nlopt_optimize.mexa64':
Missing symbol '_ZNSt13runtime_errorC1EPKc' required by '/usr/local/lib/libnlopt.so.0->/home/seph/MATLAB/R2017b/bin/nlopt_optimize.mexa64'
Missing symbol '_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' required by
'/usr/local/lib/libnlopt.so.0->/home/seph/MATLAB/R2017b/bin/nlopt_optimize.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm' required by
'/usr/local/lib/libnlopt.so.0->/home/seph/MATLAB/R2017b/bin/nlopt_optimize.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructEmc' required by
'/usr/local/lib/libnlopt.so.0->/home/seph/MATLAB/R2017b/bin/nlopt_optimize.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm' required by
'/usr/local/lib/libnlopt.so.0->/home/seph/MATLAB/R2017b/bin/nlopt_optimize.mexa64'
Missing symbol 'ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm' required by
'/usr/local/lib/libnlopt.so.0->/home/seph/MATLAB/R2017b/bin/nlopt_optimize.mexa64'.

Here is the config log:

-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- NLopt version 2.6.1
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for getopt.h
-- Looking for getopt.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for time.h
-- Looking for time.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for getpid
-- Looking for getpid - found
-- Looking for syscall
-- Looking for syscall - found
-- Looking for isinf
-- Looking for isinf - found
-- Looking for isnan
-- Looking for isnan - found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Looking for qsort_r
-- Looking for qsort_r - found
-- Looking for time
-- Looking for time - found
-- Looking for copysign
-- Looking for copysign - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of uint32_t
-- Check size of uint32_t - done
-- Check size of unsigned int
-- Check size of unsigned int - done
-- Check size of unsigned long
-- Check size of unsigned long - done
-- Looking for sqrt in m
-- Looking for sqrt in m - found
-- Looking for fpclassify
-- Looking for fpclassify - TRUE
-- Performing Test HAVE_THREAD_LOCAL_STORAGE
-- Performing Test HAVE_THREAD_LOCAL_STORAGE - Success
-- Performing Test HAVE_THREAD_LOCAL_STORAGE
-- Performing Test HAVE_THREAD_LOCAL_STORAGE - Failed
-- Looking for __cplusplus
-- Looking for __cplusplus - found
-- Performing Test SUPPORTS_STDCXX11
-- Performing Test SUPPORTS_STDCXX11 - Success
-- Found PythonInterp: /usr/bin/python (found version "2.7.15")
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
-- Could NOT find Guile (missing: GUILE_EXECUTABLE GUILE_ROOT_DIR GUILE_INCLUDE_DIRS GUILE_LIBRARIES)
-- Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
-- Could NOT find Octave (missing: OCTAVE_EXECUTABLE OCTAVE_ROOT_DIR OCTAVE_LIBRARIES)
-- Found Matlab: /home/seph/MATLAB/R2017b/extern/include (found version "9.3") found components: MX_LIBRARY
-- Performing Test HAS_MINUS_PTHREAD
-- Performing Test HAS_MINUS_PTHREAD - Success
-- Configuring done
-- Generating done

@jschueller
Copy link
Collaborator

jschueller commented May 3, 2019

maybe it's missing linking to libstdc++, and I dont remember if matlab extension is using c++, can you delete everything and post the full log of make VERBOSE=1 ?

@stevengj
Copy link
Owner

stevengj commented May 3, 2019

After #198, libnlopt is built with C++ by default, which might be breaking the Matlab plugin because our mex file ends with .c. Try passing -DNLOPT_CXX=Off to cmake.

I don't see an option in the mex documentation to compile a .c file using C++, so we may have to rename the file to do this.

@jschueller
Copy link
Collaborator

jschueller commented May 3, 2019

Could you try adding this line after matlab_add_mex in src/octave/CMakeLists.txt (like in #271) ?
set_target_properties (nlopt_optimize-mex PROPERTIES LINKER_LANGUAGE CXX)

@NicolasRiel
Copy link
Author

Hi all, thank you for such fast answers !

As suggested by Steven, the following command when running cmake fixed my problem:
-DNLOPT_CXX=Off

Now it perfectly works !!

Thank you very much,

@jschueller
Copy link
Collaborator

Good, can you test the fix I'm proposing anyway ? That way you and others wont have to worry next time.

@NicolasRiel
Copy link
Author

Hi jschueller,

I tried your fix i.e.
set_target_properties (nlopt_optimize-mex PROPERTIES LINKER_LANGUAGE CXX)

Unfortunately it did not work :(

@jschueller
Copy link
Collaborator

could you try this line instead, BEFORE the matlab_add_mex line ? :
set_source_files_properties (nlopt_optimize-mex.c PROPERTIES CPLUSPLUS ON)

@stevengj
Copy link
Owner

stevengj commented May 8, 2019

Closed by #272.

@stevengj stevengj closed this as completed May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants