有一個靜態類Pipe,在我包含的C++頭文件中定義。Objective-C/C++ - 鏈接器錯誤/方法簽名問題
靜態方法我很感興趣調用(從Objective-C的)是在這裏:
static ERC SendUserGet(const UserId &_idUser,const GUID &_idStyle,const ZoneId &_idZone,const char *_pszMsg);
我訪問出現存儲用戶ID的副本的Objective-C的數據結構,和了zoneid - 它看起來像:
@interface DataBlock : NSObject
{
GUID userID;
GUID zoneID;
}
查找了GUID def,它是一個結構與一堆重載操作符相等。 UserId和ZoneId從第一個函數簽名是#typedef GUID
現在,當我嘗試調用該方法,無論我如何投它(const UserId),(UserId)等,我得到以下鏈接器錯誤:
Ld build/Debug/Seeker.app/Contents/MacOS/Seeker normal i386
cd /Users/josh/Development/project/Mac/Seeker
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/josh/Development/TS/Mac/Seeker/build/Debug -L/Users/josh/Development/TS/Mac/Seeker/../../../debug -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1 -F/Users/josh/Development/TS/Mac/Seeker/build/Debug -filelist /Users/josh/Development/TS/Mac/Seeker/build/Seeker.build/Debug/Seeker.build/Objects-normal/i386/Seeker.LinkFileList -mmacosx-version-min=10.5 -framework Cocoa -framework WebKit -lSAPI -lSPL -o /Users/josh/Development/TS/Mac/Seeker/build/Debug/Seeker.app/Contents/MacOS/Seeker
Undefined symbols:
"SocPipe::SendUserGet(_GUID const&, _GUID const&, _GUID const&, char const*)", referenced from:
-[PeoplePaneController clickGet:] in PeoplePaneController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
這是一個類型/函數簽名錯誤,或真正的某種鏈接錯誤?我有所有這些類型和靜態類定義的標題#imported - 我也試過#include,以防萬一,因爲我已經絆倒了:P
原諒我,我來自一個Web技術背景,所以這種C風格的內存管理和不可變性的東西超級朦朧。
編輯:添加完整的鏈接器錯誤文本。將「功能」更改爲「方法」。另外我會注意到我們使用一個自定義的makefile來編譯這個項目的一些外部項目。儘管在這個xcode項目中引用了SocPipe靜態方法,但似乎編譯得很好。
這並不是完整的鏈接器錯誤 - 請在粘貼之前抓住一兩行。 – 2010-05-15 22:44:28
此外,'SendUserGet'肯定不是一個函數,它是一個靜態方法。如果它是一個函數,它將不會生成鏈接器錯誤,因爲它被聲明爲「靜態」。是的,'static'意味着完全取決於它是出現在類定義的內部還是外部。 – 2010-05-15 22:50:49
方法然後。編輯。 – Josh 2010-05-15 23:00:24