我试图在Windows上编译我的GTKmm 3应用程序。在编译期间获取错误,Glib :: 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
Windows:Glib 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
答案 0 :(得分:0)
问题是我使用了错误的gcc。
which gcc
表明我使用的是MSYS2 GCC而不是MINGW64 GCC。
通过安装适当的GCC / MinGW64解决:pacman -S mingw-w64-x86_64-toolchain