Re: [問題] 請問vc中的__declspec(dllexport),GCC …

看板C_and_CPP作者 (原力副甦)時間15年前 (2010/06/03 11:06), 編輯推噓0(009)
留言9則, 3人參與, 最新討論串1/4 (看更多)
※ 引述《Risingforce (原力副甦)》之銘言: : 就包dll時,外部接口的提示,vc中為 __declspec(dllexport) : 一樣的code不能用gcc 4.0編(mac os環境) : 明顯是這行錯了 : 那請問gcc下要用什麼代替呢,謝謝 我程式是這樣的 #ifndef _A_H_ #define _A_H_ #ifdef A_EXPORTS #define API __declspec(dllexport) #else #define API #endif #ifdef __cplusplus extern "C" { #endif API int Init(void);/*initial*/ API void Close(int jpegcd);/*close*/ API int Run(int ....一堆引數) #ifdef __cplusplus } #endif #endif/*_A_H_*/ 在windows下完全正常(當然前致處理的宏設為A_EXPORTS),可是移到 mac 下的 xcode(gcc 4.0) ,編是可以編過(不設宏) , 可是測時就一直找不到 function啊。 後來我在mac下,設 #define JPEGCD_API __declspec(dllimport) 編就編不過了 : error expected constructor destructor or type conversion before '(' token 那請問我該怎樣解決呢,謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.158.204 ※ 編輯: Risingforce 來自: 59.120.158.204 (06/03 19:08)

06/03 19:26, , 1F
可以測時就一直找不到 function啊。 <== 請問如何測的?
06/03 19:26, 1F
※ 編輯: Risingforce 來自: 59.120.158.204 (06/03 19:49)

06/03 19:50, , 2F
樓上,用另一個程式去load這dll
06/03 19:50, 2F

06/03 19:58, , 3F
上篇就推文跟你說 GCC 不用 __declspec(dllexport) 了。
06/03 19:58, 3F

06/03 20:02, , 4F
「可是測時就一直找不到 function」 <-- 把操作過程跟下的
06/03 20:02, 4F

06/03 20:02, , 5F
command 列出來吧,不然很難猜。
06/03 20:02, 5F

06/03 20:03, , 6F
還有你所謂找不到 function 得到的 error messages。
06/03 20:03, 6F

06/03 20:09, , 7F
load他的程式是同事寫的,QQ 他下班了
06/03 20:09, 7F

06/03 20:09, , 8F
所謂 load 是用 dlopen() 去開 .so 檔?
06/03 20:09, 8F

06/03 20:09, , 9F
從頭開始測好了 去寫個hello world來冊dll寫法
06/03 20:09, 9F
文章代碼(AID): #1C1up03B (C_and_CPP)
文章代碼(AID): #1C1up03B (C_and_CPP)