• 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
C++ Static library fails to link for some code, relocatable object works fine
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ Static library fails to link for some code, relocatable object works fine


  • Subject: C++ Static library fails to link for some code, relocatable object works fine
  • From: Adam Zegelin <email@hidden>
  • Date: Tue, 15 Jul 2008 04:58:31 +1000

Hi,

I'm trying to build a project that uses sqlite3x, a C++ wrapper for SQLite3. I've created a new "sqlite3" static library target which includes all the sqlite3 and sqlite3x source files. This target is then added as a dependency of the main application (Cocoa) target, and the static lib product is added to the "Linked Libraries" list in the target settings of the main target.

The project fails to link. I've been working on this for hours, and gave up, eventually stripping my main.mm file down to

#include "../sqlite3x/sqlite3x.hpp"

int main(int argc, char *argv[])
{
	sqlite3x::sqlite3_connection	c;
}

	That shows the problem perfectly. ld spits out:

Undefined symbols:
  "__ZN8sqlite3x18sqlite3_connectionC1Ev", referenced from:
      _main in main.o
  "__ZN8sqlite3x18sqlite3_connectionD1Ev", referenced from:
      _main in main.o
      _main in main.o
ld: symbol(s) not found

	Yet the output of `nm libsqlite3.a` shows the symbols defined:

00000070 T __ZN8sqlite3x18sqlite3_connectionC1Ev
000192c0 S __ZN8sqlite3x18sqlite3_connectionC1Ev.eh
== snip ==
00000a02 T __ZN8sqlite3x18sqlite3_connectionD1Ev
00019580 S __ZN8sqlite3x18sqlite3_connectionD1Ev.eh

Changing the "sqlite3" target mach-o type to "Relocatable Object", and then from the command line calling `g++ libsqlite3.o main.mm` builds and links fine.

	Calling the C sqlite3 API functions stored in the lib builds fine.

I have other C++ code in other static libs that link correctly. I can't find anything weird about the code to sqlite3x.

	No warnings are given by ld either, just the errors above.

	This is using Xcode 3.1, targeting 10.5.

Thanks,
Adam
_______________________________________________
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: C++ Static library fails to link for some code, relocatable object works fine
      • From: Jens Alfke <email@hidden>
    • Re: C++ Static library fails to link for some code, relocatable object works fine
      • From: Peter O'Gorman <email@hidden>
  • Prev by Date: Re: Xcode 3.1, iPhone SDK, and NDA
  • Next by Date: Re: Non human friendly error message from compiler with exceptions
  • Previous by thread: Re: Xcode 3.1 problem checking dependencies
  • Next by thread: Re: C++ Static library fails to link for some code, relocatable object works fine
  • Index(es):
    • Date
    • Thread