-
Notifications
You must be signed in to change notification settings - Fork 473
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
Mingw enhancement #548
Mingw enhancement #548
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -104,6 +104,42 @@ From Visual Studio, you can open the project file `JSBSim.vcxproj` to open a pro | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For more detailed instructions on using Visual Studio project files and CMake via Visual Studio to build JSBSim take a look at the following documentation link - [Building using Visual Studio](https://jsbsim-team.github.io/jsbsim-reference-manual/mypages/quickstart-building-using-visualstudio/). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
### Building with MinGW toolset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
With the help of cmake, you can build JSBSim under Windows using MinGW toolset. The whole configuration and building command is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
as simple as that in unix bash: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> cd jsbsim-code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> mkdir build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> cd build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> cmake .. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> mingw32-make | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#### Building python module with MinGW toolset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If cython executable is installed in your PATH enviroment or provided to cmake command, the python module will be built as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Usually, there is nothing special with MinGW toolset. But if you get `cannot find -lmsvcrt140`, you may need to modify your cygwinccompiler.py, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
which is in distutils folder (In anaconda, it should be `Anaconda3\lib\distutils\cygwinccompiler.py`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
```python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
elif int(msc_ver) >= 1900: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# VS2015 / MSVC 14.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# return ['msvcr140'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return ['vcruntime140'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
And then copy `vcruntime140.dll` to `/path/to/mingw-w64/lib`. This problem is due to msvc runtime library naming convention broken after VS2015. See [here](https://stackoverflow.com/questions/52943590/cython-missing-msvcr140-dll). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+120
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Requesting the user to perform manual modifications to their Python installation is not our way to handle platform specific cases. Actually, we are going to great length to avoid this and instead we are automatically handling such situations by overloading Lines 78 to 106 in d9df845
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#### Building matlab mex file with MinGW toolset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To compile matlab mex file, gcc major version needs to be greater than 8 to support c++14 language features. The official matlab support MinGW-w64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version is 6.3, so you have to set your own MinGW toolset environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Download a newer MinGW-w64 toolset in your local machine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Set `MW_MINGW64_LOC` environment variable in your local machine or in matlab command shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Run matlab command `mex -setup` to set up toolset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
After setting up your Mingw-w64 toolset in matlab, you can build the JSBSim mex file running `JSBSimSimulinkCompile.m`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
## Testing JSBSim | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JSBSim comes with a test suite to automatically check that the build is correct. This test suite is located in the `tests` directory and is coded in Python so you need to [build the Python module of JSBSim](#building-the-python-module-of-jsbsim) first. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,9 @@ compiler = new_compiler(compiler=compiler_name) | |
if compiler.compiler_type == 'unix': | ||
cpp_compile_flags = ['-std=c++11'] | ||
cpp_link_flags = [] | ||
elif compiler.compiler_type == 'mingw32': | ||
cpp_compile_flags = ['-std=c++11', '-D_hypot=hypot'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May I ask why you are requesting the flag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your review. I use this macro as I close this PR for the moment. My branch will be working in progress for better MinGW compability support, to pass the CI python module building. If any new findings, I will be back here.:grin: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha OK, I did not think to check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And we'll be more than happy to provide you some help so do not hesitate to re-open this PR if you need some support. |
||
cpp_link_flags = [] | ||
elif compiler.compiler_type == 'msvc': | ||
# These flags are equivalent to a RelWithDebInfo configuration. | ||
# Since the module fpectl is not supposed to be used in production, these | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,10 @@ if compiler.compiler_type == 'unix': | |
cpp_compile_flag = ['-std=c++14'] | ||
cpp_link_flags = [] | ||
link_libraries = [${JSBSIM_LINK_LIBRARIES}] | ||
elif compiler.compiler_type == 'mingw32': | ||
cpp_compile_flag = ['-std=c++14', '-D_hypot=hypot'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: why are you requesting the flag |
||
cpp_link_flags = ['-Wl,-Bstatic'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of this linker flags ? |
||
link_libraries = ['wsock32', 'ws2_32'] | ||
elif compiler.compiler_type == 'msvc': | ||
if args.config in ('Debug', 'RelWithDebInfo'): | ||
# These flags are equivalent to a RelWithDebInfo configuration. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find this code in Python official
distutils
: https://github.com/python/cpython/blob/576e38f9db61ca09ca6dc57ad13b02a7bf9d370a/Lib/distutils/cygwinccompiler.py#L61 so I am a bit skeptical that a user can follow successfully the steps you are describing ?