Zerolink problems

Discussion in 'Mac Programming' started by mmmdreg, Jun 4, 2005.

  1. mmmdreg macrumors 65816

    mmmdreg

    Joined:
    Apr 14, 2002
    Location:
    Sydney, Australia
    #1
    A program I'm writing compiles fine at this stage, yet when running, I get this error:
    ZeroLink: unknown symbol '__ZN14linkedListTypeIiEC1Ev'

    To show where the error occurs, from the following code, "debug1" is printed, but it never reaches "debug2":
    Code:
    int main()
    {
    	int theInput = 0;
    	cout << "debug1" << endl;
    	linkedListType<int> myList;
    	cout << "debug2" << endl;
    
     
  2. mmmdreg thread starter macrumors 65816

    mmmdreg

    Joined:
    Apr 14, 2002
    Location:
    Sydney, Australia
    #2
    I turned zerolink off and now it won't compile, giving me "undefined symbols" for various member functions of my template class. Does turning off zerolink screw things up with template classes?
     
  3. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    I'm not using XCode for C++ but if you turn of zerolink you will need to do a clean build to get it to work as some of your files will have been compiled with zerolink and some other won't!
     
  4. mmmdreg thread starter macrumors 65816

    mmmdreg

    Joined:
    Apr 14, 2002
    Location:
    Sydney, Australia
    #4
    I found some help. This site shows pretty much the problems with using template classes. To get around it, I included the classImplementation.cpp file at the bottom of the header file, and removed the inclusion of the header in the class implentation file. Then I had the class header file included in the main .cpp file.

    This is when i found a possible xcode bug. There are three files. the class header, the class cpp, and the main cpp. Xcode tries to compile the class cpp which doesn't include the header file so it has many errors. Meanwhile, doing:
    "g++ -o theApp theMainFile.cpp"
    yields no errors and a perfect executable. Is this a bug or just some thing I overlooked?
     
  5. AlmostThere macrumors 6502a

    #5
    Xcode (and just about every IDE) will infer some sort of meaning from the extension you give your files. In the case of cpp, you are telling Xcode that you want to compile this file. Using cpp for a template implementation is only going to be acceptable if you can control which files are passed to the compiler, as you do with the command line compile ... using an IDE is one way of saying that you don't want to be bothered with this level of detail!

    Either use a different extension (er, maybe tpp or txx - you can tell Xcode that these types contain c++ code to get your syntax highlighting) or stick the whole implementation in the header file.
     

Share This Page