我想用MinGW編譯一個DLL,並使用Visual Studio編譯的可執行文件編譯它。DLL包括unordered_map不是用visual studio編譯器編譯
來自DLL的源文件之一是使用hash_map <>,它可以用MinGW成功編譯。
當我改變hash_map<>
到std::tr1::unordered_map<>
並添加#include <tr1/unordered_map>
我的代碼它的成功編譯爲Visual Studio編譯器。(How can I force MinGW to use tr1 namespace?)
,但是當我試圖編譯MinGW的代碼作爲一個DLL,並從使用可執行文件編譯與Visual Studio編譯器它給錯誤:無法打開包含文件'tr/unordered_map'
必須我的DLL兼容CL和MinGW同時?
編輯: 我編譯的命令低於:
g++ -shared -o stemming.dll stemming.cpp alphabet.cpp basic.cpp determinise.cpp fst.cpp hopcroft.cpp operators.cpp utf8.cpp -Wl,--output-def,stemming.def,--out-implib,libstemming.a
lib /machine:i386 /def:stemming.def
cl sfstMinGW.cpp SFST/stemming.lib
所有這些容器應該是Dll實現的一部分,而不是接口。在這種情況下,它們的頭文件應該僅包含在.cpp文件中,並且不應該影響使用另一個編譯器構建的Dll客戶端。如果您試圖將模板容器包括到Dll接口中,即使對於相同的編譯器,這也是錯誤的。 – 2013-04-22 14:31:02
你實際上是想''包括** ** tr **/unordered_map還是在你的問題中有一個錯字? – jerry 2013-04-22 19:47:21