Reputation: 5597
I'm trying to compile C++ code with NDK to use on Android. However, I get this error when trying to compile:
error: 'JNIEXPORT' does not name a type (File: JNIApi.h, line: 9)
error: 'JNIEXPORT' does not name a type (File: JNIApi.h, line: 10)
JNIApi.h looks like this:
#pragma once
extern "C"
{
JNIEXPORT void JNICALL Java_com_manabreak_tremortest_TremorLauncher_initTremor(JNIEnv* jenv, jobject obj);
JNIEXPORT void JNICALL Java_com_manabreak_tremortest_TremorLauncher_setSurface(JNIEnv* jenv, jobject obj, jobject surface);
}
And the build process outputs this:
Build started 1.8.2014 11:14:17.
1>Project "E:\Tremor\build\Tremor.vcxproj" on node 2 (Build target(s)).
1>ClCompile:
E:\ADT\ndk\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-g++.exe JNIApi.cpp
E:\ADT\ndk\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-g++.exe -o Android/Debug/JNIApi.o -marm -fno-strict-aliasing -funswitch-loops -finline-limit=100 -fomit-frame-pointer -fno-exceptions -fpic -fstack-protector -fno-rtti -fno-short-enums -x c++ -Wno-psabi -IE:/ADT/ndk/platforms/android-19/arch-arm/usr/include -IE:/ADT/ndk/sources/cxx-stl/gnu-libstdc++/4.8/include -IE:/ADT/ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -DANDROID_NDK -DANDROID -D__ANDROID__ -D__ARM_EABI__ -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -O0 -g -std=c++11 -march=armv7-a -mtune=xscale -c -MD ../src/platforms/android/JNIApi.cpp
TRApplicationContext.cpp
E:\ADT\ndk\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-g++.exe -o Android/Debug/TRApplicationContext.o -marm -fno-strict-aliasing -funswitch-loops -finline-limit=100 -fomit-frame-pointer -fno-exceptions -fpic -fstack-protector -fno-rtti -fno-short-enums -x c++ -Wno-psabi -IE:/ADT/ndk/platforms/android-19/arch-arm/usr/include -IE:/ADT/ndk/sources/cxx-stl/gnu-libstdc++/4.8/include -IE:/ADT/ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -DANDROID_NDK -DANDROID -D__ANDROID__ -D__ARM_EABI__ -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -O0 -g -std=c++11 -march=armv7-a -mtune=xscale -c -MD ../src/platforms/android/TRApplicationContext.cpp
E:\Tremor\src\platforms\android\TRApplicationContext.cpp(3): includes this header: 0:
1>E:\Tremor\src\platforms\android\JNIApi.h(9,2): error : 'JNIEXPORT' does not name a type
JNIEXPORT void JNICALL Java_com_manabreak_tremortest_TremorLauncher_initTremor(JNIEnv* jenv, jobject obj);
^
1>E:\Tremor\src\platforms\android\JNIApi.h(10,2): error : 'JNIEXPORT' does not name a type
JNIEXPORT void JNICALL Java_com_manabreak_tremortest_TremorLauncher_setSurface(JNIEnv* jenv, jobject obj, jobject surface);
^
1>Done Building Project "E:\Tremor\build\Tremor.vcxproj" (Build target(s)) -- FAILED.
Build FAILED.
Time Elapsed 00:00:00.52
Upvotes: 1
Views: 9591
Reputation: 613442
You have to include the JNI header file:
#include <jni.h>
This will define the macros JNIEXPORT
and JNICALL
, not to mention all the other types etc. that you need for JNI.
Upvotes: 13