#include <julia.h>
JULIA_DEFINE_FAST_TLS() // only define this once, in an executable (not in a shared library) if you want fast code
int main(int argc, char argv[])
{
/ required: setup the Julia context */
jl_init();
/* run Julia commands */
jl_eval_string("print(sqrt(2.0))");
/* strongly recommended: notify Julia that the
program is about to terminate. this allows
Julia time to cleanup pending write requests
and run all finalizers
*/
jl_atexit_hook(0);
return 0;
}
编译结果
gcc -o test -fPIC -I/usr/include/julia -L/usr/lib test.c -ljulia /usr/lib/libstdc++.so.6
/usr/bin/ld: /tmp/cci1znro.o: in function main': test.c:(.text+0x10): undefined reference to
jl_init’
collect2: 错误:ld 返回 1
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Celeron(R) CPU N3150 @ 1.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, silvermont)