I have started using c++ extensively in school and now my programs are getting to the point where have more than 1 file (i.e. header, driver, implementation file). I don't know enough about software development to understand or get a grasp of how to setup the build process by looking at apple's guides. Could someone walk me through how to compile a simple c++ project with a header and two c++ files in xcode? Do I first need to make a makefile??
In Xcode:
main.cpp
file. You can use that file if desired, or select it and hit the Delete key to get rid of it.You will want to learn more about Xcode if you are going to use it as your main IDE. There's a lot of documentation for Xcode, but most of it is designed for people creating Cocoa apps. For developing simple C++ console apps, you can probably start with the Xcode Workspace Guide.
You commented about targets, so I thought I might explain them for you:
You don't need to worry about it for now, if you select the C++ Command Line Tool project template there is already a target and some build configurations made for you which should already work.
Rather then have multiple makefiles Xcode prefers to keep its compiling information within the project file, targets are for building different products, if you click the drop down arrow on the standard target (Should be the name of your project) you can see 'build phases', essentially steps in building that require specific input, using the "Compile with Source" and "Copy Headers" phases you can have two targets which use separate main.cpp files and make separate applications, yet still share some source files within the project.
The active target is the one Xcode is going to work with when you hit the 'build' button.
The build configuration changes the values passed to the GCC compiler (The backend responsible for compiling and linking all your source files, the messages from which you can see in the build window) and a few processes xcode handles itself. These values anything from custom macros to level of optimisation performed. Traditionally one has a Development configuration which has low optimisations and fills in variables symbols for debugging purposes, and then a Deployment configuration with high optimisation and no support for debugging and other developer features. If you want to muck around with these options you can change them for your entire project by right clicking your project file, selecting get info and opening the 'build' tab, you can change them for each target by right clicking the target, selecting get info and opening the 'build' tab and selecting what configuration to change using the drop down menu on the left.
If you click any of the options xcode normally does a pretty decent job of explaining what it does - if you don't understand (There are a few weird ones) then its probably best to leave them at whatever value they are.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With