2

我正在尝试在http://code.google.com/p/javacpp/上运行自己的 LegacyLibrary 示例

当我尝试使用仅在站点中提到的以下命令编译代码时(基本上是使用 javacpp.jar 编译代码),我遇到了以下异常

D:\Java Workspace\POC\JavaCPP\bin>java -jar javacpp.jar LegacyLibrary
Generating source file: D:\Java Workspace\POC\JavaCPP\bin\jniLegacyLibrary.cpp
Building library file: D:\Java Workspace\POC\JavaCPP\bin\windows-x86\jniLegacyLibrary.dll
cl "/IC:\Program Files (x86)\Java\jdk1.6.0_03\include" "/IC:\Program Files (x86)\Java\jdk1.6.0_03\include\win32" "D:\Java Workspace\POC\JavaCPP\bin\jniLegacyLibrary.cpp" /W3 /Oi
 /O2 /EHsc /Gy /GL /MD /LD /link "/OUT:D:\Java Workspace\POC\JavaCPP\bin\windows-x86\jniLegacyLibrary.dll"
Exception in thread "main" java.io.IOException: Cannot run program "cl": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
        at com.googlecode.javacpp.Builder.build(Builder.java:189)
        at com.googlecode.javacpp.Builder.generateAndBuild(Builder.java:234)
        at com.googlecode.javacpp.Builder.main(Builder.java:479)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
        at java.lang.ProcessImpl.start(ProcessImpl.java:30)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
        ... 3 more

对此有何补救措施?

4

1 回答 1

2

错误消息非常清楚:它没有找到cl可执行文件,它是 Visual Studio 编译器的名称。

您应该从 Visual Studio 命令提示符运行该命令(通常在开始菜单中有一个条目),以加载正确的环境变量。

于 2012-03-15T13:04:02.060 回答