static libraries and missing symbols in release build
static libraries and missing symbols in release build
- Subject: static libraries and missing symbols in release build
- From: Bryan Smart <email@hidden>
- Date: Tue, 16 Feb 2010 10:16:17 -0500
- Acceptlanguage: en-US
- Thread-topic: static libraries and missing symbols in release build
I have a library that I'm trying to use with my app. The library must be included in the app, and, due to project requirements, must be statically linked.
When the library and the app are built in debug configuration, all works well. However, when the library and the app are built in release configuration, I get complaints about a missing _Main symbol during link, as if there is no main entry point for either the app or library. There isn't a main entry point for the library, but there is certainly one in the app, and the app runs just fine in debug config.
The library is called RenaissanceC. RenaissanceC is built in a separate project, and its static library product is copied to a common folder.
The log below is from my RenaissanceC Test Suite project, the project that tests the library. This project has a cross-project reference to the RenaissanceC project, and the Renaissance Test Suite target has RenaissanceC as a dependency to force it to be up-to-date before the test suite is compiled and linked against the library. The actual link takes place against the RenaissanceC product that is copied to the common folder, not by directly referencing the lib in the RenaissanceC project. I'm trying to work this way because this is how the client applications will use the library. They won't have a full source project to build against, so will just be linking to the static lib.
----------
Ld "../build/RenaissanceC Test Suite.build/Release/RenaissanceC Test Suite.build/Objects-normal/x86_64/RenaissanceC Test Suite" normal x86_64
cd "/Users/bryansmart/Documents/General Software Development/RenaissanceC/Library/Source/RenaissanceC Test Suite"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/gcc-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk "-L/Users/bryansmart/Documents/General Software Development/RenaissanceC/Library/Source/RenaissanceC Test Suite/../build/Release" "-L/Users/bryansmart/Documents/General Software Development/RenaissanceC/Library/Source/RenaissanceC Test Suite/../.." "-F/Users/bryansmart/Documents/General Software Development/RenaissanceC/Library/Source/RenaissanceC Test Suite/../build/Release" -filelist "/Users/bryansmart/Documents/General Software Development/RenaissanceC/Library/Source/RenaissanceC Test Suite/../build/RenaissanceC Test Suite.build/Release/RenaissanceC Test Suite.build/Objects-normal/x86_64/RenaissanceC Test Suite.LinkFileList" -mmacosx-version-min=10.6 -framework Cocoa -lRenaissanceC -o "/Users/bryansmart/Documents/General Software Development/RenaissanceC/Library/Source/RenaissanceC Test Suite/../build/RenaissanceC Test Suite.build/Release/RenaissanceC Test Suite.build/Objects-normal/x86_64/RenaissanceC Test Suite"
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
----------
The RenaissanceC Test Suite, the project where this build is performed, does have a Main function, and that runs just fine in the debug config. In release config, though, I always get this error.
Not that I think that this is the solution, but I tried adding a dummy main function to the library. This causes the release build to succeed, but the debug build then fails with duplicate symbols errors, which makes sense. Somehow, then, the main function in the Test Suite app is being ignored or obscured when linking against the RenaissanceC static lib.
I've tried to compare the debug and release configurations of both my library and app, and the only major difference that I can find is that, in debug, I'm only building for the current architecture, where as, in release, I'm building universal (standard 32/64) for both the lib and app. Maybe static libs can't be universal?
In case I'm somehow totally off track here with what I'm doing, which is totally possible, my goal is to be able to produce a universal binary static lib that contains some utility functions. My users will need to be able to link this static lib to their apps without access to the original project that generated the static lib.
I can make this work just fine, in both debug and release configs, when I build the library as shared. However, it must be static due to some other technical requirements of the project. I have very little experience with static libraries, though, so there is probably some caveat to their use that I don't know about.
Does anyone have a solution, or at least a theory that I might investigate?
And, in case you're curious, the project is a system that I'm working on to make it possible for blind Mac developers to bypass the accessibility problems in Interface Builder by creating the Cocoa UI objects programatically from directives in a markup file. Only Cocoa is supported at the moment, but Cocoa Touch will be soon, and that will absolutely require that this system be available as a static library.
Thanks a lot for any ideas!
Bryan
_______________________________________________
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