记录 这里使用的系统是 CentOS 7 Full 选择的Gnome
1. CentOS 默认安装openjdk没安装开发环境,应安装开发环境
yum -y install java-1.7.0-openjdk-devel.x86_64
2. Jni开发yum -y install gcc,如果没有自动安装g++,yum -y install gcc-c++
3. eclipse 需要c/c++插件,具体可以下一个 eclipse-cpp-juno-SR2-win32-x86_64比对下具体加哪些组件
4. Jni开发找到.h文件: whereis jvm找到/usr/lib/jvm目录,开发时用的到
5. Jni开发eclipse配置run->extternal tools->external tools configurations..->program new->变量/usr/lib/jvm/java-.../bin/javah、${project_loc}、-v -classpath “${project_loc}/bin” -d“${project_loc}/jni” -jni ${java_type_name}
6. Jni 开发 项目配置 properties->c/c++ build->
Setting->Cross G++ Linker->Shared Library Settings->check Shared,
Includes中增加JAVA_HOME/include/linux和JAVA_HOME/include目录,Setting->Build Artifact 设置为ShareLibrary生成so文件前缀lib
7. Jni开发 如出现 ....o:relocation R_X86_64_32 against .rodataa.str1.8’ can not be used when making a shared object; recompile with -fPIC则配置properties->c/c++ build->Setting -> Cross G++ Compiler-> Miscellaneous 在Other flags原参数前面添加“-fPIC” 参数(不要引号)