Search code examples
c++xcodexcode6static-linking

At a loss ... Can't figure out why XCode 6.1 won't compile my C++ program


Although XCode is not flagging any errors before compile time, it brings up 4 when I actually compile it. They are

Undefined symbols for architecture i386:
  "HtmlProcessor::HtmlProcessor()", referenced from:
      _main in main.o
  "HtmlProcessor::~HtmlProcessor()", referenced from:
      _main in main.o
  "DocTree::_hp", referenced from:
      DocTree::setTree(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in HtmlProcessor.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have searched the web high and low for answers. Most of them mention changing the Architectures settings. Right now I have

Architectures: Universal (32/64-bit Intel) (x86_64, i386)
Base SDK: Latest OFX (OS X 10.9)
Build Active Architecture Only: No
Supported Platforms: OSX 
Valid Architectures: i386

and I've fiddled around with everything to try and get my damn program to compile. I don't even care what the target architecture is ..... I'm making this program for my own amusement and want it to run on my machine, a MacBook Pro running OS X 10.9.4. I just want this damn console program to work. You would think that XCode would have default configurations for your program to run on your machine.

Here are the source files: https://www.dropbox.com/sh/yu7tblwj14eoq1l/AAC8PfDi6la3CjE167Iz1C0da?dl=0

Nobel Prize to the Stack Overflow guru who bails me out of this one.


Solution

  • You declared a static class member, but you did not define it in any module:

     class DocTree {
     //...
     static HtmlProcessor _hp;
     //...
    };
    

    This needs to have this in one and only one module:

    HtmlProcessor DocTree::_hp;