Building on Linux

Discussion about using Moai SDK - post questions, bugs and issues here.

Moderators: seebs, franciscotufro

Building on Linux

Postby varomix » Sun Apr 24, 2011 3:58 pm

Hi Guys

I'm a linux guy and that's the reason I want to use Moai

can anyone please help to build this on linux



thanks
varomix
 
Posts: 2
Joined: Wed Apr 13, 2011 6:30 pm

Building on Linux

Postby varomix » Mon Apr 25, 2011 2:37 am

well, been trying to do this

I manage to convert the .sln file into a makefile, got some error but did build some stuff

moai core does build, just battling to build the main moai runtime, I'm getting an glut.h error

just need to put that were the make can find it.

If you guys had build it, please, any pointers?



I'll let you know if I do this



THanks
varomix
 
Posts: 2
Joined: Wed Apr 13, 2011 6:30 pm

Building on Linux

Postby patrick » Mon Apr 25, 2011 7:11 am

I suspect GLUT is already on your system. Should probably just be a matter of configuring the right path to it. I know on Mac the build uses the system's GLUT instead of its own.
User avatar
patrick
 
Posts: 589
Joined: Sat Apr 02, 2011 10:50 pm

Building on Linux

Postby stefano.linguerri » Mon Apr 25, 2011 7:35 pm

@varomix


do you mind to share your make files? I'm very interested in building for Linux
Twitter: http://twitter.com/eljeko
RapaNui: https://github.com/ymobe/rapanui

"Do, or do not. There is no try."
User avatar
stefano.linguerri
 
Posts: 70
Joined: Wed Apr 13, 2011 3:11 pm
Location: Italy

Building on Linux

Postby berteh » Thu May 26, 2011 2:25 am

+ 1 interested in Linux support.
berteh
 
Posts: 6
Joined: Thu May 26, 2011 9:12 am

Building on Linux

Postby b.lindeijer » Thu May 26, 2011 6:02 am

+1

I'll also be looking into compiling it on Linux.

Windows is only suitable for playing StarCraft 2. :P
b.lindeijer
 
Posts: 12
Joined: Thu May 26, 2011 12:58 pm

Building on Linux

Postby lazalong » Thu May 26, 2011 12:37 pm

To convert .sln files on linux you might look at Code::Blocks (http://www.codeblocks.org/).



Excellent ide it even support MacOS and is way smaller than Eclipse or NetBean.

Also you can have language settings to edit files (i.e. lua, html, …).



In fact it could be a good "official" ide for MOAI :)



Only issue I had was that the step-by-step degbugger had 1 issue when debugging DLLs (difficulty to enter the dll in step-by-step mode).  And the only reason why I moved back to VisualC... but perhaps this issue is now resolved.
User avatar
lazalong
 
Posts: 3
Joined: Sun May 22, 2011 4:59 pm

Building on Linux

Postby luckysuga » Sun May 29, 2011 3:13 pm

In building on Windows(use Cygwin), a error occured 



moai-betaeclipselibmoailibcryptoobjlocalarmeabibuild.sh L15



ar rcs libcrypto.a "*.o"

-> not found error



So I removed "" from script

ar rcs libcrypto.a *.o



I succeed to build it.
luckysuga
 
Posts: 3
Joined: Fri May 27, 2011 1:16 am

Building on Linux

Postby todd » Mon May 30, 2011 4:24 am

Thanks - we'll check that out.
User avatar
todd
 
Posts: 262
Joined: Fri Mar 25, 2011 1:11 pm

Building on Linux

Postby paul.danset » Wed Jun 01, 2011 10:57 am

This is a temporary "solution" until we get a native Linux port, but FYI I've been able to run Moai SDK (e.g. WolfToss app) under Linux, using WINE.  Rough sketch of what I did for Ubuntu 10.10:


  • Install WINE:  


  $ sudo apt-get install wine


  • Download some missing VC++ DLLs that the moai.exe expects from M$ URL below, and install them:


  http://www.microsoft.com/downl.....layLang=en

  $ wine vcredist_x86.exe


  • Unpack the SDK / WolfToss app into the C: drive (in my case, ~/.wine/drive_c/Program Files/Moai SDK).

  • Run it:


  $ pwd

  /home/pengo/.wine/drive_c/Program Files/Moai SDK/samples/WolfToss/lua

  $ wine ../host-windows/moai.exe "config-all.lua" "config-windows.lua" "main.lua"



