View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015786 | CMake | Modules | public | 2015-10-13 07:32 | 2016-03-07 09:12 | ||||
Reporter | Kerstin Keller | ||||||||
Assigned To | |||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | no change required | ||||||
Platform | Win64 | OS | Windows | OS Version | 7 | ||||
Product Version | CMake 3.3.2 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0015786: FindMatlab / matlab_add_mex does not work with 64-bit Matlab Version - Version detected as 32-bit Matlab | ||||||||
Description | I have installed a 64bit Matlab Version (2015a) and CMake 3.3.2. When writing a simple CMakeLists.txt script cmake_minimum_required(VERSION 3.3) project(easy_example) find_package(MATLAB REQUIRED) include_directories(Matlab_INCLUDE_DIRS) matlab_add_mex( NAME easy_example SRC easy_example.cpp ) It cannot find the mex library. The Output is -- Could NOT find Matlab (missing: Matlab_MEX_LIBRARY) (found version "8.5") CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: Matlab_MEX_LIBRARY linked by target "easy_example" in directory D:/SourceCode/Matlab/easy_example -- Configuring incomplete, errors occurred! | ||||||||
Steps To Reproduce | Try to run find_package(MATLAB REQUIRED) and then use matlab_add_mex( ... ) with a 64-bit Matlab Version. | ||||||||
Additional Information | Digging a little into the FindMatlab.cmake script, and outputted the directories where it searches for the directories (l.1342). message(STATUS "The include dir ${MATLAB_INCLUDE_DIR_TO_LOOK}") message(STATUS "The library dir ${_matlab_lib_dir_for_search}") This gives me the following Output -- The include dir C:/LegacyApp/Matlab15a/R2015a_64bit/extern/include -- The library dir C:/LegacyApp/Matlab15a/R2015a_64bit/extern/lib/win32/microsoft However, as my Matlab Version is 64bit, it library dir should be C:/LegacyApp/Matlab15a/R2015a_64bit/extern/lib/win64/microsoft This can be traced back to line 1276, where I added another message Output: if(_matlab_64Build) set(_matlab_current_suffix ${_matlab_bin_suffix_64bits}) message(STATUS "64bit Matlab") else() set(_matlab_current_suffix ${_matlab_bin_suffix_32bits}) message(STATUS "32bit Matlab") endif() CMake falsely detects a 32bit Matlab Version -- 32bit Matlab | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0039583) Raffi Enficiaud (developer) 2015-10-13 07:49 |
Hi, It will look for the 64 bits version only if you use a 64bit toolchain. What is your initial cmake command? |
(0039584) Kerstin Keller (reporter) 2015-10-13 07:59 |
Ok, so this isn't really a bug, more a wrong invokation: I invoked CMake only with cmake . -B_build -G "Visual Studio 11 2012" instead of cmake . -B_build -G "Visual Studio 11 2012 Win64" Of course a Win32 build will look for a Win32 Matlab Version. However instead of saying Could NOT find Matlab, the FindMatlab.cmake Script could be improved to give a WARNING such as "Compiling for 32bit, but only 64bit Matlab Version is installed" |
(0039585) Raffi Enficiaud (developer) 2015-10-13 08:04 |
What do you see when you add "MATLAB_FIND_DEBUG" to your invocation/command line? |
(0039586) Kerstin Keller (reporter) 2015-10-13 08:12 |
My Output is: -- [MATLAB] Search for Matlab from the registry unsuccessful, testing all supported versions -- [MATLAB] Matlab root folders are 8.5;C:/LegacyApp/Matlab15a/R2015a_64bit -- [MATLAB] Current version is 8.5 located C:/LegacyApp/Matlab15a/R2015a_64bit -- [MATLAB] [DEBUG]_matlab_lib_prefix_for_search = lib | _matlab_lib_dir_for_search = C:/LegacyApp/M atlab15a/R2015a_64bit/extern/lib/win32/Microsoft So it makes sense, it was just unclear to me, why it specified the win32 as search Directory. I think we can close the issue, as it is clearly not a bug with the Script, only wrong usage by the user. |
(0039587) Raffi Enficiaud (developer) 2015-10-13 08:14 |
If you think the documentation might be improved, please indicate how you think this can be clarified. Thanks! |
(0039589) Kerstin Keller (reporter) 2015-10-13 09:07 edited on: 2015-10-13 09:09 |
Ok, so if Matlab was found (Matlab_FOUND is TRUE) but the mex library was not (Matlab_MEX_LIBRARY is NOT_FOUND), this is a strong indicator that compiler Version (32/64) and Matlab Version (32/64) are not compatible. In the case of 32 bit compiler / 64 bit matlab the file exists at /extern/lib/win64/Microsoft/libmex.lib, but the search path will be /extern/lib/win32/Microsoft/ and thus CMake cannot find the library and Matlab_MEX_LIBRARY is set to NOT_FOUND. In this case there could be a WARNING, "Matlab_MEX_LIBRARY NOT_FOUND: Please check if compiler Version and Matlab Version are compatible" By the way, can you Point me to any example of the usage of matlab_add_mex macro, besides the official CMake documentation? I was not able to find a single example of the usage. Even though I can now find Matlab correctly, I still get linker Errors concerning used Matlab functions, see easy_example.obj : error LNK2019: unresolved external symbol mxGetPr referenced in function "void _ _cdecl mexFunction(unsigned __int64,struct mxArray_tag * * const,unsigned __int64,struct mxArray_ta g const * * const)" (?mexFunction@@YAX_KQEAPEAUmxArray_tag@@0QEAPEBU1@@Z) [D:\SourceCode\Matlab\eCA LImporter\_build\easy_example.vcxproj] easy_example.obj : error LNK2019: unresolved external symbol mxCreateStructMatrix_730 referenced in function "void __cdecl createStructureArray(struct mxArray_tag * *)" (?createStructureArray@@YAXPE APEAUmxArray_tag@@@Z) [D:\SourceCode\Matlab\eCALImporter\_build\easy_example.vcxproj] D:\SourceCode\Matlab\eCALImporter\_build\Debug\easy_example.mexw64 : fatal error LNK1120: 2 unresol ved externals [D:\SourceCode\Matlab\eCALImporter\_build\easy_example.vcxproj] |
(0039592) Raffi Enficiaud (developer) 2015-10-13 11:26 |
You may have a look to this: https://github.com/MPI-IS/Grassmann-Averages-PCA/blob/master/CMakeLists.txt#L82-L98 [^] https://github.com/MPI-IS/Grassmann-Averages-PCA/blob/master/CMakeLists.txt#L482-L488 [^] For your suggestion about the warning, my opinion is that is could be erroneous or misleading for other use cases. Please have a look to the documentation: it looks like you are missing the MX component. https://cmake.org/cmake/help/v3.3/module/FindMatlab.html#command:matlab_add_mex [^] |
(0040614) Robert Maynard (manager) 2016-03-07 09:12 |
Closing resolved issues that have not been updated in more than 4 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2015-10-13 07:32 | Kerstin Keller | New Issue | |
2015-10-13 07:49 | Raffi Enficiaud | Note Added: 0039583 | |
2015-10-13 07:59 | Kerstin Keller | Note Added: 0039584 | |
2015-10-13 08:04 | Raffi Enficiaud | Note Added: 0039585 | |
2015-10-13 08:12 | Kerstin Keller | Note Added: 0039586 | |
2015-10-13 08:14 | Raffi Enficiaud | Note Added: 0039587 | |
2015-10-13 08:59 | Brad King | Status | new => resolved |
2015-10-13 08:59 | Brad King | Resolution | open => no change required |
2015-10-13 09:07 | Kerstin Keller | Note Added: 0039589 | |
2015-10-13 09:09 | Kerstin Keller | Note Edited: 0039589 | |
2015-10-13 11:26 | Raffi Enficiaud | Note Added: 0039592 | |
2016-03-07 09:12 | Robert Maynard | Note Added: 0040614 | |
2016-03-07 09:12 | Robert Maynard | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |