LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-11-2006, 01:00 PM   #1
pdeman2
Member
 
Registered: Jul 2005
Location: Maine, USA
Distribution: OpenSUSE, Gentoo, Fedora, Ubuntu, Mandriva, others
Posts: 413

Rep: Reputation: 30
Creating programs for Mac in Linux?


Is it possible to compile C code in linux using gcc so that it can be executed on Mac OS X?
 
Old 02-11-2006, 01:17 PM   #2
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
I think what you're asking about is called "cross-compiling".

When you compile C code, you're creating machine instructions for a given hardware platform. The default for gcc is to create binaries for the hardware it's currently running on. You can pass it options to generate binaries for other hardware platforms. See "man gcc" for more details. Not sure if it's the same thing, but GNU/Linux on x86 uses ELF binaries (which, I think, is the "format" of the binary gcc produces -- how the code is actually laid out in the binary file). Macs (well, PPC macs at least) don't use ELF.

Now, the matter of linking to libraries is a different animal. It's complicated on a Mac -- OS X is built upon FreeBSD (well, I think it's actually a BSD compatibility layer upon Mach -- not sure), so they should use regular .so and .a libs, but they also have this totally separate and distinct OS X- (NeXT- ?) style thing where libs are named ".dylib"... well, it's complicated.

I'd suggest, either just do your development on the Mac to make Mac software, or else look into the possibility of making your app web-based, run it on a GNU/Linux server, then just access it from the Mac. Of course, you could still dig in and learn some more about getting gcc to do what you want. The newsgroup gnu.gcc.help ( http://groups.google.com/group/gnu.gcc.help ) may be of some assistance if you go that route.
 
Old 02-11-2006, 01:54 PM   #3
pdeman2
Member
 
Registered: Jul 2005
Location: Maine, USA
Distribution: OpenSUSE, Gentoo, Fedora, Ubuntu, Mandriva, others
Posts: 413

Original Poster
Rep: Reputation: 30
Thanks for the information. I'll do some deeper research and try to use cross-compiling.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mac programs on Linux Oxagast Linux - Software 4 03-14-2006 06:45 PM
x86 Mac OS X Programs on Linux, soon? tsphan Linux - Software 4 11-21-2005 09:06 AM
Are there linux programs for creating simple animated video scenes? calimer Linux - Software 0 12-02-2004 11:44 AM
Creating shortcuts to programs piggysmile Linux - Software 3 05-27-2004 08:43 AM
Creating HFS part in Redhat for storage of mac files jang Linux - General 0 07-01-2003 10:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration