• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
XCode Static Libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XCode Static Libraries


  • Subject: XCode Static Libraries
  • From: Cory R Leach <email@hidden>
  • Date: Mon, 11 Feb 2008 01:26:39 -0600

Let me apologize in advance for posting what I thought seemed would be a straightforward problem to solve just by searching but somehow I just can't seem to find the answer to.

I'm compiling a BSD Static Library which is a project I created in XCode 3.0

It's just a test library and has two files:

//TestLib.h

int TestLib();


//TestLib.cpp

#include <iostream>

int TestLib() {

std::cout << "Test Lib\n";

return 0;

}

I compile this and as expected no errors and I get in the ./build/release libTestLib.a
Up until this point I have done nothing to the static lib project settings, only added the two
source files and compiled.

Now, I create a new project,  C++ Command line too and I just call it TestApp

and I have the following in main.cpp:

#include <iostream>
#include <TestLib.h>

int main (int argc, char * const argv[]) {


    TestLib();


    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;

}


For the project settings I set the include path to include TestLib.h

Now what I do is I add libTestLib.a to the project by just doing add Existing File and selecting it.
I look at the target and under TestApp->Link Binary With Library I see my library libTestLib.a and
I assume it will compile and link just fine. 

Of course the problem is now that it just doesn't work: 
Undefined symbols:
  "TestLib()", referenced from:
      _main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
  "TestLib()", referenced from:
      _main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Build failed (1 error)

I have even taken it to the command line by trying to combine main.cpp with the libTestLib.a using g++
and it will not link at the command line either so I thought something must be wrong with the way I compile the
library. But according to the docs symbols export by default so I don't know what I am doing wrong.

I have to think it's something really small and simple I'm not doing :-/

Any help will be really appreciated, thanks in advance.

yoroshiku onegaishumasu,

Cory





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Xcode Static Libraries
      • From: Chris Espinosa <email@hidden>
  • Prev by Date: Re: gcc and extended character source code
  • Next by Date: newbie alert: just trying to follow documention
  • Previous by thread: Re: gcc and extended character source code
  • Next by thread: Re: Xcode Static Libraries
  • Index(es):
    • Date
    • Thread