无法链接GTKmm 3应用程序与minGW64 ithin MSYS2:未找到ustring构造函数

问题描述:

我试图在Windows上编译我的GTKmm 3应用程序。把那油嘴:: ustring没有构造无法链接GTKmm 3应用程序与minGW64 ithin MSYS2:未找到ustring构造函数

Glib:: ustring:: ustring(std::string*) 

虽然代码获取Ubuntu的成功编译编译时错误。

样品的编号:

#include <gtkmm.h> 
#include <string> 

int main() 
{ 
    std::string a("aa"); 
    Glib::ustring b(a); 
    return 0; 
} 

与编译:

g++ -std=c++14 -c test.cpp `pkg-config gtkmm-3.0 --cflags` && \ 
g++ test.o `pkg-config --libs gtkmm-3.0` 

输出(在Windows 10的X64,MSYS2 MinGW64):

test.o:test.cpp:(.text+0x51): undefined reference to `Glib::ustring::ustring(std::string const&)' 
test.o:test.cpp:(.text+0x51): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Glib::ustring::ustring(std::string const&)' 
collect2: error: ld returned 1 exit status 

视窗:油嘴2.50.3,Glibmm 2.50.0,GCC 5.3.0(MinGW 64bit)
Ubuntu:Glib 2.48.1,Glibmm 2.46.3,GCC 5.4 .0

问题是我使用了错误的gcc。

which gcc表明我使用的是MSYS2 GCC而不是MINGW64 GCC。

通过安装合适的GCC/MinGW64解决:pacman -S mingw-w64-x86_64-toolchain