C++ Static library fails to link for some code, relocatable object works fine
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