Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can I Compile my existing C++ Code to run in os-mac asnd linux?

Best reguards
abzadeh
Posted

I'd think that would depend on whether you used any Windows-specific stuff in your existing code.

[EDIT] In the end, after you've looked for whether your app is Windows-specific, all you can do is try to compile it on the platform of your choice and see whether it succeeds or fails. If you find failure points in compilation or in execution, you have to figure out why and whether you're doing something that can be made to work cross-platform. Depending on how much goes wrong, this could be quite time-consuming.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 13-Apr-11 12:01pm    
That's basically is the main issue, my 5.
--SA
mr.abzadeh 13-Apr-11 12:12pm    
Can you tell me an example of windows-specific stuff? and which compiler should I use if I have not used it in my existing code?

Thanks in advance
abzadeh
Marc A. Brown 13-Apr-11 12:19pm    
This (http://msdn.microsoft.com/en-us/library/ff381399(v=vs.85).aspx) should give you a start on the Win-specific stuff. It's a tutorial on C++ programming for Windows. I would think the compiler you use would depend on the platform. the GNU compiler collection is used heavily on Linux, though I don't know enough to recommend it vs. some other solution. I don't know what you'd use on OSX or whether there's a compiler that would give good results across platforms.
mr.abzadeh 13-Apr-11 12:32pm    
I will study the article you noticed to me, and does linux and os-mac use messaging in a way similar to windows sh that I convert my code?
Sergey Alexandrovich Kryukov 13-Apr-11 12:19pm    
We're talking not about compiler. Everything related Windows OS. Not Windows specific is just calculations, file system I/O, console I/O, sockets, etc., that is, the stuff common for most systems, Posix... Windows UI with messaging system, System Services, System Managements, COM/ActiveX, all Windows API -- Windows-specific.
--SA
Answering the follow-up Question: new UI for Windows, Linux and Mac.

First, there are several different platforms for Linux; all is based on X-Windows, on top of it there is one or another Windows Manager with their APIs (KDE, Gnome), there is multi-platform Qt and Gtk+ (both available on Windows as well, can be a good point for your) and finally, and CLI-based: .NET (on Windows), Mono — many other platforms). .NET/Mono is based in CLI, ECMA and ISO standard, so this is most solid, but this is much more than UI, this is manages memory, IL JIT-compiled code, lots of goodies, big part if it is Windows-specific, but even non-standard parts are vastly supported by Mono. .NET/Mono can use shared libraries written on native platform, so this will work for you.

So, you could do Windows + Linux + Mac +more development in first place if you used from the very beginning for UI one of the following: Qt, Gtk+, .NET, Mono, .NET + native or Mono + native. If you did so, you would be Linux-ready by now. Also, you could use .NET + native C++ in two ways: 1) Native C++ DLLs linked to .NET applications using P/Invoke, 2) Mixed-mode (managed+unmanaged) C++ and C++/CLI project which can mix up two words an easily interoperate in the same project and same executable module; it would be able to play dual role: main module of .NET Assembly and native DLL.

What can you do now? You can start Linux-ready development using Windows. This approach will be the most convenient for you. You certainly need to keep all your universal and application-specific code in its native form and isolated from UI. You can do all development on Windows and test it on Linux (or other OS) on a regular basis. First you need to choose main platform for UI application: managed or native and for native, chose from Qt or Gtk. I cannot advise which one to pick up for native platform as I moved to managed long time ago and never developed with Qt, Gtk, Gnome or something like that (I developed on Linux long time ago, before those APIs were created and later developed only for Mono). For .NET/Mono, you also should choose from the same platforms, plus you can develop using System.Windows.Forms. I do this, and my applications are run on Linux without recompilation. For native (but portable) project you would need to recompile it all in each platform, of course. .NET/Mono complies in byte-code (IL) and finally compiles for native CPU codes only during run-time, on per-method basis.

Maybe, you did not even hope for multi-platform application. I would not advice you to switch to Linux completely. If you used to Windows, it’s much better to stay with it and prefer multi-OS UI. As I tried to explain, this is quite feasible.

So, what can you say? Decisions, decisions…

—SA
 
Share this answer
 
Comments
Marc A. Brown 13-Apr-11 14:30pm    
Great follow-up answer. Got my 5.
Sergey Alexandrovich Kryukov 13-Apr-11 14:33pm    
Thank you very much, Marc.
--SA
Albert Holguin 13-Apr-11 14:31pm    
great answer! my 5
Sergey Alexandrovich Kryukov 13-Apr-11 14:34pm    
Thank you very much, Albert.
--SA
mr.abzadeh 13-Apr-11 14:57pm    
I will keep windows and write multi-os UI. I have a lot of research to do. Thank you for your
kind, helpfull, and extensive description..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900