Skip to content

Cmake called from pysimlink.Model() fails to find nmake. #23

Description

@JGPrior

The Issue
I am currently having some issues getting the compiler in PySimlink to work. Namely, when I run the Model initialisation, I receive the following Generation Error:

CMake Error at CMakeLists.txt:2 (project):
Running

'nmake' '-?'

failed with:

no such file or directory

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

I have seen a closed issue that looks similar to mine, however it seems the original poster did not respond to clarifying questions. Hopefully I can provide more details to solve the issue this time.

System Set-Up
I am running Python 3.11.7 from within a conda environment, into which I have installed PySimlink via pip.

Per Windows instruction in the docs I have checked my installation of Visual Studio 2019 and confirmed inclusion of “Desktop Development with C++”. I have also checked using the VS developer command prompt that nmake can be found, including the version number:

nmake_version

I can confirm that nmake exists in the usual folder, which for my system is:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64

My Simulink model is named PySimTest.slx and is very simple in its structure (just a clock, sum block, a sine function, and a constant block). With MATLAB R2024b as my local version I have performed code generation exactly according to the instructions in the PySimlink docs. This has generated a zip folder with the following structure:

(top folder name)
     |
     |--pySimTest.zip
        |
	|--2024b
	|    |--extern
	|    |--rtw
	|    |--simulink
	|
	|--(top folder name)
             |--pySimTest_grt_ftw

Attempted Resolutions:
When looking for similar error codes online I stumbled on this stackoverflow thread:

(https://stackoverflow.com/questions/69338088/error-while-configuring-cmake-project-running-nmake-failed),

in which a recommended resolution to not being able to locate nmake is simply to use another generator, namely MinGW Makefiles.

I am aware that pysimlink.Model() has a named argument that allows you to modify which generator is used, but the API documentation doesn’t point to a listed of supported values (apologies if this is in fact the case and I have simply missed it). I tried looking through the code for the Model class definition and found that “NMake Makefiles” is the default value for Windows, but haven’t gone further than that.

I have passed generator= “MinGW Makefiles” as a last-ditch attempt but simply received an error stating that cmake couldn’t find it as a valid build tool:

CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.

I am guessing that this is just because I don’t have mingw installed, and not because it’s an invalid command? I noticed in the Pysimlink docs that the following is stated:

“While mingw is a valid compiler on Windows, it’s much simpler to use the Visual Studio tools”

.As such I’d like to try and resolve this issue using nmake if possible, as I want my own application to be as easy as possible to set up across multiple devices.

I have tried adding the folder containing nmake to the system path in my Python session but it has had no impact on the error file produced when I try and compile the Simulink model.

Other Notes
The Generation Error .txt file I received also has a warning included about deprecated functionality that will be removed in future versions of Cmake:

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.

Update the VERSION argument value. Or, use the ... syntax
to tell CMake that the project requires at least but has been updated
to work with policies introduced by or earlier.

Given how common this kind of warning is I have not attempted to address it as part of the previously mentioned error, but thought it worth mentioning regardless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions