Friday, July 31, 2009

C++ for Linux, Mac and Windows?

Im currently using Bloodshed Dev-C++ to do C++ Computer programming but it only seems to do Windows projects so is it possible in Dev-C++ to do app's for linux or mac?


If so how?


Also is the C++ code the same for linux as it is for windows?

C++ for Linux, Mac and Windows?
%26gt; "Im currently using Bloodshed Dev-C++ to do C++ Computer programming but it only seems to do Windows projects"


Dev-C++ is an IDE. The compiler it uses is MinGW. MinGW is a windows port of gcc. gcc is a compiler that runs on Linux, among other systems. MinGW targets windows only.





%26gt; "so is it possible in Dev-C++ to do app's for linux or mac?"


The topic you want to look at is cross compiling. No, this is not a one paragraph topic. Please Google and read. Good luck on not getting intimidated.





%26gt; "Also is the C++ code the same for linux as it is for windows?"


Sort of. C++ itself is a portable language, so if you stick to standard C++ and the standard library, you're fine. However, that only happens for trivial programs. Most likely, you will start relying on OS specific capabilities, in which case your code isn't just going to run from one machine to other. You'll have to port it.
Reply:Not sure if you can use dev-C++ for linux or mac projects, but the code is the same, its just different compilers picking up different errors etc. I think if you do it on linux it should work on Mac, windows is the only odd OS out there
Reply:As long your code uses ANSI C++, you don't need to worry about portability; however, this is tricky even when using ANSI C++! For instance the function "system" under the c header file stdlib parses an OS shell command to execute through C++; when typing system("cls"); under windows it will clear the dos screen, but "cls" doesn't exist in Linux; instead, "clear" will clear the terminal screen under Linux! C++ doesn't care and it parses the string parameter passed to the system function; syntax-wise, it accepts any string inside it, but when it comes to execution, you won't get the result you expected because there are certain OS considerations.


Any way, Borland released two years ago "Borland C++ BuilderX" which is a cross-plattform C++ Compiler; you chose the target Operating system for your project and the compiler will generate a compatible code for that target OS; it's a wounderful release, but after the release Borland Studio 2006 it has been removed! Perhaps now in the new release "CodeGear" this support is back; I'm not sure, so check it out, but i'm quite sure you'll find what you want under "Borland C++ BuilderX" though it's not easy to find for download.
Reply:Try here for info


http://www.techtutorials.net/





http://www.theeldergeek.com/
Reply:If you want to develop linux applications you must install Linux and compile the application again. Same for Mac's. and any other operating system. A compiler is specific to an operating system. Java managed to do this though but Java isn't a compiler. It's an interpreter, meaning it translates the code to a virtual machine which needs to be installed on that operating system, and through this virtual machine the program will run.
Reply:It will be the same as long as you stick to ISO-compliant C++, not platform-dependent extensions of the language.


No comments:

Post a Comment