How to write C ++ code that works between IDEs?

I am new to C ++ with the background of C # .NET and Visual Studio (and some Objective-C / XCode).

I want to write a cross-platform (Windows, OS X, Linux) application with C ++. I started with TextMate on my Mac and Notepad on my Windows and compiled the code using g ++ on the command line / terminal to create executable files on my platform.

I got confused when I started using the IDE (namely VC ++ , XCode and Eclipse ). I tried all three projects and created projects before embedding my code in it. If I start editing in one IDE, I don’t know how to get a possible piece of code to compile on another platform.

For example, if I have a class file - foo.cpp. In Eclipse, it will generate foo.cpp(inside it a foo.h, foo::foo()) and a separate header file foo.h(inside the file FOO_H_, etc.). In Xcode, it generates a Fooconstains folder main.cppand foo.l) is it. Why is the difference?

I, although C ++ code is just C ++ code that creates executable files for the platform if they are compiled on that platform. (for example, compile on Mac, it becomes a Mac executable, and if compiled on Windows, it becomes a Windows executable).

It seems that when I started using the IDE, my C ++ code automatically became unsportsmanlike due to all these automatically generated files that I don’t understand about. I am trying to read the documentation on Xcode, Eclipse and Visual Studio at the same time, and this confuses me even more. I just want to write C ++ ...

I also follow the classic Stroustrup text to pick up C ++ and in the book, nothing looked like the header or source of the files .hor _H_, which is why all these files were generated.

Besides using the Notepad / Textmate + g ++ compiler, how can I write a clean, portable C ++ program in the IDE that can be cross-platform or even possible?

+3
source share
3 answers

(= ) ++ Foo foo.h, Foo a foo.cpp, Foo.

include.

, , IDE:

  • (, include, src make MyProject), IDE make.h include .cpp src)
  • .h .cpp explorer/finder/...
  • " " - , .
  • , Visual Studio " " , .
+2

CMake - Boost Qt , .

CMake IDE: s, IDE: CMake IDE, .

Windows, Linux Mac - QtCreator IDE, . http://qt.nokia.com/downloads

+1

Why not use 1 IDE for everyone? Eclipse is a cross-platform IDE

+1
source

All Articles