When I try to compile a program with mlton
, I get an error.
~/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 $
According to this, that means I should install libgmp3-dev
. I've run apt-get install libgmp3-dev
, and verified that the file /usr/include/x86_64-linux-gnu/gmp.h
exists, but am still getting the same error.
Any idea what I'm doing wrong?
Try executing gcc -v -x c -E -
in your terminal. This will print out the header file search path that your C compiler is using. I get something like:
#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)
So if I had gmp.h
in /usr/include/x86_64-linux-gnu/
, then my C compiler would not find it. I would suggest moving your .h file into a directory that is on this search path (like /usr/local/include
in my case), or passing in the -I /usr/include/x86_64-linux-gnu/
flag, which would require modifying MLton's build scripts. Chances are you are going to have to do the same thing with libgmp.a
when it comes time to link