问题描述
请帮忙,我已经花了一整天的时间来编译我的c ++应用程序。
Please help, I have spent all day trying to make my c++ app compile.
我的项目包含一个源文件:Foo.cpp。这是它的代码:
My project contains one source file: Foo.cpp. Here is its code:
#include <jni.h>
#include <com_Foo.h>
JNIEXPORT jint JNICALL Java_com_Foo_add
(JNIEnv * env, jobject obj, jint x, jint y)
{
return x+y;
}
您可以看到我正在尝试使用JNI,但我没有认为与问题有关。这是我在命令行上尝试过的操作:
as you can see I was trying to use JNI, but I don't think that has anything to do with the problem. Here is what I tried on the command line:
C:\Users\michael\cworkspace\foo>cl -LD Foo.cpp -FeFoo.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
Foo.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/dll
/implib:Foo.lib
/out:Foo.dll
Foo.obj
LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'
在我的环境中,我设置了:
In my environment I have set:
包含:
C:_\include; C:\frankenstein\includes; C:\Program Files\Java\jdk1.6.0_24\include; C:\ \程序文件\Java\jdk1.6.0_24\include\win32; C:_\include\win32; C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\include
INCLUDE:C:_\include;C:\frankenstein\includes;C:\Program Files\Java\jdk1.6.0_24\include;C:\Program Files\Java\jdk1.6.0_24\include\win32;C:_\include\win32;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
LIBPATH:
C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\lib
LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
我检查了lib目录,它包含一个 libcmt.lib文件。不知道它是否区分大小写,但是我知道我从未更改过Visual Studio文件或目录中的任何内容。
I checked in the lib directory, it contains a "libcmt.lib" file. Don't know if it is case sensitive, but I know that I never changed anything in the visual studio files or directories.
请问有人可以告诉我如何制作
Would somebody please tell me how I can make this work?
推荐答案
在2018年底重新启动此线程,因为没有其他解决方案对我的情况有所帮助:)
Resurrecting this thread in late 2018 since none of the other solutions helped my case :)
对我来说,在为完全不相关的项目安装了 Windows驱动程序包之后,这个错误就开始出现了。
For me this error started appearing out of nowhere after i installed Windows Driver Kit for a completely unrelated project.
如果您不需要抑制反射 (您很可能不需要),并且看到此错误,则很有可能只需设置项目属性(属性页)->配置属性-> C / C ++->代码生成->缓解幽灵到已禁用。
If you don't need "Spectre Mitigation" (you most likely do not) and seeing this error it's highly probable that you just have to set Project Properties (property pages) -> Configuration Properties -> C/C++ -> Code Generation -> Spectre Mitigation to Disabled.
在所有项目中,Visual Studio工具的安装程序都将WDK设置为 Enabled ,即使它们与WDK无关,也是如此。已为任何与驱动程序相关的内容选择了平台工具集。最好的微软。
Magically it was set to Enabled by the installer of Visual Studio tools for WDK in all projects even tho they got nothing to do with WDK nor the Platform toolset was selected for any driver related stuff. Microsoft at its finest.
这篇关于链接:致命错误LNK 1104:无法打开文件'LIBCMT.lib'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!