Can Xcode be used to compile C++ programs for a Mac from a Linux system?

  • Context: C/C++ 
  • Thread starter Thread starter daniel_i_l
  • Start date Start date
  • Tags Tags
    Mac Programs Writing
Click For Summary

Discussion Overview

The discussion centers around the feasibility of compiling C++ programs on a Linux system for use on a Mac, specifically addressing the challenges and considerations involved in cross-compilation and the tools available on both platforms.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses the need to compile a simple C++ application on Linux for a friend using a Mac, seeking a straightforward solution.
  • Another participant asserts that generally, code compiled on Linux cannot run on a Mac, suggesting that the Mac user should compile the code directly on their machine using the GNU compiler collection.
  • A participant questions whether compiling with gcc on Linux would work on Unix systems, citing a past experience with Solaris and Ubuntu.
  • One reply references cross-compilation and suggests using gcc on the Mac as a simpler alternative to avoid complications.
  • Another participant provides information about Xcode, mentioning that it is Apple's development suite and may include GCC, indicating it could compile basic C++ code for terminal use, while also noting the existence of cross-platform GUI frameworks.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to compile the C++ application for Mac, with differing views on the feasibility of cross-compilation and the use of Xcode versus compiling directly on the Mac.

Contextual Notes

There are unresolved assumptions regarding the compatibility of compiled binaries between Linux and Mac systems, as well as the specific requirements for using Xcode and its components.

daniel_i_l
Gold Member
Messages
864
Reaction score
0
I use linux on a pc and one of my friends who uses a mac wants me to write a small app for him. It doesn't need any GUI of anything, just a few lines in C++ with a bitmap image for input and an output to a text file.
Is there a way for me to compile it in linux so that he'll be able to use it with his mac? He isn't very computer literate so I don't want him to have to do a lot of tweaking.
Thanks.
 
Technology news on Phys.org
In general, you cannot compile it on a Linux machine and then run it on a Mac. The Mac should already have the GNU compiler collection installed on it, though, so you should be able to compile it on the Mac with the same commands you would use on the Linux box.

- Warren
 
If you compile using gcc on the linux box, should it not work on unix since the two are similar?

I remember running a small program on Solaris that was compiled in ubuntu.
 
XCode is Apple's Development Suite (free through Apple Developer, and I think it's still included--but not installed--on the OS X DVD, up to Leopard, OS X 10.5)
http://en.wikipedia.org/wiki/Xcode
http://developer.apple.com/TOOLS/xcode/

I think (but am not positive) that it includes GCC, and a whole lot of other things. However, it should be able to compile your (very basic, and non-system specific) C++ code to at least a terminal program. Barring that, there're Widgets like QT, wxWidgets, and GTK+ which would allow you to develop cross-platform (to a point) GUI programs.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 13 ·
Replies
13
Views
31K
  • · Replies 14 ·
Replies
14
Views
35K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
Replies
3
Views
4K