1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Adding a header file to Xcode

Discussion in 'Mac Programming' started by n00blar, Dec 19, 2012.

  1. macrumors newbie

    #1
    First off, the following question was posted already, about a few months ago in these forums; however, I seem to have a slightly different error message, and I can't find the answer for this issue in the place where I got this header file.

    When building the project, I get the following error message:

    Undefined symbols for architecture x86_64:
    "_GetString", referenced from:
    _main in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    I installed these files using the following commands:

    gcc -c -ggdb -std=c99 cs50.c -o cs50.o
    ar rcs libcs50.a cs50.o
    rm -f cs50.o
    chmod 0644 cs50.h libcs50.a
    sudo mv cs50.h /usr/include
    sudo cp libcs50.a /usr/lib


    My version of Xcode is: Version 4.5.2 (4G2008a) and I'm running OS X 10.7.5.

    I have no clues as to how to get this to work. Thanks for any suggestions.
     
  2. macrumors 65816

    #2
    I'm sorry, I don't know the answer to your question. I think it would be difficult for most of us to guess at an answer. Here's the typical help desk response:

    Have you tried uninstalling and reinstalling XCode? I'd recommend doing it via the app store. I haven't had any problems on any of my systems.
     
  3. macrumors 6502

    #3
    Check your project setup, it looks like a linking problem. check if xcode & your project is referencing your newly compiled static linked library correctly (or at all).

    If that won't help remove the library, add it again and restart xcode.

    If that won't help check that your compile targets are correct (compiling for a correct platform) - not normally a problem.



    If that still won't work then check the course homepage about compilation (which I found by googling it): https://manual.cs50.net/CS50_Library#Mac_OS

    They mention other compile steps which you don't seem to do (at a cursory glance) and some different directories (i.e. usr/local instead of usr/ )
     
  4. macrumors 6502

    #4
    I've had this happen a few times when I forget to close my projects between different computers when running SugarSync.


    1) Make sure that the header file for the class you are having a problem with is actually linked to your target. I usually remove the file in Xcode and the drag-n-drop it back being sure to check the box specifying the targets.


    2) You can also try closing Xcode and deleting the "Derived Data" folder for that project.
     

Share This Page