MEX build issue on Windows #734
Replies: 3 comments
-
Hi @fkg-ctsi, it looks very much like the script is trying to link with the JSBSim DLL although the static library has been built. This should be fixed by providing the flag diff --git a/matlab/JSBSimSimulinkCompile.m b/matlab/JSBSimSimulinkCompile.m
index e8004d90..61274dd5 100644
--- a/matlab/JSBSimSimulinkCompile.m
+++ b/matlab/JSBSimSimulinkCompile.m
@@ -1,8 +1,8 @@
disp('Compiling S-function from JSBSim...');
% For Linux:
-mex -v -R2017b CXXFLAGS='$CXXFLAGS -std=c++14' ./matlab/JSBSim_SFunction.cpp ./matlab/JSBSimInterface.cpp -I./src -L./src/.libs -lJSBSim
+%mex -v -R2017b CXXFLAGS='$CXXFLAGS -std=c++14' ./matlab/JSBSim_SFunction.cpp ./matlab/JSBSimInterface.cpp -I./src -L./src/.libs -lJSBSim
% For Windows:
-%mex -v -R2017b COMPFLAGS='$COMPFLAGS' ./matlab/JSBSim_SFunction.cpp ./matlab/JSBSimInterface.cpp -I".\out\install\x64-Release\include\JSBSim" -L".\out\install\x64-Release\lib" -lJSBSim wsock32.lib ws2_32.lib
+mex -v -R2017b COMPFLAGS='$COMPFLAGS /DJSBSIM_STATIC_LINK' ./matlab/JSBSim_SFunction.cpp ./matlab/JSBSimInterface.cpp -I".\out\install\x64-Release\include\JSBSim" -L".\out\install\x64-Release\lib" -lJSBSim wsock32.lib ws2_32.lib
% For MacOS:
%mex -v -R2017b CXXFLAGS='$CXXFLAGS -std=c++14' ./JSBSim_SFunction.cpp ./JSBSimInterface.cpp -I../src -L../build/src -lJSBSim
disp('Finished.') |
Beta Was this translation helpful? Give feedback.
-
@bcoconni got it running! Thank you so much! |
Beta Was this translation helpful? Give feedback.
-
Thanks for reporting the issue. I have created the PR #735 to fix the problem. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there!
Firstly, thank you so much for all of the continued development and support over the years. This project has really helped make this industry more accessible!
I have a (likely) noob question re: compiling the S-Function using MEX.
I've been following the guide, and when I get to the step to compile with mex, I get a large link error dump.
Here is a snippet:
Error using mex Creating library JSBSim_SFunction.lib and object JSBSim_SFunction.exp LINK : warning LNK4217: symbol '??0SGPath@@QEAA@P6A?AUPermissions@0@AEBV0@@Z@Z (public: __cdecl SGPath::SGPath(struct SGPath::Permissions (__cdecl*)(class SGPath const &)))' defined in 'JSBSim.lib(sg_path.obj)' is imported by 'JSBSim_SFunction.obj' in function '"void __cdecl mdlInitializeConditions(struct SimStruct_tag *)" (?mdlInitializeConditions@@YAXPEAUSimStruct_tag@@@Z)'
...
...
JSBSim_SFunction.mexw64 : fatal error LNK1120: 13 unresolved externals
For reference, I am using VS Community 2019, and Matlab/Simulink 2022b (Really hoping that this isn't the issue)
Admittedly, I am a MEX noob and only functional in C++, but would really appreciate a nudge in where to start investigating a path forwards.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions