更新:鏈接錯誤
我才意識到,你可以通過設置LD_TRACE_ARCHIVES和LD_TRACE_DYLIBS環境變量,然後直接在命令行中運行鏈接器命令獲得更多的信息。下面是我執行,然後它的輸出(雖然我更換了一些很長的路徑和名稱與<short-text
>字符串):
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2
-arch i386
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
-L<path_to_project>/build/Debug-iphonesimulator
-L<path_to_static_libs>
-F<path_to_project>/build/Debug-iphonesimulator
-filelist <path_to_project>/build/<project_name>.build/Debug-iphonesimulator/<project_name>.build/Objects-normal/i386/<project_name>.LinkFileList
-mmacosx-version-min=10.6
--verbose
-lproject_lib
-Xlinker -objc_abi_version
-Xlinker 2
-framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore
-o <path_to_project>/build/Debug-iphonesimulator/<project_name>.app/<project_name>
Using built-in specs.
Target: i686-apple-darwin10
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)
/Developer/usr/bin/../libexec/gcc/i686-apple-darwin10/4.2.1/collect2
-dynamic -arch i386 -macosx_version_min 10.6
-syslibroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
-weak_reference_mismatches non-weak
-o <path_to_project>/build/Debug-iphonesimulator/<project_name>.app/<project_name>
-lcrt1.10.6.o
-L<path_to_project>/build/Debug-iphonesimulator
-L<path_to_static_libs>
-L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib
-L/Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1
-L/Developer/usr/bin/../lib/gcc
-L/usr/lib/gcc/i686-apple-darwin10/4.2.1
-L/usr/lib/gcc/i686-apple-darwin10/4.2.1
-L/Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1
-L/Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1/../../..
-L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../..
-filelist <path_to_project>/build/<project_name>.build/Debug-iphonesimulator/<project_name>.build/Objects-normal/i386/<project_name>.LinkFileList
-lproject_lib
-objc_abi_version 2
-framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore
-lstdc++ -lSystem -lgcc -lSystem
-F<path_to_project>/build/Debug-iphonesimulator
[Logging for XBS] Used dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/Frameworks/Foundation.framework/Foundation
[Logging for XBS] Used dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/Frameworks/UIKit.framework/UIKit
[Logging for XBS] Used dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/Frameworks/OpenGLES.framework/OpenGLES
[Logging for XBS] Used dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore
[Logging for XBS] Used dynamic library: /Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libstdc++.dylib
[Logging for XBS] Used dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/libSystem.dylib
[Logging for XBS] Used indirect dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/libobjc.A.dylib
[Logging for XBS] Used indirect dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
[Logging for XBS] Used indirect dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/system/libSystem.override.dylib
[Logging for XBS] Used indirect dynamic library: /usr/lib/libSystem.B.dylib
[Logging for XBS] Used indirect dynamic library: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/system/libmathCommon.A.dylib
[Logging for XBS] Used static archive: <path_to_static_libs>/libproject_lib.a
Undefined symbols:
".objc_class_name_NSBundle", referenced from:
[email protected][email protected][email protected] in libproject_lib.a(file1.o)
".objc_class_name_UIWindow", referenced from:
[email protected][email protected][email protected] in libproject_lib.a(file2.o)
".objc_class_name_UIView", referenced from:
.objc_class_name_file3 in libproject_lib.a(file3.o)
".objc_class_name_CAEAGLLayer", referenced from:
[email protected][email protected][email protected] in libproject_lib.a(file3.o)
".objc_class_name_EAGLContext", referenced from:
[email protected][email protected][email protected] in libproject_lib.a(file2.o)
[email protected][email protected][email protected] in libproject_lib.a(file3.o)
".objc_class_name_NSDictionary", referenced from:
[email protected][email protected][email protected] in libproject_lib.a(file3.o)
".objc_class_name_NSNumber", referenced from:
[email protected][email protected][email protected] in libproject_lib.a(file3.o)
".objc_class_name_UIScreen", referenced from:
[email protected][email protected][email protected] in libproject_lib.a(file2.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
所以,問題是:爲什麼沒有被發現,即使collect2的.objc_class_name_xxx引用正在研究iPhoneSimulator的正確框架位置?這裏的要點是,這一切都正常工作,當針對iPhone設備本身時,沒有鏈接錯誤。
原始郵件:
我已經編譯並在Xcode鏈接的精細標定設備本身(新iPad)時,而是一個應用程序,當我嘗試目標模擬器我得到指示的錯誤,從我的框架符號沒有找到m使用。
我已經看到了與此相關的一些舊的線程,但他們的建議不工作: 1)我沒有複製的iPhoneOS SDK框架本地 2)我沒有一個明確的框架搜索路徑 3)但是,我確實有明確的庫搜索路徑,一個用於模擬器,一個用於設備。 4)我嘗試製作明確的框架搜索路徑,一個用於模擬器,一個用於設備,但也不起作用,儘管生成的gcc命令行具有正確的模擬器的-syslib和-F選項。
我一直堅持這一段時間了。有沒有人有任何進一步的洞察可能會發生什麼?我只是連接4個基礎框架,Foundation,UIKit,QuartzCore和OpenGLES。
感謝,
-Eric
omfg我一直在一遍又一遍地問這個同樣的問題。非常感謝你分享你的答案。 – cheshirekow 2012-04-16 01:51:15