Creating C++ with external lib - Xcode 3.2

Discussion in 'Mac Programming' started by pazimi, Sep 19, 2009.

  1. pazimi macrumors newbie

    Sep 19, 2009

    I'm a programmer and for the past five-or-six years, I was programming in ActionScript, Java, C++ and a dozen more languages. but, I've never used Xcode before.

    Now, I'm running Xcode 3.2 on SnowLeopard. I want to create a simple console program with C++. but I can't! If you don't know, Xcode 3.2 is kinda different with Xcode 3.1 and I couldn't find anywhere how to do this.

    here, you can find the library I want to use:

    in the <cs106> folder.

    well, It's cool. but I CAN'T create a project like this!

    can someone please describe me, how to:
    *create a project with Xcode, with C++ and not ObjectiveC
    *how to attach libraries
    *and anything else needed in order that i can run a simple program like this:
    #include <iostream>
    #include <fstream>
    #include "genlib.h"
    #include "simpio.h"
    #include "vector.h"
    string readFile(string fileName) {
    	ifstream in;;
    	if( {
    		Error("Error loading file!");
    	string text;
    	while(true) {
    		string line;
    		getline(in, line);
    		if( {
    		text += line;
    	return text;
    void writeFile(string fileName, string text) {
    	ofstream out;;
    	if( {
    		Error("Error creating file");
    	out << text;
    int main() {
    	string input = readFile("info.plist");
    	cout << input << endl;
    	string outputFileName = GetLine();
    	writeFile(outputFileName, input);
    	return 0;
    I don't know why, but every time I try to INCLUDE something lice "vector.h" or "set.h", this stupid IDE gives me a lot of errors. and all of them are nonsense! 26 errors for nothing!
    just comment the line that includes "vector.h" and it works fine! strange, hah?

    ** actually I have two questions, 1: how to create a C++ program in Xcode 3.2 without pain, and 2: why I can't run this piece of code?

    I don't know what to do or where to go, except macrumors, 'cause I know nobody using Xcode.

    Thank you so much, I'm not a newbie to programming, not at all, but i've got confused with this new, stupid Xcode 3.2
    and, sorry for bad english! :eek:
  2. lloyddean macrumors 6502a

    May 10, 2009
    Des Moines, WA
    The project you're trying to compile has setting specified that are not appropriate for use under Xcode 3.2 and Mac OS X 10.6

    In order for your project to compile -

    • From within Xcode go to the "Project" menu and select "Edit Project Settings".
      A dialog window titled 'Project "MyProject" Info' will apear.
    • If not currently selected select the "Build" tab.
    • Change the "Base SDK" to "Mac OS X 10.5" or later.
    • Close the 'Project "MyProject" Info' setting dialog.
    The project should now compile without errors or warnings.
  3. pazimi thread starter macrumors newbie

    Sep 19, 2009

Share This Page