[英]Calling Haskell from Java, dynamic linking error Relocation
我在編譯一個供Java使用的獨立庫時遇到了麻煩(C ++ inbetween)。 Haskell中有一個程序導出一個處理某些文本並返回它的函數。 Haskell中的程序需要一些外部數據(二進制文件)。 我正在'借助file-embed包編譯它'。 當我開始編譯時:
$ ghc -fPIC -dynamic -c -O --make MyModule.hs
它拋出錯誤:
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.
這是我使用file-embed的地方。
所以我嘗試了所提出的方法(編譯兩次,更改后綴):
$ 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
現在我收到一個我不明白的錯誤:
/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
任何人都可以向我解釋並提供一些如何解決它的提示嗎?
只是一個猜測,但也許您需要不同版本的HSrts-ghc-7.6.3,因為這是一個“非標准”構建。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.