CMake:运行链接命令时出错:%1不是有效的Win32应用程序 [英] CMake: Error running link command: %1 is not a valid Win32 application
问题描述
我正在尝试使用CMake在64位Windows 8.1上构建NaCl扩展.相同的代码可以在Ubuntu上正常工作.一切顺利,直到CMake尝试与此命令链接:
I'm trying to build a NaCl extension on 64-bit Windows 8.1 using CMake. The same code works on Ubuntu without any problems. Everything goes well until CMake tries to link with this command:
cmake -E cmake_link_script link.txt
CMake:运行链接命令时出错:%1不是有效的Win32应用程序
CMake: Error running link command: %1 is not a valid Win32 application
link.txt如下:
The link.txt is as follows:
C:/nacl_sdk/pepper_39/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a CMakeFiles/foo.dir/Foo.cc.o
C:/nacl_sdk/pepper_39/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a
NMake和Unix makefile生成器都会发生这种情况(NaCl SDK包含Windows的make.exe).
This happens with both NMake and Unix makefile generators (the NaCl SDK contains make.exe for Windows).
如果我手动运行这些命令,它们将成功.这有什么问题吗?
If I run those commands manually, they succeed. What could be wrong here?
推荐答案
就像eugensk00建议的那样,在工具链定义中添加".bat"似乎可行.需要同时为ar和ranlib添加:
Just like eugensk00 suggested adding ".bat" in toolchain definitions seems to work. It is required to add both for ar and ranlib though:
set(CMAKE_AR "${PLATFORM_PREFIX}/bin/pnacl-ar.bat" CACHE STRING "")
set(CMAKE_RANLIB "${PLATFORM_PREFIX}/bin/pnacl-ranlib.bat" CACHE STRING "")
这篇关于CMake:运行链接命令时出错:%1不是有效的Win32应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!