4

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: Error running link command: %1 is not a valid Win32 application

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

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?

CodesInChaos
  • 106,488
  • 23
  • 218
  • 262
user2061057
  • 962
  • 1
  • 9
  • 20
  • 1
    win_pnacl tools are sh scripts without extension and .bat files, so I think defining CMAKE_AR as pnacl_ar.BAT might fix it. But here is another problem, maximum length of .bat file command line is much less than allowed by CreateProcess api – eugensk Apr 13 '15 at 08:14

1 Answers1

2

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 "")
orcy
  • 1,304
  • 14
  • 29