Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross compile error #78

Closed
linuxaged opened this issue Sep 29, 2019 · 9 comments
Assignees
Projects
Milestone

Comments

@linuxaged
Copy link
Contributor

@linuxaged linuxaged commented Sep 29, 2019

platform: Windows 10, Visual Studio 2019, CMake 3.15.1
target: emscripten

Got the D8021: invalid numeric argument '/Wno-warn-absolute-paths' error.
Is cross building target Web platform on Windows not supported?

C:\workspace\corrade\build-emscripten>cmake ..  -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten-wasm.cmake"  -DCMAKE_BUILD_TYPE=Release  -DEMSCRIPTEN_PREFIX="C:/workspace/emsdk" -DCMAKE_INSTALL_PREFIX="C:/lib/emscripten/system"
-- The CXX compiler identification is MSVC 19.23.28105.4
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCXXCompiler.cmake:53 (message):
  The C++ compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/workspace/corrade/build-emscripten/CMakeFiles/CMakeTmp

    Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe cmTC_6bdf8.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.3.0+0f4c62fea
    版权所有(C) Microsoft Corporation。保留所有权利。

      Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28105.4 for x64
      Copyright (C) Microsoft Corporation.  All rights reserved.
      cl /c /I"C:\workspace\vcpkg\installed\x64-windows\include" /W1 /WX- /diagnostics:column /O2 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_6bdf8.dir\Debug\\" /Fd"cmTC_6bdf8.dir\Debug\vc142.pdb" /Gd /TP /errorReport:queue  -s WASM=1 -Wno-warn-absolute-paths "C:\workspace\corrade\build-emscripten\CMakeFiles\CMakeTmp\testCXXCompiler.cxx"
    cl : command line error D8021: invalid numeric argument '/Wno-warn-absolute-paths' [C:\workspace\corrade\build-emscripten\CMakeFiles\CMakeTmp\cmTC_6bdf8.vcxproj]





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:50 (project)


-- Configuring incomplete, errors occurred!
See also "C:/workspace/corrade/build-emscripten/CMakeFiles/CMakeOutput.log".
See also "C:/workspace/corrade/build-emscripten/CMakeFiles/CMakeError.log".
@mosra mosra added this to the 2019.0b milestone Sep 29, 2019
@mosra mosra added this to TODO in Platforms via automation Sep 29, 2019
@mosra mosra self-assigned this Sep 29, 2019
@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Sep 29, 2019

Hi!

This is a common issue on Windows -- CMake uses Visual Studio project files as a default generator on Windows, but Visual Studio projects insist on using MSVC as a compiler (so emcc supplied by the Emscripten toolchain will get ignored). Solution is to specify a different generator (e.g. -G Ninja, if you have Ninja installed). The troubleshooting docs contain more information, including how to use Ninja that's bundled in VS installations.

Since you're not the first person running into this, I'll look if this could be handled with a better error message in the toolchain file itself.

@linuxaged

This comment has been minimized.

Copy link
Contributor Author

@linuxaged linuxaged commented Sep 29, 2019

Yet, Get another error when generate Ninja project:

C:\workspace\corrade\build-emscripten>cmake .. -G Ninja -DCMAKE_MAKE_PROGRAM="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe" -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten-wasm.cmake"  -DCMAKE_BUILD_TYPE=Release  -DEMSCRIPTEN_PREFIX="C:/workspace/emsdk" -DCMAKE_INSTALL_PREFIX="C:/lib/emscripten/system"
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:50 (project):
  The CMAKE_CXX_COMPILER:

    C:/workspace/emsdk/em++.bat

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "C:/workspace/corrade/build-emscripten/CMakeFiles/CMakeOutput.log".
See also "C:/workspace/corrade/build-emscripten/CMakeFiles/CMakeError.log".
@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Sep 29, 2019

Windows is not my primary system and I don't know much about emsdk, so I'm afraid I won't be able to help much... :/

Does C:/workspace/emsdk/em++.bat exist at all? Alternatively, if you have em++.bat in PATH, CMake should be able to pick that up correctly as well.

@linuxaged

This comment has been minimized.

Copy link
Contributor Author

@linuxaged linuxaged commented Sep 29, 2019

My fault, have assigned wrong value to EMSCRIPTEN_PREFIX, em++.bat is located in emsdk/emscripten/1.38.30.
Ninja project has been generated! Thanks.

@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Sep 29, 2019

Yay, glad to hear that! 🎉

Keeping this open until I add a better error message to the toolchain file as I mentioned above.

@linuxaged

This comment has been minimized.

Copy link
Contributor Author

@linuxaged linuxaged commented Sep 30, 2019

By the way, got another cmake error when building magnum target WASM,
there're UseCorrade.cmake CorradeLibSuffix.cmake files in my C:\lib\emscripten\system\share\cmake\Corrade folder, how did cmake not find them with find_path?

C:\workspace\magnum\build-emscripten>cmake .. -G Ninja -DCMAKE_MAKE_PROGRAM="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe" -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten-wasm.cmake"  -DCMAKE_BUILD_TYPE=Release  -DEMSCRIPTEN_PREFIX="C:/workspace/emsdk/emscripten/1.38.30" -DCMAKE_PREFIX_PATH="C:/lib/emscripten/system" -DCMAKE_INSTALL_PREFIX="C:/lib/emscripten/system" -DMAGNUM_DEPLOY_PREFIX="C:/http/magnum" -DWITH_SDL2APPLICATION=ON -DCORRADE_INCLUDE_DIR="C:/lib/emscripten/system/include"
CMake Error at modules/FindCorrade.cmake:291 (file):
  file failed to open for reading (No such file or directory):

    C:/workspace/magnum/_CORRADE_CONFIGURE_FILE-NOTFOUND
Call Stack (most recent call first):
  CMakeLists.txt:52 (find_package)


CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Corrade (missing: _CORRADE_MODULE_DIR
  _CORRADE_CONFIGURE_FILE Containers Utility)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  modules/FindCorrade.cmake:552 (find_package_handle_standard_args)
  CMakeLists.txt:52 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/workspace/magnum/build-emscripten/CMakeFiles/CMakeOutput.log".
See also "C:/workspace/magnum/build-emscripten/CMakeFiles/CMakeError.log".
@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Sep 30, 2019

Cross-compilation with CMake is painful, right? 🙈

Have a look at this part of the troubleshooting guide -- in particular, adding -DCMAKE_FIND_ROOT_PATH=C:/lib/emscripten/system could help. Hopefully (this is one featurebug of CMake I still don't understand, even after 10 years of using it). And then you shouldn't need to specify -DCORRADE_INCLUDE_DIR.

The "nuclear" solution when everything goes wrong is opening CMake GUI in the directory and pointing all CORRADE_* variables to the dirs/files manually. But that's really the most desperate solution when everything else fails.

@linuxaged

This comment has been minimized.

Copy link
Contributor Author

@linuxaged linuxaged commented Sep 30, 2019

Yep, cross-building maybe not so friendly to a newcomer like me, but magnum is still a great project especially the architecture, i can hold on. Good job!

Fixed, thanks!

@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Oct 15, 2019

Since mosra/toolchains@c6eaa23 there's an explicit error message when Visual Studio generator is used with Emscripten, explaining what to do instead.

@mosra mosra closed this Oct 15, 2019
Platforms automation moved this from TODO to Done Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Platforms
  
Done
2 participants
You can’t perform that action at this time.