cross-compilation for Linux from OSX

314 views
Skip to first unread message

Sergey Kojin

unread,
Dec 12, 2015, 11:12:30 AM12/12/15
to Crystal
I build empty app and try to complile it for ubuntu from OSX 10.9.5

crystal build --cross-compile "Linux x86_64"  --target "x86_64-pc-linux-gnu" src/crystalhello.cr
cc crystalhello.o -o crystalhello  -rdynamic  -levent -lrt -lpcl -lpcre -lgc -lpthread -ldl

It fail, call cc -v give error

Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
 "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -export_dynamic -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o crystalhello crystalhello.o -levent -lrt -lpcl -lpcre -lgc -lpthread -ldl -L. -L/usr/local/lib -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What I do wrong?

Ary Borenszweig

unread,
Dec 12, 2015, 7:07:00 PM12/12/15
to crysta...@googlegroups.com
Are you running the "cc" command in ubuntu or mac osx? 

--
You received this message because you are subscribed to the Google Groups "Crystal" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crystal-lang...@googlegroups.com.
To post to this group, send email to crysta...@googlegroups.com.
Visit this group at https://groups.google.com/group/crystal-lang.
To view this discussion on the web visit https://groups.google.com/d/msgid/crystal-lang/89e03186-ec4a-45ba-95ff-7d4c14ac64b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Ary Borenszweig         Manas Technology Solutions
[ar.phone]                      5258.5240       #ARY(279)
[us.phone]                      312.612.1050    #ARY(279)
[email]                         aboren...@manas.com.ar
[web]                           www.manas.com.ar

Sergey Kojin

unread,
Dec 13, 2015, 4:04:25 AM12/13/15
to Crystal
On OSX

Ary Borenszweig

unread,
Dec 13, 2015, 1:24:03 PM12/13/15
to crysta...@googlegroups.com
That's why it doesn't work. If you follow the instructions at http://crystal-lang.org/docs/syntax_and_semantics/cross-compilation.html it says you need to copy the .o to the target system of the cross compilation (ubuntu in your case) and then run that cc command there.

But there's already a compiler for ubuntu, so you could easily compile a program in ubuntu, no need to cross compile.

On Sun, Dec 13, 2015 at 6:04 AM, Sergey Kojin <sergey...@gmail.com> wrote:
On OSX

--
You received this message because you are subscribed to the Google Groups "Crystal" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crystal-lang...@googlegroups.com.
To post to this group, send email to crysta...@googlegroups.com.
Visit this group at https://groups.google.com/group/crystal-lang.

For more options, visit https://groups.google.com/d/optout.

Tim Uckun

unread,
Dec 13, 2015, 10:58:40 PM12/13/15
to crysta...@googlegroups.com
Just out of curiosity Is the compilation static? 

Sergey Kojin

unread,
Dec 14, 2015, 3:27:28 AM12/14/15
to Crystal
Thanks, that helps, I just expected some like GO crosscompliation.

Now I stick with error on ubuntu 14.04

main_module:(.text+0x72bb): undefined reference to `GC_get_push_other_roots'


воскресенье, 13 декабря 2015 г., 21:24:03 UTC+3 пользователь aborenszweig написал:

Ary Borenszweig

unread,
Dec 14, 2015, 10:28:57 AM12/14/15
to crysta...@googlegroups.com
You need boehm GC 7.4. But why are you cross compiling to Ubuntu if there's a package for it already?


For more options, visit https://groups.google.com/d/optout.

sergey.kojin

unread,
Dec 14, 2015, 10:54:58 AM12/14/15
to crysta...@googlegroups.com
I not compile crystal, I compile my project.

понедельник, 14 декабря 2015 г. в 18:28, Ary Borenszweig написал:

You received this message because you are subscribed to a topic in the Google Groups "Crystal" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/crystal-lang/KXtUaIyPtxo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to crystal-lang...@googlegroups.com.

To post to this group, send email to crysta...@googlegroups.com.
Visit this group at https://groups.google.com/group/crystal-lang.

Sergey Kojin

unread,
Dec 14, 2015, 11:38:28 AM12/14/15
to Crystal
Everyone thanks, for help. I just used docker to build for ubuntu.

Tim Uckun

unread,
Jul 26, 2016, 9:14:29 AM7/26/16
to crysta...@googlegroups.com
Just out of curiosity.

What is the preferred way to deploy Crystal apps? Do you ship the source and compile on the target as a part of the deployment process or do you rely on cross compilation?

Also do you guys think it will ever be possible to statically compile your app so you can just copy a binary and be done without having to worry about what's installed on the host.

Thanks.

Ary Borenszweig

unread,
Jul 26, 2016, 9:30:58 AM7/26/16
to crysta...@googlegroups.com
Right now the best thing to do is to compile on the target machine.

I think eventually fully cross compiling an app should be possible, but right now it's really low priority for us.


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages