Skip to content

Calling SML compiled with MLton from C #456

Answered by MatthewFluet
klartext asked this question in Q&A
Discussion options

You must be logged in to vote

[Consolidating discussion to a single answer.]

Yes, it is possible to create an SML library that is called by a C program. The documentation is at http://mlton.org/LibrarySupport.

The essential process is to create your SML library as an SML program that uses _export "func" public as described in http://www.mlton.org/CallingFromCToSML; note the public symbol scope to make the symbol visible by other DSOs. Compile that program with -export-header foo.h -format library -libname foo (to create a dynamic shared library (i.e., a .so)) or with -export-header foo.h -format archive -libname foo (to create an archive (i.e., a .a)). Then your C program should #include "foo.h" (the header created wh…

Replies: 7 comments 23 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
18 replies
@fweimer
Comment options

@klartext
Comment options

@MatthewFluet
Comment options

@xyproto
Comment options

@MatthewFluet
Comment options

Comment options

You must be logged in to vote
1 reply
@MatthewFluet
Comment options

Comment options

You must be logged in to vote
2 replies
@xyproto
Comment options

@MatthewFluet
Comment options

Comment options

You must be logged in to vote
1 reply
@xyproto
Comment options

Answer selected by MatthewFluet
Comment options

You must be logged in to vote
1 reply
@MatthewFluet
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #455 on October 31, 2021 00:56.