除錯相關 鏈結庫的問題

2021-04-13 03:27:34 字數 1595 閱讀 8075

testproject error lnk2001: 無法解析的外部符號 "char * __stdcall inet_ntoa(struct in_addr)" (?inet_ntoa@@$$j14ygpaduin_addr@@@z)

testproject error lnk2001: 無法解析的外部符號 "int __stdcall bind(unsigned int,struct sockaddr const *,int)" (?bind@@$$j212yghipbusockaddr@@h@z)

testproject error lnk2001: 無法解析的外部符號 "int __stdcall gethostname(char *,int)" (?gethostname@@$$j18yghpadh@z)

testproject error lnk2001: 無法解析的外部符號 "int __stdcall sendto(unsigned int,char const *,int,int,struct sockaddr const *,int)" (?sendto@@$$j224yghipbdhhpbusockaddr@@h@z)

testproject error lnk2001: 無法解析的外部符號 "int __stdcall setsockopt(unsigned int,int,int,char const *,int)" (?setsockopt@@$$j220yghihhpbdh@z)

testproject error lnk2001: 無法解析的外部符號 "int __stdcall wsagetlasterror(void)" (?wsagetlasterror@@$$j10yghxz)

testproject error lnk2001: 無法解析的外部符號 "int __stdcall wsastartup(unsigned short,struct wsadata *)" (?wsastartup@@$$j18yghgpauwsadata@@@z)

testproject error lnk2001: 無法解析的外部符號 "struct hostent * __stdcall gethostbyname(char const *)" (?gethostbyname@@$$j14ygpauhostent@@pbd@z)

testproject error lnk2001: 無法解析的外部符號 "unsigned int __stdcall socket(int,int,int)" (?socket@@$$j212ygihhh@z)

testproject error lnk2001: 無法解析的外部符號 "unsigned long __stdcall inet_addr(char const *)" (?inet_addr@@$$j14ygkpbd@z)

testproject error lnk2001: 無法解析的外部符號 "unsigned short __stdcall htons(unsigned short)" (?htons@@$$j14yggg@z)

寫了個廣播的程式,出現了如上的連線錯誤,查msdn,知道setsockopt()等所依賴的鏈結庫ws2_32.lib

沒有新增上去。方法:工程屬性/鏈結器/輸入/附加依賴項  中新增上即可

linuxGDB下動態鏈結庫的除錯

gdb file 你的exe gdb load 你的so 這條應該是可選的 gdb dir gdb sharedlibrary 你的so gdb breakpoint 你的so中somewhere gdb run load 是將動態庫加載入記憶體。sharedlibrary是將動態庫的符號讀入gdb...

動態鏈結庫 靜態鏈結庫

包含標頭檔案和庫 idir 指定編譯查詢標頭檔案的目錄,常用於查詢第三方的庫的標頭檔案,例 gcc test.c i.inc o test。ldir 指定鏈結時查詢lib的目錄,常用於查詢第三方庫。llibrary 指定額外鏈結的lib庫 巨集定義 dmacro 以字串 1 預設值 定義 macro...

靜態鏈結庫 動態鏈結庫

庫是寫好的現有的,成熟的,可以復用的 現實中每個程式都要依賴很多基礎的底層庫,不可能每個人的 都從零開始,因此庫的存在意義非同尋常。本質上來說庫是一種可執行 的二進位制形式,可以被作業系統載入記憶體執行。庫有兩種 靜態庫 a lib 和動態庫 so dll windows上對應的是.lib dll ...