Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Microsoft 內部支援資訊

錯誤 #: 101959 (Visual Studio)

摘要

當您藉由使用 64 位元版本的 Microsoft Visual C++ 的編譯器和連結器建置 DLL 時,您可能會收到連結器錯誤代碼 LNK4197,如果已宣告的函式,使其能匯出一個以上的時間。

徵狀

連結器輸出可能類似下列:

C:\>link /NOLOGO /def:Sample.def /pdb:Sample.pdb /out:Sample.dll  Sample.objSample.obj : warning LNK4197: export 'DllSample' specified multiple times; using first specification   Creating library Sample.lib and object Sample.exp 

原因

已宣告的函式,使其能匯出一次以上,就會產生連結器錯誤號碼 LNK4197。下列方法之一來進行匯出宣告的函式:

  • 您的 C 原始程式檔中使用__declspec(dllexport)關鍵字宣告的函式:

    __declspec(dllexport) int DllSample() {   return 42;}
  • 函式宣告使用模組定義 (。DEF) 檔中:

    EXPORTS   DllSample

連結器可能發生此錯誤最常時__declspec(dllexport)關鍵字和 a。DEF 檔用來定義中相同的函式名稱。DLL 專案。

解決方案

若要解決這個問題,請定義匯出函式只一次,使用__declspec(dllexport)關鍵字,或使用。DEF 檔。請勿使用這兩種方法。

狀態

產生此錯誤是系統刻意為之。

其他相關資訊

宣告匯出一次以上的函式可能不會產生的 32 位元版本的 Microsoft Windows c + + 編譯器和連結器在本文 < 徵狀=""> 一節所述的連結器錯誤。不過,Microsoft 建議您在 32 位元和 64 位元版本 Windows 的 c + + 編譯器和連結器中定義函式匯出一次。

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×