Browse thread
ocamlgsl natively with MingW
- Tobias Elze
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Tobias Elze <mailinglists@t...> |
| Subject: | ocamlgsl natively with MingW |
Almost one year after my last message on this list where I asked for help compiling ocamlgsl with MingW, I succeeded. I want to thank Olivier Andrieu and Ulrich Steinmetz for their support and to provide the necessary steps here (since some of them are not obvious at all): First of all, it seems not to be possible to link ocamlgsl dynamically. So when compiling it, remove the line DYNAMIC_LINKING=... from the Makefile. After this, I was able to compile the library and could even generate native binaries of my programs which used it. However, whenever functions from Gsl_rnd where called, I received lots of compile warnings, and in many cases the compiled binaries were not working (crashing or doing nothing). The solution was to link the gsl library _statically_ to my binaries. This could be done by adding the following arguments to ocamlopt: -ccopt -static. However, this links _every_ C library you use to your binary, and you may end up in lots of "undefined reference" errors, since all libraries that are required by your C libraries have to be linked as well, and you may have to spend hours or days with resolving dependencies and receive a giant executable. To prevent this, I suggest not to use this global "static" flag but to link _only_ the gsl library statically and all other libraries dynamically. For this, one has to link gsl at the right position in the ocamlopt arguments. Here is a way that is working: ocamlopt (...other options...) -cclib -Wl,-lmlgsl,-dn,-lgsl,-dy,-lgslcblas (...) Finally, one has to link the pthread library by -cclib -lpthread With these tricks I succeeded, and even Gsl_rng is working. Best regards, Tobias.