Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Cross-Platform Compilation  (Read 2844 times)

0 Members and 1 Guest are viewing this topic.

SMURF4o0o

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Cross-Platform Compilation
« on: May 08, 2014, 04:16:50 pm »
Hi,
First I want to say my big thanks to the team of SFML as the library is amazing and reduced my time developing significantly. I am kind of new to C++ development, so I am sorry if my question is somewhat misplaced. Now to the point:

I have developed a small C++ GUI application with SFML + Code Block under Windows 7 Home Premium statically. All works perfectly.

My current task is compiling it so work under Mac.  Installing a Mac for the compilation is out of the option, I am sorry to say, due to funding limitations. Is there a way I can compile my code for that OS,  my compiler is MinGW32 with a g++ version 4.8. I've heard of some cross-compilation techniques, but haven't had any luck finding a step by step instructions on how to achieve my goal. I imagine I need to link the dylib that come with the Mac archive, but the compiler says:

File format not recognized

Any help would be greatly appreciated.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Cross-Platform Compilation
« Reply #1 on: May 08, 2014, 04:31:36 pm »
You could perhaps use a virtual machine (VirtualBox is free). Then you just need a copy of OS X, not the Mac hardware.

SMURF4o0o

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Cross-Platform Compilation
« Reply #2 on: May 08, 2014, 04:36:21 pm »
I am sorry for the misunderstanding, when I was referring to Mac I was referring to the operating system. My goal is under Windows or Linux to be able to compile a file to be able to run on MacOS (without the need of Wine or similar).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Cross-Platform Compilation
« Reply #3 on: May 08, 2014, 04:45:59 pm »
Running OS X on non Apple hardware (e.g. Virtual Box) is illegal but doable as long as you have an Intel CPU.

How much time did you spend researching this topic? What have your findings turned up so far?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Cross-Platform Compilation
« Reply #4 on: May 08, 2014, 04:56:52 pm »
Running OS X on non Apple hardware (e.g. Virtual Box) is illegal but doable as long as you have an Intel CPU

One has to be really careful: in the past some people had issue with SFML on Hackintosh that didn't happen on Mac... I assure the same can happen when virtualising OS X on Win/Unix.
SFML / OS X developer

SMURF4o0o

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Cross-Platform Compilation
« Reply #5 on: May 08, 2014, 05:00:21 pm »
I've been looking on this topics for about a week now.
I would classify my results as 3 types of rumors:

1.) Can't be done. Just use dedicated software/hardware or both to compile. This would require a lot of computational power and/or financials with I am trying to avoid.
2.) Use Virtual machines and do pretty much the same basically compile it under each and every operating system you are trying to use it. Which is really not suitable as in the next stages I will be trying to automate the process (since it will be like a stand alone image gallery) and having to load VMware compile for all for each snippet of images seems kind of an overkill.
3.) Heard rumors of having a cross-compiler. Here things become a little dodgy. As far as I understand this means compiling your own compiler?!?!. And the information/articles/tutorials seem quite unclear on how that compilation happens and how it is used afterwards.

So after all this I thought I could just try and 'trick' my own compiler by renaming the dylib (the Mac libraries) to '.a' - as are in the Windows archive. So they compile and have everything needed to run under MacOS, sadly, but as expected it doesn't work.

I am aware that Apple are kind of picky about who and how develops products for their OS. But I picked C++ because of its native support on the different operating systems and now it seems it does me no good.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Cross-Platform Compilation
« Reply #6 on: May 08, 2014, 05:11:34 pm »
One has to be really careful: in the past some people had issue with SFML on Hackintosh that didn't happen on Mac... I assure the same can happen when virtualising OS X on Win/Unix.
Well that's to be expected imho. It's called Hackintosh after all for a reason! ;)

So after all this I thought I could just try and 'trick' my own compiler by renaming the dylib (the Mac libraries) to '.a' - as are in the Windows archive. So they compile and have everything needed to run under MacOS, sadly, but as expected it doesn't work.
Well that's pretty silly... ::)

There's a forth option, using some continuous integration software and let someone else build your application. This of course will become rather tedious if you run into bugs on OS X.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SMURF4o0o

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Cross-Platform Compilation
« Reply #7 on: May 08, 2014, 05:17:01 pm »
@eXpl0it3r:
I know its sully, but you know how they say: Desperate times call for desperate measures. I would really love to keep the project enclosed (my own little creation) as I imagine with time it could blow up out of proportions.

Have you encountered anything similar? How would you approach such a problem?
Thanks

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Cross-Platform Compilation
« Reply #8 on: May 08, 2014, 09:47:15 pm »
My personal experience setting up a Mac VM was as follows:

No VM software out there directly supports it, because it's illegal.  So first you have to find an .iso and a corresponding tutorial that is *not* out of date, which took me a stupidly long time.  If you're really lucky it'll be for a version of OS X you actually want to support.

Once I found one that worked at all, it actually worked surprisingly decently.  It did have no sound whatsoever, and if I clicked certain things in the system menus the VM would have a seizure, but I could build and run SFML programs and even distribute binaries of my programs to someone who owned a real Mac, who then confirmed that everything (including audio!) worked fine for him.  Though he did say it ate a ton of CPU...

However, I'm also under the impression that my laptop has been less stable and performant ever since I started using these VMs on it, though of course it's impossible to prove such a thing.


For cross-compiling, my impression is that it's only ever used in the context of mobile development, because you need to develop the game on a non-mobile device.  I was unable to find anything for cross-compilation between desktop OSes that looked remotely promising.


In the long run, I expect I'll probably end up buying a real Mac someday.

 

anything