Compiling on Mac

BlitzMax Forums/BlitzMax Beginners Area/Compiling on Mac

Arabia(Posted 2013) [#1]
Got access to a Mac and decided to see if what I was working on would look like. I know zero about Mac's, so this is probably a simple thing. When I try to compile I'm getting the following error:

Building untitled1
Compiling:untitled1.bmx
sh: as: command not found
Build Error: Failed to assemble /Users/username/Downloads/BlitzMax/tmp/.bmx/untitled1.bmx.gui.debug.macos.x86.s
Process complete

I'm not even sure if I've installed BM correctly, I just downloaded, and ran the file - I couldn't see how to unzip the files as you do in Windows. Also remember reading some stuff about xcode - is this something I need?


xlsior(Posted 2013) [#2]
es, you need to download and install xcode -- and after installing it, you need to go in there and install the command line tools as well.

Not sure if there are any specific version limitations/requirements, but if you search the forums you'll probably find the info...


Arabia(Posted 2013) [#3]
Thanks very much. Downloading now, stand by for my silly questions when I still can't get it working :)


Arabia(Posted 2013) [#4]
Okay, got it all working. Still trying to find my way around these weird arse Mac's :)

It all compiles, doing a couple of funny things and getting the occasional weird flicker where I'm drawing some of my graphics - using SetAlpha for some objects, is this an issue? works fine on the PC.

Other than that, it works pretty much the as intended - I can worry more about sorting out Mac issues when the game is finished.

One last question - where does the compiled code get placed? I'm just running the code from a USB drive at the moment, and after compiling there are no new files on the drive that.


d-bug(Posted 2013) [#5]
An *.app file is a bundle including the compiled binary in the subfolder YourApp.app/Contents/MacOS/. (You can see it by using "Showing Package Contents" in Finder's context menu on your app). When the binary was compiled the one in the bundle is exchanged by the fresh one. The file date of your app should have changed but the file count on your drive keeps the same.


AdamStrange(Posted 2013) [#6]
You also need to do a full module compile to get it to play nice with osx :)


Brucey(Posted 2013) [#7]
The file date of your app should have changed

Not always. Sometimes it stays the same, and only the contents of the bundle change.


Arabia(Posted 2013) [#8]
Thanks guys, I think I got it sorted. I was compiling it from the same directory that I had already compiled the PC version - so it either didn't like to overwrite the old file or it did so without changing the date on the file.

This was only a really early test just to see if I could get my program working on the Mac, unfortunately I don't have access to this Mac very often so I'd more than likely try to find a Mac user here to compile stuff in the future for me.


Arabia(Posted 2013) [#9]
Hoping I've got it right, perhaps a Mac person could test the download and tell me if the app runs:

http://www.mediafire.com/download/0y888irwxxvb2ra/tmc_mac_beta_1.zip

PC version is here too:

http://www.mediafire.com/download/sgzaqr3wx40m3r7/tmc_pc_beta_1.zip

I won't post full instructions. Basically it's a little cricket sim I've been working on for years.

Press S to start
Press Y/N to make batsman run when prompted (upper left of window)
Press ENTER to bowl a new ball
Press F1 for scoreboard

To exit, press ESC immediately after pr essing ENTER for a new ball. This is a very early version, only really uploaded this to see if I could get the Mac version working while I had access to one.

Doesn't look as nice on the Mac - known issue - I've hard coded the location of the Arial font \windows\fonts - didn't know where they were kept on a mac and how exactly to do this, conditional compilation?

Mac users will notice ugly flashing and some text over writing on the right hand side of the screen where the batsman & bowlers details are shown - this doesn't happen on the PC version - any ideas what I could be doing wrong Mac people?


Brucey(Posted 2013) [#10]
The flicker is probably due to the way you are incorrectly using the buffer. It almost looks like you are drawing stuff before one flip, but not drawing the same stuff before the next flip?

Are you not doing something like :
While looping

Handle events

Cls

Draw stuff

Flip

Wend


Where you are drawing *everything* on each iteration.
Your "Draw stuff" can obviously choose to draw different things based on some state.

If you want to save some space with your audio, you can convert them to .ogg format.
You may also want to put your images and stuff into a different folder than the executable, or even embed them in the app itself (using Incbin).
On Mac, it creates what is called an App Bundle, which is a folder, where you can also store all the application's resources (images, audio, etc).

You could embed the font too, perhaps, using Incbin.


Arabia(Posted 2013) [#11]
I had a feeling it was something to do with the draw order Brucey - I'll look into a bit more - weird that it only happens on the Mac though.

I was going to ask about converting to .ogg too - I've got a decent audio editor which should allow me to convert easily - the main crowd sample was 34mb on it's own and is a 3min sample - I could probably just cut this sample down to a minute too.

And yes, the plan was to IncBin the graphics & sound samples when I'm getting closer.

Thanks for downloading it, and glad it worked (i.e. I didn't stuff anything up too much).


Arabia(Posted 2013) [#12]
Just thinking about the display issues with the Mac - I'm pretty sure I have the Flip's in the right places, but I will have to double check this. Couple of things that come to mind which could possibly be Mac issues that I'm unaware of:

1. I'm not using SetGraphicsDriver - Should I be? I'm simply starting my program using Graphics 1350,710,0.

2. I had issues with extremely slow performance when I was drawing everything, I solved this issue by using SetViewPort to only redraw the part of the screen that I was updating. Are there issues with using this that I'm unaware of?

It's really only if there are issues with the above points regarding the Mac, as previously stated it works fine on the PC (using both a fairly high end graphics card and also a rather crappy onboard laptop graphics card)


xlsior(Posted 2013) [#13]
I'm not using SetGraphicsDriver - Should I be?


Doesn't matter, on Mac you can only use OpenGL, and it will default to that.

(On windows it will default to DirectX unless you specify otherwise)

I solved this issue by using SetViewPort to only redraw the part of the screen that I was updating. Are there issues with using this that I'm unaware of?


Possibly, in that:
1) There is no guarantee that the parts of the screen that you didn't redraw will be there after the flip, it depends on the video driver. The OpenGL standard says that you can't count on the picture remaining.

and more likely:
Depending on the video card and drivers you are using, the screen can use anywhere from 1 to 4 backbuffers... Meaning that when you draw & flip, the next backbuffer that presents itself to you to draw on for the next flip *may* be the same, or it could contain the contents of the screen 2 flips ago.. or 3 flips, or 4 flips... Which could cause flickering since there are likely differences in areas of the screen that you are not currently focussing on.
(Esentially the video may continuously rewind itself a few frames, resulting in a stuttery appearance)

To ensure that a game works on *all* computers and doesn't run into those issues, you really should redraw the entire screen each frame.

Note that it's not a mac-only issue: one of my previous windows PC's cycled through three backbuffers, while my laptop used two, and another Pc used just one. Unfortunately your mileage may vary.

(Which is why ideally you should test your programs on multiple machines with different hardware, so hopefully those kind of issues pop up during testing and not after you release your game)


Arabia(Posted 2013) [#14]
Thanks for the info Xlsior, I was not aware of any of that info. I'll hopefully get a chance to do some more today, so I will definitely have a look at getting rid of my SetViewPort code - I didn't really want to use it in the first place - it was more of a solution to some pretty sloppy coding.

I no longer have access to a Mac that I can compile on - any one on the forum willing to do a compile for me?


Brucey(Posted 2013) [#15]
any one on the forum willing to do a compile for me?

I can do Mac builds and testing for you if you like? (contact details in my profile).


Arabia(Posted 2013) [#16]
Thanks Brucey, you're a champ :) I'll get in contact when I'm ready. Don't look at my code to closely, my inefficient/unstructured code will probably make someone of your skill physically ill.

I haven't looked any of the code regarding drawing/setviewport yet which might be causing the Mac issues, when I've done that I'll get in contact.

Took your advice on converting WAV to OGG and it shrank a 34mb to less than 4mb, so that will make things a lot smaller too.


Arabia(Posted 2013) [#17]
Haven't touch a Mac for a few weeks now.

I'm at a public library where they have Mac's everywhere, just wondering if someone can tell me where to look to confirm if XCode & Command Line Tools are installed? I'm guessing these public machines won't allow me to install this stuff if it's not already on them - but being a University I'd be hoping that this stuff is already installed since I.T. students would possibly be using them to write code in some other language on them.

Do all programming languages on the Mac require XCode & Command Line Tools to be installed? or is this something particular to only certain languages?


xlsior(Posted 2013) [#18]
In finder: Go -> Applications
xcode should be listed as an installed application there if it is on the machine.

To see if the command line tools are installed:
- open XCode
- go to the xcode pull-down menu at the top of the screen
- Preferences
- Go to the downloads tab
- Components
- See if command line tools are installed (you can install from there if they aren't)


Arabia(Posted 2013) [#19]
Thanks Mate.