我想用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