几天后,我可以在Ubuntu 18.04中编译openalpr,现在我有了libopenalprjni.so和两个自动创建的jni文件(com_openalpr_jni_Alpr.h和openalprjni.cpp)。另外,我还有其他一些Java源文件中的Main.Java,它似乎不是与Android相关的Java源文件! 我创建了一个jni静态共享库,并在其上使用com_openalpr_jni_Alpr.h和openalprjni.cpp,并将libopenalprjni.so引用到其中,并将alpr.h添加为外部依赖项。但是,当我编译它时,出现错误MSB6006:“ clang.exe”退出,代码为1。 这是我在Visual Studio 2017中的输出:
ANDROID_HOME=C:\ProgramData\Microsoft\AndroidSDK\25
ANT_HOME=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Apps\apache-ant-1.9.3
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_172
NDK_ROOT=C:\Microsoft\AndroidNDK64\android-ndk-r15c
pch.h
nativealpr.cpp
nativealpr.cpp(89,2): warning : 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
delete buf;
^
[]
nativealpr.cpp(81,23): note: allocated with 'new[]' here
unsigned char* buf = new unsigned char[len];
^
1 warning generated.
undefined reference to 'alpr::Alpr::Alpr(std::string, std::string, std::string)'
undefined reference to 'alpr::Alpr::isLoaded()'
undefined reference to 'alpr::Alpr::recognize(std::string)'
undefined reference to 'alpr::Alpr::toJson(alpr::AlprResults)'
undefined reference to 'alpr::Alpr::recognize(std::vector<char, std::allocator<char> >)'
undefined reference to 'alpr::Alpr::toJson(alpr::AlprResults)'
undefined reference to 'alpr::Alpr::recognize(unsigned char*, int, int, int, std::vector<alpr::AlprRegionOfInterest, std::allocator<alpr::AlprRegionOfInterest> >)'
undefined reference to 'alpr::Alpr::toJson(alpr::AlprResults)'
undefined reference to 'alpr::Alpr::setDefaultRegion(std::string)'
undefined reference to 'alpr::Alpr::setDetectRegion(bool)'
undefined reference to 'alpr::Alpr::setTopN(int)'
undefined reference to 'alpr::Alpr::getVersion()'
clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Application Type\Android\3.0\Android.Common.targets(104,5): error MSB6006: "clang.exe" exited with code 1.