Cheers




User avatar
paul.danset
 
Posts: 6
Joined: Wed Jun 01, 2011 4:52 pm

Building on Linux

Postby b.lindeijer » Thu Jun 02, 2011 5:12 am

I've made a start by allowing Moai to be compiled with CMake (just on Linux for now). The patch can be found here:

https://github.com/bjorn/moai-beta/commit/4fbfd72903bd40c7529ed65e5f13933cd39b59af

Successful compilation also depends on the small fix committed before that, changing a GLUT/glut.h include to GL/glut.h, which seems to be the more common location.



Now, this might work on a 32-bit Linux system, but unfortunately I am on a 64-bit system. After I fixed u32 to be actually 32-bit (to fix an assertion on startup), the compiler is (rightfully) complaining about a large amount of casts from pointer to 32-bit integer. Some of these are simple printf statements where the cast is easy to remove, but there is also some strange magic going on like this:



src = ( void* )(( u32 )src + 2 );



So that's where I'm at, currently.

I've also tried to remove the assertion instead and let u32 just be 64-bit, but when I try to run one of the examples I just get an empty window (not even painted once) with 100% CPU usage.



Update:

I've just tried it on a virtual 32-bit Ubuntu machine, where I discovered I had forgotten to compile and link to expat (which had somehow just worked on my Arch Linux machine). I also documented the dependencies I needed to install.

On that machine images are showing up fine, but all samples seem to be just paused. Maybe something is missing regarding the timing.
I've amended my commit with the additional fixes and documentation (link above updated).


b.lindeijer
 
Posts: 12
Joined: Thu May 26, 2011 12:58 pm

Building on Linux

Postby paul.danset » Thu Jun 02, 2011 8:57 am

Awesome!  

I just got access to the beta source code June 1 and got to a similar point last night.  My approach was creating a bunch of hand crafted Makefiles, but I like your cmake approach better.

I could build the moai executable cleanly, but ran into the 64-bit runtime issue on my 64-bit Ubuntu 10.10 system:

pengo@toughbook:~/moai-beta$ make

/usr/bin/g++ -Isrc vs2010/moai/main.cpp

-Lsrc/aku -laku

-Lsrc/moaicore -lmoaicore

-Lsrc/uslsext -luslsext

-Lsrc/uslscore -luslscore

-L3rdparty/lua-5.1.3/lib -llua

-L3rdparty/box2d-2.1.2/Box2D/Build/Box2D -lBox2D

-L3rdparty/chipmunk-5.3.4/src -lchipmunk

-L3rdparty/contrib -lutf8

-lpthread -lglut -lGLEW -lssl -lcurl -lpng -lfreetype -lexpat -ltinyxml

-o moai




pengo@toughbook:~/moai-beta$ ./moai

