VS2010在尝试编译基本JNI测试代码时出错
Error in VS2010 when trying to compile basic JNI Test Code
我正在尝试编译一个基本的JNI测试,为一个DLL(带有头和lib文件)做准备,我希望在未来几天内收到它,我需要为它创建一个JNI接口。
我试着把它指向JNI.lib的x64/x86库。我试着根本不把它指向库。我已经尝试将其指向include目录的两个x64/x86版本,但总是出现如下错误。
Visual Studio给了我以下错误,我不知道为什么:
1>------ Build started: Project: CLibHelloWorld, Configuration: Debug Win32 ------
1>Build started 04/03/2015 19:04:09.
1>InitializeBuildStatus:
1> Creating "DebugCLibHelloWorld.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> CLibHelloWorld.c
1>Link:
1> Creating library F:Work 4-CompaniesDigitalARCSystemsKlearKaptureCameraInterfacetesttest-jniDebugCLibHelloWorld.lib and object F:Work 4-CompaniesDigitalARCSystemsKlearKaptureCameraInterfacetesttest-jniDebugCLibHelloWorld.exp
1> test-jni.vcxproj -> F:Work 4-CompaniesDigitalARCSystemsKlearKaptureCameraInterfacetesttest-jniDebugCLibHelloWorld.dll
1>FinalizeBuildStatus:
1> Deleting file "DebugCLibHelloWorld.unsuccessfulbuild".
1> Touching "DebugCLibHelloWorld.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.43
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
HelloWorld.java(使用javacHelloWorld.jav编译):
class HelloWorld {
public native void print(); //native method
static //static initializer code
{
System.loadLibrary("CLibHelloWorld");
}
public static void main(String[] args)
{
HelloWorld hw = new HelloWorld();
hw.print();
}
}
HelloWorld.h(由javah-jniHelloWorld生成):
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: print
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_print
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
CLibHelloWorld.c:
#include "HelloWorld.h"
#include "jni.h"
#include "stdio.h"
JNIEXPORT void JNICALL Java_HelloWorld_print(JNIEnv *env, jobject obj)
{
printf("Hello worldn");
return;
}
将注释转换为答案,因为这显然有助于解决问题。
调查MSBuild问题的一种方法是查看详细的日志。从VS命令提示符,cd到项目的目录,然后执行命令msbuild MyProject.vcxproj /v:d
。这将建立详细的详细程度。在输出中搜索链接器命令,您应该会看到类似的内容
C:Program Files (x86)Microsoft Visual Studio 12.0VCbinlink.exe /OUT:"c:my_output_pathmyfile.dll" ...
链接器的/OUT选项就是您想要的。如果根本没有调用链接器,那么您有一些设置不需要为项目生成二进制文件。
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 无法编译 rtmidi 测试 cmidiin.cpp 文件, 非法指令
- 尽管测试成功,CppUnit测试核心仍被丢弃.为什么
- 数据成员SFINAE的C++17测试:gcc vs clang
- 如何使用重载的相等(==)运算符向测试用例添加描述
- 为什么二进制搜索在我的测试中不起作用
- 从父数组测试用例构造二叉树失败
- 通过JNI传递数据数组的最快方法是什么
- 试图对缓存进行跨步测试,但程序并没有结束
- 有什么好的方法可以让系统调用代理允许在单元测试中进行模拟
- OpenGL在启用深度测试时不会丢弃我的碎片
- 为测试目标创建具有不同源文件夹的文件
- 在子目录中使用target_sources()命令时用于单元测试(qtest)的项目结构
- VC++本机单元测试,找不到调试符号
- 换位表导致测试失败(但在游戏中运行良好)
- 用于交叉编译和CMake的预处理器宏的单元测试
- 谷歌测试中的期望值存储在哪里
- VS2010在尝试编译基本JNI测试代码时出错
- 如何从 JNI 代码进行 JNIT 测试回调
- 运行一个非常简单的Hello World JNI测试时遇到麻烦