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?

  • You might need to setup the Visual Studio environment by calling `vcvarsall.bat x86` before running your msbuild command. – vre Nov 09 '20 at 07: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 – quotschmacher Nov 09 '20 at 10:05
  • I'm confused are you using visual studio to build your project on a server? –  Nov 09 '20 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](https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources) is an overview – quotschmacher Nov 09 '20 at 10:59
  • 1
    wxWidgets repository states [here](https://github.com/wxWidgets/wxWidgets/blob/master/docs/msw/install.md) "*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 ...`? – vre Nov 09 '20 at 12:14
  • its an accessory sentence!!!!! that's it! thanks. – quotschmacher Nov 09 '20 at 13:08
  • @quotschmacher, just get rid of CMake and use provided Makefiles for building wxWidgets and then look at the `minimal` sample Makefile to how to build your own code. Using 3rd party tool on top of what wxWidgets provides will screw you over. – Igor Nov 09 '20 at 16:24

2 Answers2

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

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.

  • 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. – quotschmacher Nov 09 '20 at 13:13