moai: uslscore.cpp:23: void _typeCheck(): Assertion `sizeof ( u32 ) == 4' failed.

Aborted



I tried changing the u32 definition in uslscore/pch.h from a long to an int and recompiling, but then I get a problem in USLuaObject.cpp:


USLuaObject.cpp:54: error: cast from ‘USLuaObject*’ to ‘u32’ loses precision

I noticed there's a lot of 32-bit pointer arithmetic using u32 and the TODO in the code:

void USLuaObject::DebugDump () {
        // TODO: fix for 64 bit

        printf ( "0x%08X <%s> %s", ( uint )(( u32 )this ), this->TypeName (), this->ToString ().c_str ());



So I was going to try and redo the whole thing under 32-bit Linux …

Cheers

User avatar
paul.danset
 
Posts: 6
Joined: Wed Jun 01, 2011 4:52 pm

Building on Linux

Postby b.lindeijer » Thu Jun 02, 2011 9:10 am

Yeah the pointer to int casting could be a mess to clean up.

I've also noticed that some code really depends on u32 to be 32-bit, so hacking that to be 64-bit is not going to work (well it would have been a messy hack anyway). For example, the MOAIActionMgr uses the overflow point of the u32, incrementing from 0xffffffff and expecting it to go to 0. It won't on 64-bit, which was the reason I was just getting an empty window.
b.lindeijer
 
Posts: 12
Joined: Thu May 26, 2011 12:58 pm

Building on Linux

Postby patrick » Thu Jun 02, 2011 10:43 am

That's right. It's not the end of the world to get Moai 64-bit compliant, but it may take a little time. There are a lot of places that have a legitimate need for u32 but, as Bjørn pointed out, I haven't been very disciplined in casting for pointer arithmetic. I've been putting off the cleanup of that for a while, but it needs to be done.

Moving forward I'll make a point to start fixing that code as I find it.
User avatar
patrick
 
Posts: 589
Joined: Sat Apr 02, 2011 10:50 pm

Building on Linux

Postby paul.danset » Wed Jun 08, 2011 9:46 pm

I've made a little more progress.

Now I'm running a lightweight 32-bit Linux (Xubuntu 11.04) inside a VirtualBox VM.  The moai executable finally compiles cleanly and I can run the hello-moai as well as some other samples.



pengo@xubuntu:~/moai-beta/samples/hello-moai$ pwd

/home/pengo/moai-beta/samples/hello-moai

pengo@xubuntu:~/moai-beta/samples/hello-moai$ moai ../config/config.lua main.lua



The result of the command above is a window with an image of a cat.



However, I'm unable to get some of the interaction / animation / gfx samples to do much more than show the same static cat image.

Currently the only packages compiled in the 3rdparty directory are the ones below; the rest are native Ubuntu libraries.


  • box2d

  • chipmunk

  • lua

  • contrib (utf8)


Have any changes been made to libraries like GLUT / GLEW that I should be aware of?  Thanks.


User avatar
paul.danset
 
Posts: 6
Joined: Wed Jun 01, 2011 4:52 pm

Building on Linux

Postby b.lindeijer » Wed Jun 08, 2011 10:20 pm

@pengo

That's the same state my repository was already in on 32-bit Linux. Image shows, but animation doesn't run. Did you make any changes on top of the cmake build files I wrote or are you doing another build system?
b.lindeijer
 
Posts: 12
Joined: Thu May 26, 2011 12:58 pm

Building on Linux

Postby b.lindeijer » Thu Jun 09, 2011 9:24 am

Alright, it's working! For as far as I tested, at least (I tried some animation, font, box2d, chipmunk and simpleShader examples).


  • The 64-bit support required some monkeying around after introducing uintptr/sintptr, which I introduced to represent integer types that are the size of a pointer, to replace the s32 and u32 in the right places. I've also adapted the printf statements. I didn't verify yet whether it still works on 32-bit, maybe somebody can do that for me.

  • Then I fixed the timer code. Or actually, I just removed it, since the implementation used for Linux was a broken version of the one used for Android (see the commit for details).

  • Finally I fixed one example for case-sensitive file systems. :)


The patches are ready for review. I hope they can be merged, but of course somebody should go over them and also it should be tested that it doesn't break anything on Mac, Windows, iPhone or Android...



Code is here:

 https://github.com/bjorn/moai-beta/commits/master
b.lindeijer
 
Posts: 12
Joined: Thu May 26, 2011 12:58 pm

Building on Linux

Postby patrick » Thu Jun 09, 2011 10:53 am

That's awesome!

We're slammed at the moment, but I'll try to get this reviewed and merged in before open beta.

Thanks!
User avatar
patrick
 
Posts: 589
Joined: Sat Apr 02, 2011 10:50 pm

Building on Linux

Postby paul.danset » Thu Jun 09, 2011 12:29 pm

Thanks Bjørn!  

Last week I had problems building from your git repo, but this time everything built smoothly under Ubuntu 10.10 64-bit.

I ran all the examples under the samples/basic directory:

$ cd samples/basic

$ for i in *; do echo $i; pushd $i; moai ../../config/config.lua main.lua ; popd; done





The following directories caused a segfault for the same minor "TTF" vs "ttf" case sensitivity issue you found in the font-ttf directory:


  • font-colors

  • textBox-spool

  • textBox-alignment

  • textBox-paging

  • textBox-curves


The util-xml caused a more serious problem:

pengo@toughbook:~/moai-beta/samples/basics/util-xml$ moai ../../config/config.lua main.lua

*** glibc detected *** moai: free(): invalid pointer: 0x0000000000919208 ***

======= Backtrace: =========

/lib/libc.so.6(+0x774b6)[0x7fd9c18d54b6]

/lib/libc.so.6(cfree+0x73)[0x7fd9c18dbc83]

/usr/lib/libstdc++.so.6(_ZNSsD1Ev+0x39)[0x7fd9c2117049]

moai(_ZN13TiXmlDocumentD1Ev+0x2a)[0x536baa]

moai(_ZN13MOAIXmlParser10_parseFileEP9lua_State+0x10f)[0x58b94f]

/usr/lib/liblua5.1.so.0(+0xcbc1)[0x7fd9c2c14bc1]

/usr/lib/liblua5.1.so.0(+0x17959)[0x7fd9c2c1f959]

/usr/lib/liblua5.1.so.0(+0xd08d)[0x7fd9c2c1508d]

/usr/lib/liblua5.1.so.0(lua_call+0x26)[0x7fd9c2c10396]

moai(_ZN10USLuaState9DebugCallEii+0x2a)[0x64edfc]

moai(_ZN7MOAISim7RunFileEPKc+0xc7)[0x56da2d]

moai(_Z12AKURunScriptPKc+0x20)[0x4fb2cc]

moai(_Z7AKUGlutiPPc+0x10b)[0x4faa05]

moai(main+0x20)[0x4fa5e4]

/lib/libc.so.6(__libc_start_main+0xfe)[0x7fd9c187cd8e]

moai[0x4fa509]

======= Memory map: ========

00400000-0070b000 r-xp 00000000 08:01 787277                             /usr/local/bin/moai

0090b000-0090c000 r--p 0030b000 08:01 787277                             /usr/local/bin/moai

0090c000-0090d000 rw-p 0030c000 08:01 787277                             /usr/local/bin/moai

0090d000-0091a000 rw-p 00000000 00:00 0 

01937000-019e0000 rw-p 00000000 00:00 0                                  [heap]

7fd9b8000000-7fd9b8021000 rw-p 00000000 00:00 0 

7fd9b8021000-7fd9bc000000 ---p 00000000 00:00 0 

7fd9bccb7000-7fd9bccba000 r-xp 00000000 08:01 523350                     /lib/libgpg-error.so.0.4.0

7fd9bccba000-7fd9bceb9000 ---p 00003000 08:01 523350                     /lib/libgpg-error.so.0.4.0

7fd9bceb9000-7fd9bceba000 r--p 00002000 08:01 523350                     /lib/libgpg-error.so.0.4.0

7fd9bceba000-7fd9bcebb000 rw-p 00003000 08:01 523350                     /lib/libgpg-error.so.0.4.0

7fd9bcebb000-7fd9bcebe000 r-xp 00000000 08:01 530927                     /lib/libuuid.so.1.3.0

7fd9bcebe000-7fd9bd0be000 ---p 00003000 08:01 530927                     /lib/libuuid.so.1.3.0

7fd9bd0be000-7fd9bd0bf000 r--p 00003000 08:01 530927                     /lib/libuuid.so.1.3.0

7fd9bd0bf000-7fd9bd0c0000 rw-p 00004000 08:01 530927                     /lib/libuuid.so.1.3.0

7fd9bd0c0000-7fd9bd0c5000 r-xp 00000000 08:01 657819                     /usr/lib/libXdmcp.so.6.0.0

7fd9bd0c5000-7fd9bd2c4000 ---p 00005000 08:01 657819                     /usr/lib/libXdmcp.so.6.0.0

7fd9bd2c4000-7fd9bd2c5000 r--p 00004000 08:01 657819                     /usr/lib/libXdmcp.so.6.0.0

7fd9bd2c5000-7fd9bd2c6000 rw-p 00005000 08:01 657819                     /usr/lib/libXdmcp.so.6.0.0

7fd9bd2c6000-7fd9bd2c8000 r-xp 00000000 08:01 657808                     /usr/lib/libXau.so.6.0.0

7fd9bd2c8000-7fd9bd4c7000 ---p 00002000 08:01 657808                     /usr/lib/libXau.so.6.0.0

7fd9bd4c7000-7fd9bd4c8000 r--p 00001000 08:01 657808                     /usr/lib/libXau.so.6.0.0

7fd9bd4c8000-7fd9bd4c9000 rw-p 00002000 08:01 657808                     /usr/lib/libXau.so.6.0.0

7fd9bd4c9000-7fd9bd53d000 r-xp 00000000 08:01 523346                     /lib/libgcrypt.so.11.5.3

7fd9bd53d000-7fd9bd73d000 ---p 00074000 08:01 523346                     /lib/libgcrypt.so.11.5.3

7fd9bd73d000-7fd9bd73e000 r--p 00074000 08:01 523346                     /lib/libgcrypt.so.11.5.3

7fd9bd73e000-7fd9bd741000 rw-p 00075000 08:01 523346                     /lib/libgcrypt.so.11.5.3

7fd9bd741000-7fd9bd751000 r-xp 00000000 08:01 658672                     /usr/lib/libtasn1.so.3.1.9

7fd9bd751000-7fd9bd950000 ---p 00010000 08:01 658672                     /usr/lib/libtasn1.so.3.1.9

7fd9bd950000-7fd9bd951000 r--p 0000f000 08:01 658672                     /usr/lib/libtasn1.so.3.1.9

7fd9bd951000-7fd9bd952000 rw-p 00010000 08:01 658672                     /usr/lib/libtasn1.so.3.1.9

7fd9bd952000-7fd9bd969000 r-xp 00000000 08:01 657779                     /usr/lib/libICE.so.6.3.0

7fd9bd969000-7fd9bdb68000 ---p 00017000 08:01 657779                     /usr/lib/libICE.so.6.3.0

7fd9bdb68000-7fd9bdb69000 r--p 00016000 08:01 657779                     /usr/lib/libICE.so.6.3.0

7fd9bdb69000-7fd9bdb6a000 rw-p 00017000 08:01 657779                     /usr/lib/libICE.so.6.3.0

7fd9bdb6a000-7fd9bdb6d000 rw-p 00000000 00:00 0 

7fd9bdb6d000-7fd9bdb75000 r-xp 00000000 08:01 657800                     /usr/lib/libSM.so.6.0.1

7fd9bdb75000-7fd9bdd74000 ---p 00008000 08:01 657800                     /usr/lib/libSM.so.6.0.1

7fd9bdd74000-7fd9bdd75000 r--p 00007000 08:01 657800                     /usr/lib/libSM.so.6.0.1

7fd9bdd75000-7fd9bdd76000 rw-p 00008000 08:01 657800                     /usr/lib/libSM.so.6.0.1

7fd9bdd76000-7fd9bdd91000 r-xp 00000000 08:01 658769                     /usr/lib/libxcb.so.1.1.0

7fd9bdd91000-7fd9bdf91000 ---p 0001b000 08:01 658769                     /usr/lib/libxcb.so.1.1.0

7fd9bdf91000-7fd9bdf92000 r--p 0001b000 08:01 658769                     /usr/lib/libxcb.so.1.1.0

7fd9bdf92000-7fd9bdf93000 rw-p 0001c000 08:01 658769                     /usr/lib/libxcb.so.1.1.0

7fd9bdf93000-7fd9bdf95000 r-xp 00000000 08:01 523358                     /lib/libkeyutils.so.1.3

7fd9bdf95000-7fd9be194000 ---p 00002000 08:01 523358                     /lib/libkeyutils.so.1.3

7fd9be194000-7fd9be195000 r--p 00001000 08:01 523358                     /lib/libkeyutils.so.1.3

7fd9be195000-7fd9be196000 rw-p 00002000 08:01 523358                     /lib/libkeyutils.so.1.3

7fd9be196000-7fd9be19d000 r-xp 00000000 08:01 655750                     /usr/lib/libkrb5support.so.0.1

7fd9be19d000-7fd9be39c000 ---p 00007000 08:01 655750                     /usr/lib/libkrb5support.so.0.1

7fd9be39c000-7fd9be39d000 r--p 00006000 08:01 655750                     /usr/lib/libkrb5support.so.0.1

7fd9be39d000-7fd9be39e000 rw-p 00007000 08:01 655750                     /usr/lib/libkrb5support.so.0.1

7fd9be39e000-7fd9be3a1000 r-xp 00000000 08:01 523317                     /lib/libcom_err.so.2.1

7fd9be3a1000-7fd9be5a0000 ---p 00003000 08:01 523317                     /lib/libcom_err.so.2.1

7fd9be5a0000-7fd9be5a1000 r--p 00002000 08:01 523317                     /lib/libcom_err.so.2.1

7fd9be5a1000-7fd9be5a2000 rw-p 00003000 08:01 523317                     /lib/libcom_err.so.2.1

7fd9be5a2000-7fd9be5c6000 r-xp 00000000 08:01 654526                     /usr/lib/libk5crypto.so.3.1

7fd9be5c6000-7fd9be7c6000 ---p 00024000 08:01 654526                     /usr/lib/libk5crypto.so.3.1

7fd9be7c6000-7fd9be7c7000 r--p 00024000 08:01 654526                     /usr/lib/libk5crypto.so.3.1

7fd9be7c7000-7fd9be7c8000 rw-p 00025000 08:01 654526                     /usr/lib/libk5crypto.so.3.1

7fd9be7c8000-7fd9be881000 r-xp 00000000 08:01 655429                     /usr/lib/libkrb5.so.3.3

7fd9be881000-7fd9bea80000 ---p 000b9000 08:01 655429                     /usr/lib/libkrb5.so.3.3

7fd9bea80000-7fd9bea89000 r--p 000b8000 08:01 655429                     /usr/lib/libkrb5.so.3.3

7fd9bea89000-7fd9bea8a000 rw-p 000c1000 08:01 655429                     /usr/lib/libkrb5.so.3.3

7fd9bea8a000-7fd9beb25000 r-xp 00000000 08:01 658192                     /usr/lib/libgnutls.so.26.14.12

7fd9beb25000-7fd9bed25000 ---p 0009b000 08:01 658192                     /usr/lib/libgnutls.so.26.14.12

Aborted



I'll run the same tests on my 32-bit VM next.  Cheers


User avatar
paul.danset
 
Posts: 6
Joined: Wed Jun 01, 2011 4:52 pm

Building on Linux

Postby paul.danset » Thu Jun 09, 2011 2:17 pm

Curiously under 32-bit Xubuntu 11.04 (as opposed to 64-bit Ubuntu 10.10), the TTF vs ttf case sensitivity segfault did not occur.  The demos that required the TTF files worked fine.

util-xml still causes a similar stack trace (invalid pointer) under 32-bit as it did for 64-bit.

All the rest of the demos in samples/basic seemed to work fine.



For fun, I tried running WolfToss under 64-bit Linux.  Results:


  • The Moai logo screen and the WolfToss splash screen come up fine.

  • The "High Scores" screen comes up fine.

  • When you hit the "Play" button, you get a "LOADING" and a crash:


pengo@toughbook:~/WolfToss/lua$ moai config-all.lua config-windows.lua main.lua

res: using new "spritedeck.backgroundForest"

rig-background-forest.lua:74: attempt to call method 'setFrameSource' (a nil value)

stack traceback:

rig-background-forest.lua:74: in main chunk

(tail call): ?

(tail call): ?

level-forest.lua:7: in main chunk

(tail call): ?

level-001.lua:18: in main chunk

(tail call): ?

scene-gameplay.lua:70: in main chunk

(tail call): ?

(tail call): ?

main.lua:140: in function



I believe this is not a problem with the Linux port of moai; I believe WolfToss was compiled with an older version of Moai SDK and is making a call to the presumably deprecated method setFrameSource().  I see setFrameSource in the moai DLL that came with WolfToss, but I see no setFrameSource in the current git source tree.





UPDATE:  Simply commenting out the calls to setFrameSource() in the files below let me run WolfToss natively under 64-bit Linux  Smile


  • rig-background-forest.lua

  • rig-keyboard.lua

  • sys-elem.lua



User avatar
paul.danset
 
Posts: 6
Joined: Wed Jun 01, 2011 4:52 pm

Next

Return to Moai SDK

Who is online

Users browsing this forum: No registered users and 1 guest

x