看孫鑫老師講解的lesson19中的元件的的程序,其中有一個方法是通過模塊定義檔案def來匯出檔案,避免名字粉碎,按照他的做法,我實際的操作了一遍
1.首先建一個win32 dll空專案Dll3
2.加入.cpp檔案
int add (int a,int b)
{
return a+b;
}
int subtract(int a,int b)
{
return a-b;
}
3.添加def檔案 Dll3.def
4.編輯Dll3.def
LIBRARY
EXPORTS
add
subtract
5.點擊生成Dll3
6.結果出錯 錯誤提示如下:
錯誤 57 error LNK1120: 2 個無法決議的外部命令 F:\專案\DLL\Dll3\Debug\Dll3.lib Dll3
錯誤 57 error LNK1120: 2 個無法決議的外部命令 F:\專案\DLL\Dll3\Debug\Dll3.lib Dll3
錯誤 56 error LNK2001: 無法決議的外部符號 subtract F:\專案\DLL\Dll3\Dll3\Dll3.def 1 1 Dll3
7.我上網查看了一下原因,說是添加新的 Dll3.dll就不需要在 屬性---》連接器---》輸入----》模塊定義檔案----》中有Dll3.def
添加現有的 Dll3.dll就需要在 屬性---》連接器---》輸入----》模塊定義檔案----》中有Dll3.def
結果出現了6.中的錯誤
8.當我把 屬性---》連接器---》輸入----》模塊定義檔案----》中de Dll3.def去掉
就可以生成,但是生成之后會出現9.中的問題
9.生成之后,在命令提示符中cd 到相關的檔案夾F:\專案\DLL\Dll3\Debug>然后dumpbin -exports dll3.dll
發現并沒有匯出函式int add(int a,int b)和int subtract(int a,int b)
F:\專案\DLL\Dll3\Debug>dumpbin -exports dll3.dll
Microsoft (R) COFF/PE Dumper Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file dll3.dll
File Type: DLL
Summary
1000 .data
1000 .idata
2000 .rdata
1000 .reloc
1000 .rsrc
4000 .text
10000 .textbss
請各位接觸過的大神們,幫幫我。
uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
我也遇到這個問題了,樓主解決了嗎?轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/111238.html
標籤:Windows客戶端使用
