community: wt/4.0.3/stable can't be cross-compiled Linux to Windows

Description of Problem

Hi; I’m trying to cross-compile from Ubuntu 18.04 x86_64 to Windows x86_64 and setting up a profile for that. I’m following this guide but it’s trying to install msys2_installer which it shouldn’t do because I already have mingw64 gcc and g++ installed for native Ubuntu. Moreover, msys2_installer appears to only run on a Windows host.

ERROR: /home/c9/.conan/data/msys2_installer/20161025/bincrafters/stable/export/conanfile.py: Error while initializing settings. Invalid setting 'Linux' is not a valid 'settings.os_build' value.
Possible values are ['Windows']
Read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-invalid-setting"

Package Details

  • Package Name/Version: wt/4.0.3
  • Operating System: Linux Ubuntu 18.04
  • Compiler+version:
$ /usr/bin/x86_64-w64-mingw32-gcc-win32 --version
x86_64-w64-mingw32-gcc-win32 (GCC) 7.3-win32 20180312

Steps to reproduce

conanfile.txt:

[requires]
wt/4.0.3@bincrafters/stable
[generators]
cmake

l2w.profile:

[env]
CC=/usr/bin/x86_64-w64-mingw32-gcc-7.3-win32
CXX=/usr/bin/x86_64-w64-mingw32-g++-win32

[settings]
os_build=Linux
arch_build=x86_64

# We are cross building to Windows
os=Windows
arch=x86_64
compiler=gcc
compiler.version=7.3
compiler.libcxx=libstdc++11
build_type=Release

conan_build.sh:

#!/bin/bash
mkdir -p wbuild
pushd wbuild >& /dev/null
conan install --build missing --profile ../l2w.profile ..
popd >& /dev/null

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 32 (16 by maintainers)

Most upvoted comments

IN SUMMARY

Cross-compiling from Ubuntu 18.04 to Windows using MinGW64 is possible without modifying the Wt sources using the current Conan package versions and MinGW64 7.3.0 if you do the following:

sudo ln -s /usr/x86_64-w64-mingw32/include/windows.h /usr/x86_64-w64-mingw32/include/Windows.h
sudo ln -s /usr/x86_64-w64-mingw32/include/shlobj.h /usr/x86_64-w64-mingw32/include/ShlObj.h

Then reference the relevant files from https://github.com/allquixotic/conanpatcher-server

  • cmc: script for the conan package dependencies for MinGW64 (others with similar name: c for Linux, mc for MacOS)
  • cmz: script for building the code I wrote for MinGW64 (others with similar name: z for Linux, mz for MacOS)
  • conanfile.txt: I disabled wttest and wtisapi modules with options.
  • l2w.profile: A cross-compile profile provided by, I think it was memshared or you, in another issue.
  • CMakeLists.txt: Had to add -lwsock32 to link libraries by setting target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS} wsock32) (oh, shoot, I just realized this won’t work for non-Windows platforms 😄)

To successfully run the executable on Windows, you must copy files from your MinGW installation to your Windows box:

  • /usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/*.dll
  • /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll

And then:

PS C:\Users\Sean\Documents\conanpatcher-server-test> .\conanpatcher-server.exe --docroot docroot --http-listen 127.0.0.1
:8085 --accesslog log.txt --config wt_config.xml --pid-file pidfile.pid
Option no-compression is implied because wthttp was built without zlib support.
[2018-Aug-05 12:19:23.612] 10296 - [info] "config: reading Wt config file: wt_config.xml (location = 'C:\Users\Sean\Documents\conanpatcher-server-test\conanpatcher-server.exe')"
Option no-compression is implied because wthttp was built without zlib support.
[2018-Aug-05 12:19:23.615] 10296 - [info] "Auth.GoogleService: not configured: OAuth: no 'google-oauth2-redirect-endpoint' property configured"
[2018-Aug-05 12:19:23.615] 10296 - [info] "Auth.FacebookService: not configured: OAuth: no 'facebook-oauth2-redirect-endpoint' property configured"
[2018-Aug-05 12:19:23.615] 10296 - [info] "WServer/wthttp: initializing built-in wthttpd"
INFO: Opened log file (log.txt).
[2018-Aug-05 12:19:23.616] 10296 - [info] "wthttp: started server: http://127.0.0.1:8085"

And when accessing the app via browser, IT WORKS!

🎉 🎈 🎉 🎈 🎉 🎈 🎉 🎈 🎉 🎈 🎉 🎈

@SSE4 Thank you so much for all your help with this, I really, really appreciate it. The bincrafters community is fantastic!

wsock32 probably has to be added to recipe’s package_info method, I’ll add this tomorrow

@allquixotic great job! would you write PRs against wt repository?

Looks like you already found the issue with boost_system 😃 This bug is fun; it’s finding bugs in just about every package, hehe.

unfortunately, for me it failed earlier:

[ 90%] Building C object CMakeFiles/bzip2.dir/bzip2.c.obj
/home/conan/.conan/data/bzip2/1.0.6/conan/stable/build/d83fceb52c7a0f772a20ccfcae71925aa5fcdf1a/bzip2-1.0.6/bzip2.c:131:13: fatal error: sys\stat.h: No such file or directory
 #   include <sys\stat.h>
             ^~~~~~~~~~~~

but it seems like I’ve found package which includes msys2_installer, it’s lzma, I’ll rebuild it and let you know.