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

Click For Summary
Compiling C++ programs on a Linux system for use on a Mac is generally not feasible due to compatibility issues. It is recommended to compile the code directly on the Mac, which typically has the GNU compiler collection (GCC) installed or can be easily set up via Xcode. Using Xcode, which is available for free from Apple, allows for straightforward compilation of basic C++ code. While cross-compilation is theoretically possible, it is often more complex and error-prone. For cross-platform GUI applications, frameworks like QT, wxWidgets, and GTK+ can be considered.
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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

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