Comments (7)
Cmake often tries to enable pdb options which don't work well in wine; I usually use a custom patched cmake when building with msvc in wine. See https://gitlab.kitware.com/mstorsjo/cmake/-/commits/msvc/ for one version of such patches (haven't verified atm that it works with the current version of msvc-wine though).
from msvc-wine.
Confirmed it worked for me with CMake 3.19.4 built from source with 3 @mstorsjo patches on top of it
from msvc-wine.
@mstorsjo @dmikushin
I also encountered a strange problem with cmake, can you give me some guidance?
cmake --version
cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
cmake project :cxx_hello
cmake toolchain.cmake:
cmake_minimum_required(VERSION 3.8.0)
if(MSVC_TOOLCHAIN_HAS_RUN)
return()
endif(MSVC_TOOLCHAIN_HAS_RUN)
set(MSVC_TOOLCHAIN_HAS_RUN true)
list(APPEND _supported_archs
"x86" "x64"
"arm"
"arm64")
message(STATUS "ARCH:${ARCH}")
if(NOT DEFINED ARCH)
message(FATAL_ERROR "ARCH argument not set. Bailing configure since I don't know what target you want to build for!")
endif()
list(FIND _supported_archs ${ARCH} contains_ARCH)
if("${contains_ARCH}" EQUAL "-1")
string(REPLACE ";" "\n * " _supported_archs_formatted "${_supported_archs}")
message(FATAL_ERROR " Invalid ARCH specified! Current value: ${ARCH}.\n"
" Supported ARCH values: \n * ${_supported_archs_formatted}")
endif()
if(DEFINED MSVC_WINE_BIN_PATH)
set(ENV{_MSVC_WINE_BIN_PATH} "${MSVC_WINE_BIN_PATH}")
elseif(DEFINED ENV{_MSVC_WINE_BIN_PATH})
set(MSVC_WINE_BIN_PATH "$ENV{_MSVC_WINE_BIN_PATH}")
elseif(NOT DEFINED MSVC_WINE_BIN_PATH)
if(EXISTS "/opt/msvc/bin/")
set(MSVC_WINE_BIN_PATH "/opt/msvc/bin")
else()
message(FATAL_ERROR "can not find msvc wine bin path ")
endif()
endif ()
set(ENV{PATH} "${MSVC_WINE_BIN_PATH}/${ARCH}/:$ENV{PATH}")
message(STATUS "PATH: ${MSVC_WINE_BIN_PATH}")
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_MAKE_PROGRAM "${MSVC_WINE_BIN_PATH}/${ARCH}/nmake")
set(CMAKE_C_COMPILER "${MSVC_WINE_BIN_PATH}/${ARCH}/cl")
set(CMAKE_CXX_COMPILER "${MSVC_WINE_BIN_PATH}/${ARCH}/cl")
set(CMAKE_RC_COMPILER "${MSVC_WINE_BIN_PATH}/${ARCH}/rc")
set(CMAKE_MT "${MSVC_WINE_BIN_PATH}/${ARCH}/mt")
set(CMAKE_AR "${MSVC_WINE_BIN_PATH}/${ARCH}/lib")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
run :
wineserver -p && wine wineboot && cmake -DCMAKE_TOOLCHAIN_FILE=/worker/msvc-toolchain.cmake -DARCH=x86 ..
CMake error log:
-- ARCH:x86
-- PATH: /opt/msvc/bin
-- The CXX compiler identification is MSVC 19.29.30133.0
-- Check for working CXX compiler: /opt/msvc/bin/x86/cl
CMake Error at /worker/msvc-toolchain.cmake:16 (message):
ARCH argument not set. Bailing configure since I don't know what target
you want to build for!
Call Stack (most recent call first):
/worker/cxx-example/build/CMakeFiles/3.16.3/CMakeSystem.cmake:6 (include)
/worker/cxx-example/build/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake:37 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
CMakeLists.txt:5 (project)
-- Configuring incomplete, errors occurred!
See also "/worker/cxx-example/build/CMakeFiles/CMakeOutput.log".
The ARCH and CXX compilers were detected successfully at first, and the message (STATUS "PATH: ${MSVC_WINE_BIN_PATH}") has been printed, it seems that this toolchain.cmake has been run many times.
thanks!
best regards
from msvc-wine.
@zuowanbushiwo To use CMake with MSVC, you can't use the default "Unix Makefiles" generator. Your best bet is to use Ninja. (The other ones that work with MSVC on Windows are the Visual Studio project generator, and nmake. Using the visual studio project files via Wine probably is more tricky, the nmake generator might work but I haven't tested it. Edit: Those generators aren't available in a unix-based cmake; the only choice available that works with MSVC is ninja.)
I pushed a branch here which contains a working example of building things with CMake: https://github.com/mstorsjo/msvc-wine/commits/cmake
from msvc-wine.
@mstorsjo
thanks , my test branch cmake can be compiled successful and output bin is available,I still encountered two problems:
-
Is the following error caused by wine?
[1/2] Building CXX object CMakeFiles/hello-world.dir/hello-world.cc.obj
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
9041.0\ucrt\corecrt_wctype.h
[2/2] Linking CXX executable hello-world.exe -
Strange problem, it seems that the message(FATAL_ERROR "xx") function cannot be used?
If it looks like the following, it can compile normally.
message(STATUS "ARCH:${ARCH}")
if(DEFINED ARCH)
message(STATUS "DEFINE ARCH")
endif()
if(NOT DEFINED ARCH)
message(STATUS "NOT DEFINE ARCH")
endif()
cmake out :
-- ARCH:x86
-- DEFINE ARCH
-- PATH: /opt/msvc/bin
-- The CXX compiler identification is MSVC 19.29.30133.0
-- Check for working CXX compiler: /opt/msvc/bin/x86/cl
-- Check for working CXX compiler: /opt/msvc/bin/x86/cl - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /worker/cxx-example/build
if change to this:
message(STATUS "ARCH:${ARCH}")
if(DEFINED ARCH)
message(STATUS "DEFINE ARCH")
endif()
if(NOT DEFINED ARCH)
message(FATAL_ERROR "NOT DEFINE ARCH") // only here
endif()
cmake error output:
-- ARCH:x86
-- DEFINE ARCH
-- PATH: /opt/msvc/bin
-- The CXX compiler identification is MSVC 19.29.30133.0
-- Check for working CXX compiler: /opt/msvc/bin/x86/cl
CMake Error at /worker/msvc-toolchain.cmake:20 (message):
NOT DEFINE ARCH
Call Stack (most recent call first):
/worker/cxx-example/build/CMakeFiles/3.16.20200203-ga5e7a94/CMakeSystem.cmake:6 (include)
/worker/cxx-example/build/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error at /opt/cmake/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake:37 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
CMakeLists.txt:5 (project)
-- Configuring incomplete, errors occurred!
it seems that this toolchain.cmake has been run many times? and didn't define the ARCH variable in the next few times?
Thanks!
from msvc-wine.
@mstorsjo
thanks , my test branch cmake can be compiled successful and output bin is available,I still encountered two problems:
- Is the following error caused by wine?
[1/2] Building CXX object CMakeFiles/hello-world.dir/hello-world.cc.obj
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type @
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
0178:err:msvcrt:demangle_datatype Unknown type s
9041.0\ucrt\corecrt_wctype.h
[2/2] Linking CXX executable hello-world.exe
Hmm, maybe, I'm not sure if this is a combination of cornercases in wine that aren't implemented, or your cmake build doing something more fancy than I've tested. I don't get those errors with my example.
- Strange problem, it seems that the message(FATAL_ERROR "xx") function cannot be used?
If it looks like the following, it can compile normally.
Sorry, I don't have time to help you figure out your own cmake toolchain files - things work with the example I provided, anything outside of that is up to you to figure out.
from msvc-wine.
Thanks!you are so great。
best regards
from msvc-wine.
Related Issues (20)
- cl preferring WindowsSDK Headers over custom headers. HOT 1
- runnig install.sh - permission denied HOT 2
- Wine: "build_command_line command line too long" HOT 6
- Trying to get MSBuild working in a Fedora container HOT 16
- msbuild uses HostX86 tools when cross-compiling on x64 host and UseEnv=false HOT 2
- netfx 4.8
- Suggestion: Using GitHub cache action to cache the downloaded files between CI runs HOT 7
- CMake Find Packages HOT 2
- MS CMake support HOT 2
- `/analyze` Causes Errors When Used HOT 5
- Stuck on Detecting C ABI HOT 9
- File path issue when compiling wxWidgets HOT 9
- libtiff not building with clang-cl HOT 7
- GDI+ has some include file problems HOT 2
- link doesn't work with rsp HOT 6
- improving user experience with Clang/LLD in GCC mode HOT 1
- vsdownload.py: option to download compiler HOT 3
- LINK error if response files are huge HOT 2
- How to download v143 toolset? HOT 1
- there seems to be no wine64 in ubuntu23.10 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msvc-wine.