播放Scala - 本机访问

时间:2015-09-21 04:58:57

标签: c++ scala playframework swig

我正在使用Scala语言中的Play框架开发Web应用程序。在我的应用程序中,我必须使用swig访问用C ++编写并转换为.so的本机方法。

我的目标是从Controller类调用.so文件中的本机方法。我在互联网上搜索过,但我没有得到任何文件。

我看过一些scala语言使用的链接。

https://code.google.com/p/scala-native-access/ https://code.google.com/p/bridj/wiki/Download#Specialized_subsets_(smaller_JARs_!) https://github.com/xudongyang/scala-native-access

但是他们没有提到在Play框架中如何使用它。

任何人都可以拥有Play scala原生访问权限的文档吗? 任何人都可以获得相同的样本申请吗?

2 个答案:

答案 0 :(得分:2)

与任何JVM语言一样,JNA / JNI为您提供本机访问权限。请注意,由于Play使用了类加载器,因此您需要确保从同一个类访问。见fail to load a native library using activator (Play Framework)

答案 1 :(得分:1)

一般来说这很难回答。玩!只是一个Scala库和框架,一些允许您在Scala中使用本机调用的工具将与play一样工作。从您指向的第一个链接,有指示与SBT(Scala构建工具)集成,它还管理您的Play框架。您需要将他们提到的更改添加到您可以在Play项目文件夹顶层找到的[armeabi] SharedLibrary : libprotobuf-lite.so jni/src/google/protobuf/stubs/common.cc:201: error: undefined reference to 'google::protobuf::util::Status::ToString() const' jni/src/google/protobuf/stubs/common.cc:207: error: undefined reference to 'google::protobuf::operator<<(std::ostream&, google::protobuf::uint128 const&)' jni/src/google/protobuf/arena.h:622: error: undefined reference to 'google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)' jni/src/google/protobuf/arena.h:624: error: undefined reference to 'google::protobuf::Arena::AddListNode(void*, void (*)(void*))' jni/src/google/protobuf/arena.h:462: error: undefined reference to 'google::protobuf::Arena::AddListNode(void*, void (*)(void*))' jni/src/google/protobuf/arena.h:617: error: undefined reference to 'google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)' jni/src/google/protobuf/arena.h:617: error: undefined reference to 'google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)' jni/src/google/protobuf/arena.h:617: error: undefined reference to 'google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)' jni/src/google/protobuf/arena.h:633: error: undefined reference to 'google::protobuf::Arena::AddListNode(void*, void (*)(void*))' jni/src/google/protobuf/arena.h:624: error: undefined reference to 'google::protobuf::Arena::AddListNode(void*, void (*)(void*))' jni/src/google/protobuf/wire_format_lite.cc:514: error: undefined reference to 'google::protobuf::internal::IsStructurallyValidUTF8(char const*, int)' jni/src/google/protobuf/wire_format_lite.cc:527: error: undefined reference to 'google::protobuf::StringPrintf(char const*, ...)' collect2: error: ld returned 1 exit status 文件中。

相关问题