Skip to content

gcc.cpp.exe and gcc.cpp.linker not set when crosscompiling with mingw #13284

@corenting

Description

@corenting

When crosscompiling a project with using C++ interop (with importcpp) on Linux (targeting Windows with mingw), nim uses the wrong compiler (g++ instead of x86_64-w64-mingw32-g++).

The compilation then fails due to various import errors (missing Windows headers...)

Example

nimble --accept -d:mingw --cpu:amd64  -o:$(TARGET_NAME).exe cpp $(MAIN_SOURCE)

Output

Error: execution of an external compiler program '/usr/bin/g++ -c [...]

Possible Solution

By replacing my command with :

nimble --accept -d:mingw --cpu:amd64 --gcc.cpp.exe=x86_64-w64-mingw32-g++ --gcc.cpp.linkerexe=x86_64-w64-mingw32-g++ -o:$(TARGET_NAME).exe cpp $(MAIN_SOURCE)

the compilation works.

Additional Information

  • I used choosenim to install nim, and I use nimble for my project
  • My version :
$ nim -v
Nim Compiler Version 1.0.6 [Linux: amd64]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions