Last active
June 3, 2021 03:19
-
-
Save saschatimme/46d985aeaf3fbc47a0296f8874d7c936 to your computer and use it in GitHub Desktop.
make.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <caml/callback.h> | |
extern int fib(int n); | |
extern char * format_result(int n); | |
int main(int argc, char ** argv) | |
{ | |
int result; | |
/* Initialize OCaml code */ | |
caml_startup(argv); | |
/* Do some computation */ | |
result = fib(10); | |
printf("fib(10) = %s\n", format_result(result)); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This works | |
# mod.ml is some ocaml code | |
# modwrap.c is a wrapper which calls the registered callbacks | |
# libasmrun is a runtime library | |
simplewrapper: | |
ocamlopt -output-obj -o modcaml.o mod.ml | |
ocamlc -c modwrap.c ;\ | |
cp `ocamlc -where`/libasmrun.a libmod.a && chmod +w libmod.a ;\ | |
ar r libmod.a modcaml.o modwrap.o | |
main: | |
cc -o prog -I `ocamlc -where` main.c libmod.a | |
# Now has the compiler another mode | |
# -output-complete-obj | |
# That includes the runtime library directly into modcaml.o | |
simplewrapper2: | |
ocamlopt -output-complete-obj -o modcaml.o mod.ml | |
ocamlc -c modwrap.c ;\ | |
ar rcs libmod.a modcaml.o modwrap.o | |
main2: | |
cc -o prog -I `ocamlc -where` main.c libmod.a | |
# BUT now can I not compile the main file anymore. | |
# Error: | |
# Undefined symbols for architecture x86_64: | |
# "_caml_code_area_end", referenced from: | |
# _segv_handler in libmod.a(modcaml.o) | |
# "_caml_code_area_start", referenced from: | |
# _segv_handler in libmod.a(modcaml.o) | |
# "_caml_startup", referenced from: | |
# _main in main-bd2140.o | |
# (maybe you meant: _caml_startup__data_end, _caml_startup__data_begin , _caml_startup__frametable , _caml_startup__code_end , _caml_startup__code_begin ) | |
# "_caml_system__code_end", referenced from: | |
# _segv_handler in libmod.a(modcaml.o) | |
# ld: symbol(s) not found for architect 86_64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
did you fix this? I'm getting the same error :P