Embed Julia in C, libstdc++.so.6 No such file or directory


Hello everyone,
I am a new user and I was trying to embed Julia in C starting from the tutorial at: https://docs.julialang.org/en/stable/manual/embedding/. I seem I can’t run the first example, as gcc doesn’t find the libstdc++.so.6. I am on OSX 10.10, and looking into the Julia app Contents, I can’t seem to find the libstdc++.so.6 file under “Contents/Resources/julia/lib/julia”. I feel like I am missing some basic stuff, excuse me if that is the case.

gcc -o test -fPIC -I /Applications/Julia-0.6.app/Contents/Resources/julia/include/julia -L /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia test.c -ljulia /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/libstdc++.so.6

gcc: error: /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/libstdc++.so.6: No such file or directory

Thank you


It seems that flags provided by julia-config.jl in the share folder in the julia installation should be used.
For example, mine is located at “/Applications/Julia-0.6.app/Contents/Resources/julia/share/julia/julia-config.jl”, and the following command gives you the flags you should use:

julia /Applications/Julia-0.6.app/Contents/Resources/julia/share/julia/julia-config.jl --cflags
## -std=gnu99 -I'/Applications/Julia-0.6.app/Contents/Resources/julia/include/julia' -DJULIA_ENABLE_THREADING=1 -fPIC

julia /Applications/Julia-0.6.app/Contents/Resources/julia/share/julia/julia-config.jl --ldflags
## -L'/Applications/Julia-0.6.app/Contents/Resources/julia/lib'

julia /Applications/Julia-0.6.app/Contents/Resources/julia/share/julia/julia-config.jl --ldlibs
## -Wl,-rpath,'/Applications/Julia-0.6.app/Contents/Resources/julia/lib' -Wl,-rpath,'/Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia' -ljulia

And it’s also in the embedding documentation, in the section of Using julia-config to automatically determine build parameters


Have also a look at PackageCompiler.jl.