1

I have a Cmake/wxWidgets project that builds fine on my pc. I compile wxWidgets using nmake /f makefile.vc BUILD=release TARGET_CPU=X86 and generate the CMake project using cmake .. -G "Visual Studio 16 2019" -A Win32 -DCMAKE_CONFIGURATION_TYPES=Release.

Like I wrote, this compiles fine on my pc. When I want to build it using a github action on Windows 2019 Image I first pull wxWidgets, compile it using the above statement, generate wxWidgets using the aboce statement and trigger the build using a cmd-script containing "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" ".\build\NaCl-Configurator.sln" /p:Configuration=Release /p:Platform=Win32 /p:PlatformTarget=x86

But when doing this I always get the following error:

  wxmsw31u_core.lib(corelib_wincmn.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86' [D:\a\abc\abc\build\abc.vcxproj]

If I switch everything to x64 it compiles fine, but I need a x86 build. Is there any system setting I'm missing?

7
  • You might need to setup the Visual Studio environment by calling vcvarsall.bat x86 before running your msbuild command. Commented Nov 9, 2020 at 7:14
  • @vre thanks for your hint - didin't help. before this I had already tried "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat" with no success, too Commented Nov 9, 2020 at 10:05
  • I'm confused are you using visual studio to build your project on a server? Commented Nov 9, 2020 at 10:55
  • @hdf89shfdfs i'm developing on my pc but i want every version (not every commit) to be build on a github action. linux build is no problem at all and the github actions offer a windows 2019 server with vs enterprise pre installed to compile projects. here is an overview Commented Nov 9, 2020 at 10:59
  • 1
    wxWidgets repository states here "to build a 32 bit release DLL version from an x86 command prompt," Did you do that, e.g. did you called vcvarsall.bat x86 before running nmake ...? Commented Nov 9, 2020 at 12:14

2 Answers 2

2

I was using another github action to access nmake to build wxWidgets. Within this action I had to specify the architecture. So using

      - name: Preparing nmake    
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: x86
      - name: start building wx widgtes
        run: |
          cd ${{ env.WXWIN }}${{ env.wxMSW_VER }}\build\msw
          nmake /f makefile.vc BUILD=release TARGET_CPU=X86

and then going on did the trick. It was only the with: arch: x86 that was missing

Sign up to request clarification or add additional context in comments.

1 Comment

@cpp_guy_who_does_gfx i will. but the system allows me to accept my own answer only the next day ;-)
1

This is not an answer, this is a recommendation.

But after spending hours looking into your issue, I am seriously pulling my hair at the Microsoft documentation for MSBuild.

Just use Ninja. This is what we use to build our x64/x86 binaries.

You might need to learn a little bit about cmake toolchains, but at least you don't have to deal with this msbuild nonsense.

Ninja is faster, works much better with cmake, is a very tiny executable, etc.

Seriously using msbuild/visual-studio on your servers isn't worth it.

Again I apologize this isn't a direct answer to your question, if you do continue down this path I'm curious to see the answer.

====================================================

What I found out though:

I will say I'm very confused about the difference between PlatformTarget and Platform. Because all the visual studio solutions I generate don't even have PlatformTarget as a property anywhere. I scanned the generated solution files and didn't see this anywhere. Granted I'm using vs2019 so maybe it's deprecated I dunno.

Prefer to expand the /p -> /property that's just good practice for your build server scripts.

Perhaps try using the platform property "x86" instead. I literally couldn't find concrete information on which was preferred/correct. Win32/x86.

And as a final guess please start printing out your compiler, and toolchain information from cmake.

Resources:

How do I specify the platform for MSBuild?

https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-target-framework-and-target-platform?view=vs-2019

Me looking at the msbuild command line, and looking at my generated visual studio solutions.

1 Comment

thanks for your effort! If I specify a target within the cmake command either x64 or Win32 target is generated in the vs project file, even for vs 2019. As you can see my problem is solved, but I will have a look at Ninja.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.