简体   繁体   中英

Multiple .cpp programs in xcode project?

I'm using Xcode to do the Project Euler problems in C++. I wanted to keep everything organized, so I decided to make a single project that would include all my .cpp files, like in visual studio. The problem that I am encountering is I have one project called "Project Euler" and then I wanted to have Problem1.ccp, Problem2.cpp, etc. enabling the ones I want to run. When I did that, I got an error "Apple Mach-O Linker Error". Does anyone know how I could do what I'm trying to do with Xcode?

Yes, you want to add a new Target using justin's steps.

You also need to understand what a target is: http://developer.apple.com/library/ios/#featuredarticles/XcodeConcepts/Concept-Targets.html

and how to run and compile the separate files: http://developer.apple.com/library/ios/#recipes/xcode_help-scheme_editor/Articles/SchemeBuild.html

To paraphrase, a target is a completely separate product contained in the same Xcode project.

When you want to change which target you're running/compiling/analyzing you need to adjust the scheme. In Xcode version 4.6.2 go to:

Product > Scheme > Desired Target

What you want is one Xcode target per problem (assuming that each problem has a main() ).

To add a target to the current project (Xc4), go to File > New > New Target… .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM