I was trying to compile my GTKmm 3 app on Windows. Get an error during compilation that Glib::ustring doesn't have a constructor
Glib:: ustring:: ustring(std::string*)
although the code gets compiled successfully on Ubuntu.
Sample code:
#include <gtkmm.h>
#include <string>
int main()
{
std::string a("aa");
Glib::ustring b(a);
return 0;
}
Compiling with:
g++ -std=c++14 -c test.cpp `pkg-config gtkmm-3.0 --cflags` && \
g++ test.o `pkg-config --libs gtkmm-3.0`
Output (on 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
The problem was that I used wrong gcc.
which gcc
showed that I was using MSYS2 GCC instead of MINGW64 GCC.
Solved by installing proper GCC/MinGW64: pacman -S mingw-w64-x86_64-toolchain