# Transpiling Julia to C

**URL:** <https://discourse.julialang.org/t/transpiling-julia-to-c/830>\
**Category:** General Usage\
**Created:** [December 9, 2016, 3:51pm UTC](https://discourse.julialang.org/t/transpiling-julia-to-c/830 "2016-12-09T15:51:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomerg](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@tomerg](https://discourse.julialang.org/u/tomerg)\
**Post date:** [December 9, 2016, 3:51pm UTC](https://discourse.julialang.org/t/transpiling-julia-to-c/830/1 "2016-12-09T15:51:19Z")

</div>

Hi,

I’m new to Julia. I read the blog posts on static compilation and transpiling Julia to C, and I tried to do it by myself.  
I followed the instructions and I built Julia (0.6.0-dev), I compiled llvm (3.7.1) and llvm-cbe. The bottom line is that I’m running the conversion command and nothing happen, there are no errors and no output file.  
The process that I have done is as follows:

- I’m working on Ubuntu 12.04 (I know it’s old…) in a virtual machine using VirtualBox. I’m using gcc version 4.8.1.
- I built Julia according to the instructions in the website. I have run the make command successfully, but I didn’t manage to run the make install command due to dependencies in Python that I haven’t resolved yet. Maybe this is the reason for the problem…
- I compiled llvm (as part of the compilation of Julia).
- I compiled llvm-cbe.
- I have generated HelloWorld.jl code:  
function main()  
println(“hello world!”)  
end
- I saved the file in base directory and I put there a userimg.jl containing the line: include(“HelloWorld.jl”).
- Then I run the following commands inside the base directory:

1. sudo julia -C native --output-ji inference.ji coreimg.jl (the inference file was created)
2. sudo julia -C native --output-o libHelloWorld.o -J inference.ji --startup-file=no sysimg.jl (the o file was created)
3. sudo cc -L"…/usr/lib" -ljulia -shared -o libHelloWorld.so libHelloWorld.o (the file was created)
4. sudo julia --output-bc libHelloWorld.bc -J libHelloWorld.so --startup-file=no --compile=yes --eval nothing (the file was created)  
Note: when I have tried the compile all option I got a segmentation fault. The output is attached below the post.
5. sudo …/deps/scratch/llvm-3.7.1/build\_Release/Release/bin/llvm-cbe libHelloWorld.bc libHelloWorld.cbe.c  
During the execution of the command I see the c file created in the directory (with a size of 0B) but it disappears at the end of the run. Except for that I don’t get any errors or something else.

I would be glad if you help me debug the problem. Does everything related to the fact that I didn’t ran the make install?

Thanks.

Output of compile all option:  
found 24348 uncompiled methods for compile-all  
2789 / 24348  
signal (11): Segmentation fault  
while loading no file, in expression starting on line 0  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:574  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587  
array\_to\_list at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:557 [inlined]  
julia\_to\_scm\_ at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:587 [inlined]  
julia\_to\_scm at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:542  
jl\_call\_scm\_on\_ast at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:795 [inlined]  
jl\_expand at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/ast.c:806  
jl\_code\_for\_staged at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/alloc.c:532  
get\_staged at ./inference.jl:217  
typeinf\_frame at ./inference.jl:1590  
typeinf\_code at ./inference.jl:1686  
unknown function (ip: 0x952c4324)  
jl\_call\_method\_internal at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/julia\_internal.h:240 [inlined]  
jl\_apply\_generic at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1861  
typeinf\_ext at ./inference.jl:1724  
unknown function (ip: 0x952b2ee7)  
jl\_call\_method\_internal at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/julia\_internal.h:240 [inlined]  
jl\_apply\_generic at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1861  
jl\_apply at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/julia.h:1378 [inlined]  
jl\_type\_infer at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:211 [inlined]  
\_compile\_all\_deq at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1539 [inlined]  
jl\_compile\_all\_defs at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1618 [inlined]  
jl\_precompile at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/gf.c:1685  
julia\_save at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/init.c:720 [inlined]  
jl\_atexit\_hook at /media/3eab7239-0293-41c3-8f52-a29352c8d818/julia/src/init.c:196  
unknown function (ip: 0x8048dfd)  
\_\_libc\_start\_main at /lib/i386-linux-gnu/libc.so.6 (unknown line)  
unknown function (ip: 0x8048e34)  
Allocations: 38582925 (Pool: 38581929; Big: 996); GC: 10
