Forums

Binary bundling under macosx?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Binary bundling under macosx?

Postby gradha » Mon Jan 17, 2011 3:05 pm

I'm trying to embed a cobra binary with mono so it is standalone and can be run from the command line. For this purpose I compile the cobra source into an exe. Then, I try to follow the instructions at http://www.mono-project.com/Guide:Runni ... plications, mainly:
Code: Select all
mkbundle -o build/bbiribbabba src/bbiribbabba.exe --deps

However, at some point it all fails with some junk character errors:
Code: Select all
OS is: Darwin
Sources: 1 Auto-dependencies: True
   embedding: /Users/gradha/project/iPhone/bbiribbabba/src/bbiribbabba.exe
   embedding: /Library/Frameworks/Mono.framework/Versions/2.8.2/lib/mono/4.0/mscorlib.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/2.8.2/lib/mono/gac/Cobra.Lang/0.8.0.1__0a4783a5c7c9616e/Cobra.Lang.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/2.8.2/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/2.8.2/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/2.8.2/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/2.8.2/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/2.8.2/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
Compiling:
as -o temp.o temp.s
temp.s:2:unknown section type: symbol_stubs
temp.s:2:Rest of line ignored. 1st junk character valued 112 (p).
temp.s:3594:unknown section type: symbol_stubs
temp.s:3594:Rest of line ignored. 1st junk character valued 112 (p).
temp.s:2875922:unknown section type: symbol_stubs
temp.s:2875922:Rest of line ignored. 1st junk character valued 112 (p).
temp.s:2981914:unknown section type: symbol_stubs
temp.s:2981914:Rest of line ignored. 1st junk character valued 112 (p).
temp.s:4720162:unknown section type: symbol_stubs
temp.s:4720162:Rest of line ignored. 1st junk character valued 112 (p).
temp.s:5016106:unknown section type: symbol_stubs
temp.s:5016106:Rest of line ignored. 1st junk character valued 112 (p).
temp.s:5143090:unknown section type: symbol_stubs
temp.s:5143090:Rest of line ignored. 1st junk character valued 112 (p).
temp.s:6423098:unknown section type: symbol_stubs
temp.s:6423098:Rest of line ignored. 1st junk character valued 112 (p).
[Fail]

I've tried this with a recent cobra and 2.8.2 mono, along with the CSDK, though I'm not sure if that's even needed. Has somebody else tried building a standalone cobra binary with success under macosx?
gradha
 
Posts: 23

Re: Binary bundling under macosx?

Postby gradha » Mon Jan 17, 2011 4:04 pm

Ack, just figured out I would test at least a normal binary and it doesn't work either. I'll look somewhere else, sorry. I found http://go-mono.com/forums/#nabble-td1549390 but I'm lost as to how I'm supposed to figure out the pkg-config local problem, I only have the pkg-config from macports.
gradha
 
Posts: 23

Re: Binary bundling under macosx?

Postby Charles » Tue Jan 18, 2011 2:04 pm

Let us know how it goes. I tried mkbundle on Mac with Mono 2.6.7 and got the same errors. I tried on another Mac with Mono 2.8.1 and then 2.8.2 and also got errors. I tried different combinations of flags which only changed which errors occurred.

I don't need mkbundle at this time, but it would be interesting to know what it takes to get it working on Mac.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Binary bundling under macosx?

Postby gradha » Tue Jan 18, 2011 3:44 pm

I managed to get it going after tinkering with the answers found at http://go-mono.com/forums/#nabble-td2717076. My current binary build script is:
Code: Select all
#!/bin/sh

export AS="as -arch i386"
export CC="cc -arch i386"
export PATH=/Library/Frameworks/Mono.framework/Commands/:$PATH

rm -Rf build &&
mkdir -p build &&
mkbundle src/bbiribbabba.exe --deps -c -o temp_prog.c --keeptemp &&
$CC -O -o build/bbiribbabba -Wall temp_prog.c \
   `pkg-config --cflags --libs mono-2` temp.o \
   -framework CoreFoundation


Since mkbundle is not being used, I don't know what magic it uses for parameters like --static or -z, both of which don't work. The former presumably because I'm linking manually with gcc, the latter because the as command seems to fail with linking issues due to missing decompression code.

At least I get a dynamically linked 6MB cobra hello world binary. Not that bad. Maybe I'll try later the mono-osx mailing list for support.
gradha
 
Posts: 23

Re: Binary bundling under macosx?

Postby gradha » Wed Jan 19, 2011 7:53 am

Finally got it working. The details are at http://lists.ximian.com/pipermail/mono- ... 03716.html. I ended up using upx (http://upx.sourceforge.net/) in the end since it achieves a higher compression ratio: 3.5MB cobra hello world statically linked binary, which works at the other side of a dropbox. My updated script:
Code: Select all
#!/bin/sh

export AS="as -arch i386"
export CC="cc -arch i386"
export PATH=/Library/Frameworks/Mono.framework/Commands/:$PATH

rm -Rf build temp.* temp_prog.? &&
mkdir -p build &&
mkbundle src/bbiribbabba.exe -z --deps --static -o build/bbiribbabba
gradha
 
Posts: 23


Return to Discussion

Who is online

Users browsing this forum: No registered users and 122 guests