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

Mongoose: Define MONGOOSE_BUILDING when building objects for .mex #839

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

mmuetzel
Copy link
Contributor

@mmuetzel mmuetzel commented Jun 13, 2024

.mex files are basically shared libraries that are loaded by Matlab.

Define MONGOOSE_BUILDING while building the object files for the .mex file.

@DrTimothyAldenDavis: Does that fix the build issues of Mongoose in Matlab on Windows?

This reverts commit 9280868.
`.mex` files are basically shared libraries that are loaded by Matlab.
Define `MONGOOSE_BUILDING` while building the object files for the
`.mex` file.
@DrTimothyAldenDavis
Copy link
Owner

Here's the errors I see with the orignal, along with verbose mode turned on:

MEX completed successfully.
.Verbose mode is on.
... Looking for compiler 'Microsoft Visual C++ 2019' ...
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2019\Community').
... Executing command 'set "vcroot=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"&for /f "delims= " %a in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"') do @if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe" call echo %vcroot%' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2019\Community').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...Yes ('C:\Program Files (x86)\Windows Kits\10\').
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2019\Community').
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2019\Community').
... Executing command 'set "vcroot=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"&for /f "delims= " %a in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"') do @if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe" call echo %vcroot%\VC\Tools\MSVC\%a' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610').
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2019\Community').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots' KitsRoot10 ...Yes ('C:\Program Files (x86)\Windows Kits\10\').
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots' KitsRoot10 ...Yes ('C:\Program Files (x86)\Windows Kits\10\').
... Executing command 'echo off&set "sdkversion="&(for /f %a IN ('dir "C:\Program Files (x86)\Windows Kits\10\include\" /b /ad-h /on') do ( @if exist "C:\Program Files (x86)\Windows Kits\10\include\%a\ucrt\" set "sdkversion=%a" ))&call echo %sdkversion%' ...Yes ('10.0.18362.0').
Found installed compiler 'Microsoft Visual C++ 2019'.
Set PATH = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\vcpackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools;C:\Program Files (x86)\Windows Kits\10\\Bin\10.0.18362.0\x64;C:\Program Files (x86)\Windows Kits\10\\Bin\10.0.18362.0\x86;C:\Program Files (x86)\Windows Kits\10\\Bin\x64;C:\Program Files (x86)\Windows Kits\10\\Bin\x86;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\davis\Documents\GitHub\GraphBLAS\build\Release;C:\Program Files\CMake\bin;C:\Program Files\MATLAB\R2023B\runtime\win64;C:\Program Files\MATLAB\R2023B\bin;C:\Users\davis\AppData\Local\Microsoft\WindowsApps;C:\Users\davis\AppData\Local\GitHubDesktop\bin;C:\Users\davis\AppData\Local\Microsoft\WindowsApps;C:\Users\davis\Documents\GitHub\GraphBLAS\GraphBLAS\build\Release;
Set INCLUDE = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\atlmfc\include;C:\Program Files (x86)\Windows Kits\10\\include\10.0.18362.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.18362.0\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.18362.0\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.18362.0\winrt;C:\Program Files\MATLAB\R2023B\extern\include;
Set LIB = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\atlmfc\lib\x64;C:\Program Files (x86)\Windows Kits\10\\Lib\10.0.18362.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.18362.0\um\x64;C:\Program Files\MATLAB\R2023B\lib\win64;
Set LIBPATH = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\atlmfc\lib\x64;
Options file details
-------------------------------------------------------------------
	Compiler location: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\
	Options file: C:\Program Files\MATLAB\R2023B\bin\win64\mexopts\msvcpp2019.xml
	CMDLINE100 : cl /c /Zc:__cplusplus /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DNTIMER  /D_FILE_OFFSET_BITS=64  /D_LARGEFILE64_SOURCE  /DGP_MEX_FUNCTION  /DMX_COMPAT_64  /DMATLAB_DEFAULT_RELEASE=R2017b  /DUSE_MEX_CMD   /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0   /DMATLAB_MEX_FILE -I"." -I"..\Include" -I"..\External\Include" -I"..\..\SuiteSparse_config"  -I"C:\Program Files\MATLAB\R2023B\extern\include" -I"C:\Program Files\MATLAB\R2023B\simulink\include" "C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp" /FoMongoose_Logger.obj
	CMDLINE200 : link /nologo /manifest  /DLL  /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion Mongoose_Logger.obj  /LIBPATH:"C:\Program Files\MATLAB\R2023B\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib /out:Mongoose_Logger.mexw64
	CMDLINE250 : mt -outputresource:Mongoose_Logger.mexw64;2 -manifest "Mongoose_Logger.mexw64.manifest"
	CMDLINE300 : del "Mongoose_Logger.exp" "Mongoose_Logger.lib" "Mongoose_Logger.mexw64.manifest" "Mongoose_Logger.ilk"
	COMPILER : cl
	COMPFLAGS : /Zc:__cplusplus /Zp8 /GR /W3 /EHs /nologo /MD
	COMPDEFINES : /DNTIMER  /D_FILE_OFFSET_BITS=64  /D_LARGEFILE64_SOURCE  /DGP_MEX_FUNCTION  /DMX_COMPAT_64  /DMATLAB_DEFAULT_RELEASE=R2017b  /DUSE_MEX_CMD   /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0   /DMATLAB_MEX_FILE
	MATLABMEX :  /DMATLAB_MEX_FILE
	OPTIMFLAGS : /O2 /Oy- /DNDEBUG
	INCLUDE : -I"." -I"..\Include" -I"..\External\Include" -I"..\..\SuiteSparse_config"  -I"C:\Program Files\MATLAB\R2023B\extern\include" -I"C:\Program Files\MATLAB\R2023B\simulink\include"
	DEBUGFLAGS : /Z7
	LINKER : link
	LINKFLAGS : /nologo /manifest 
	LINKTYPE : /DLL
	LINKEXPORT : /EXPORT:mexFunction
	LINKEXPORTVER : /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion
	LINKLIBS : /LIBPATH:"C:\Program Files\MATLAB\R2023B\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib
	LINKDEBUGFLAGS : /debug /PDB:"Mongoose_Logger.mexw64.pdb"
	LINKOPTIMFLAGS : 
	OBJEXT : .obj
	LDEXT : .mexw64
	SETENV : set COMPILER=cl
                set COMPFLAGS=/c /Zc:__cplusplus /Zp8 /GR /W3 /EHs /nologo /MD /DNTIMER  /D_FILE_OFFSET_BITS=64  /D_LARGEFILE64_SOURCE  /DGP_MEX_FUNCTION  /DMX_COMPAT_64  /DMATLAB_DEFAULT_RELEASE=R2017b  /DUSE_MEX_CMD   /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0   /DMATLAB_MEX_FILE  /DMATLAB_MEX_FILE
                set OPTIMFLAGS=/O2 /Oy- /DNDEBUG
                set DEBUGFLAGS=/Z7
                set LINKER=link
                set LINKFLAGS=/nologo /manifest  /export:%ENTRYPOINT% /DLL /LIBPATH:"C:\Program Files\MATLAB\R2023B\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib /EXPORT:mexFunction
                set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%.mexw64.pdb"
                set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
	VCROOT : C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
	SDKROOT : C:\Program Files (x86)\Windows Kits\10\
	VSINSTALLDIR : C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
	VCINSTALLDIR : C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610
	VCVARSALLDIR : C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build
	KITSROOT : C:\Program Files (x86)\Windows Kits\10\
	SDKVERSION : 10.0.18362.0
	MATLABROOT : C:\Program Files\MATLAB\R2023B
	ARCH : win64
	SRC : "C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp"
	OBJ : Mongoose_Logger.obj
	OBJS : Mongoose_Logger.obj 
	SRCROOT : C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger
	DEF : C:\Users\davis\AppData\Local\Temp\mex_1524258583620099_3888\Mongoose_Logger.def
	EXP : "Mongoose_Logger.exp"
	LIB : "Mongoose_Logger.lib"
	EXE : Mongoose_Logger.mexw64
	ILK : "Mongoose_Logger.ilk"
	MANIFEST : "Mongoose_Logger.mexw64.manifest"
	TEMPNAME : Mongoose_Logger
	EXEDIR : 
	EXENAME : Mongoose_Logger
	COPTIMFLAGS : -O3 -fwrapv -std=c++11
	OPTIM : /O2 /Oy- /DNDEBUG
	LINKOPTIM : 
-------------------------------------------------------------------
Building with 'Microsoft Visual C++ 2019'.
cl /c /Zc:__cplusplus /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DNTIMER  /D_FILE_OFFSET_BITS=64  /D_LARGEFILE64_SOURCE  /DGP_MEX_FUNCTION  /DMX_COMPAT_64  /DMATLAB_DEFAULT_RELEASE=R2017b  /DUSE_MEX_CMD   /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0   /DMATLAB_MEX_FILE -I"." -I"..\Include" -I"..\External\Include" -I"..\..\SuiteSparse_config"  -I"C:\Program Files\MATLAB\R2023B\extern\include" -I"C:\Program Files\MATLAB\R2023B\simulink\include" "C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp" /FoMongoose_Logger.obj
Error using mex
Mongoose_Logger.cpp
C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp(30): warning C4273: 'debugLevel': inconsistent dll linkage
..\Include\Mongoose_Logger.hpp(106): note: see previous definition of 'private: static int Mongoose::Logger::debugLevel'
C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp(30): error C2491: 'Mongoose::Logger::debugLevel': definition of dllimport static data member not allowed
C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp(31): warning C4273: 'timingOn': inconsistent dll linkage
..\Include\Mongoose_Logger.hpp(107): note: see previous definition of 'private: static bool Mongoose::Logger::timingOn'
C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp(31): error C2491: 'Mongoose::Logger::timingOn': definition of dllimport static data member not allowed
C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp(32): warning C4273: 'clocks': inconsistent dll linkage
..\Include\Mongoose_Logger.hpp(108): note: see previous definition of 'private: static double * Mongoose::Logger::clocks'
C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp(32): error C2491: 'Mongoose::Logger::clocks': definition of dllimport static data member not allowed
C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp(33): warning C4273: 'times': inconsistent dll linkage
..\Include\Mongoose_Logger.hpp(109): note: see previous definition of 'private: static float * Mongoose::Logger::times'
C:\Users\davis\Documents\GitHub\SuiteSparse\Mongoose\Source\Mongoose_Logger.cpp(33): error C2491: 'Mongoose::Logger::times': definition of dllimport static data member not allowed

@DrTimothyAldenDavis
Copy link
Owner

Yes, this works, and it's a better solution than mine. I'll merge it in -- thanks!

@DrTimothyAldenDavis DrTimothyAldenDavis merged commit 2cc9665 into DrTimothyAldenDavis:dev2 Jun 13, 2024
27 checks passed
@mmuetzel
Copy link
Contributor Author

Thank you for the error message.

dllimport doesn't combine with defining a static data member. That must be a dllexport attribute instead.

This PR should fix that.

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

Successfully merging this pull request may close these issues.

2 participants