mlton给出了与库相关的错误

时间:2015-06-11 15:11:40

标签: sml mlton

当我尝试使用mlton编译程序时,出现错误。

~/projects/serve-sml $ mlton server.mlb
In file included from /usr/lib/mlton/include/platform.h:13:0,
                 from /usr/lib/mlton/include/common-main.h:16,
                 from /usr/lib/mlton/include/amd64-main.h:11,
                 from /tmp/file86PWQJ.1.c:110:
/usr/lib/mlton/include/cenv.h:137:17: fatal error: gmp.h: No such file or directory
 #include "gmp.h"
                 ^
compilation terminated.
call to system failed with exit status 1:
gcc -std=gnu99 -c -I/usr/lib/mlton/targets/self/include -I/usr/lib/mlton/include -O1 -fno-common -fno-strict-aliasing -fomit-frame-pointer -w -m64 -o /tmp/fileg5D5To.o /tmp/file86PWQJ.1.c
~/projects/serve-sml $ 

根据this,这意味着我应该安装libgmp3-dev。我已经运行apt-get install libgmp3-dev,并验证文件/usr/include/x86_64-linux-gnu/gmp.h是否存在,但我仍然遇到同样的错误。

知道我做错了吗?

1 个答案:

答案 0 :(得分:1)

尝试在终端中执行gcc -v -x c -E -。这将打印出C编译器正在使用的头文件搜索路径。我得到类似的东西:

#include "..." search starts here:
#include <...> search starts here:
/Users/ml9951/include
.
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)

所以,如果我在gmp.h中有/usr/include/x86_64-linux-gnu/,那么我的C编译器就找不到它。我建议将你的.h文件移动到这个搜索路径上的目录(比如我的/usr/local/include),或者传入-I /usr/include/x86_64-linux-gnu/标志,这需要修改MLton的构建脚本。在链接的时候你可能需要用libgmp.a做同样的事情