简体   繁体   English

从Java调用Haskell,动态链接错误重定位

[英]Calling Haskell from Java, dynamic linking error Relocation

I'm having troubles with compiling a standalone library for use by Java (with C++ inbetween). 我在编译一个供Java使用的独立库时遇到了麻烦(C ++ inbetween)。 There is a program in Haskell exporting one function that processes some text and returns it. Haskell中有一个程序导出一个处理某些文本并返回它的函数。 The program in Haskell needs some external data (binary file). Haskell中的程序需要一些外部数据(二进制文件)。 I'm 'compiling it in' with the help of file-embed package . 我正在'借助file-embed包编译它'。 When I started the compilation with: 当我开始编译时:

$ ghc -fPIC -dynamic -c -O --make MyModule.hs

It throws the error: 它抛出错误:

MyModule.hs:239:15:
Dynamic linking required, but this is a non-standard build (eg. prof).
You need to build the program twice: once the normal way, and then
in the desired way using -osuf to set the object file suffix.

This is the place where I use file-embed. 这是我使用file-embed的地方。

So I tried the proposed approach (compiling twice, changing suffixes): 所以我尝试了所提出的方法(编译两次,更改后缀):

$ ghc -fPIC  -c -O --make MyModule.hs
$ ghc -osuf d.o -fPIC -dynamic -c -O --make MyModule.hs
$ javac -cp javacpp.jar MyModule.java
$java -jar javacpp.jar -Dcompiler.path=ghc -Dcompiler.output.prefix="-optc-O3 -Wall MyModule.d.o -dynamic -fPIC -shared -lstdc++ -lHSrts-ghc7.6.3 -o " -Dcompiler.linkpath.prefix2="-optl -Wl,-rpath," MyModule

And now I'm getting an error that I don't understand: 现在我收到一个我不明白的错误:

/usr/bin/ld: MyModule.d.o: relocation R_X86_64_PC32 against undefined symbol `{Directory_with_code}zi{Some_module}_{Some_module}_con_info' can not be used when making a shared object; recompile with -fPIC

Can anyone explain it to me and give some tips on how to solve it? 任何人都可以向我解释并提供一些如何解决它的提示吗?

只是一个猜测,但也许您需要不同版本的HSrts-ghc-7.6.3,因为这是一个“非标准”构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM