tileson
tileson copied to clipboard
Multiple definition of `std::type_info::operator==(std::type_info const&) const`
I'm attempting to use Tileson to open and display a map using raylib. Right now all the program does is include the libraries and display a window.
#include <raylib.h>
#include "tileson.hpp"
int main() {
const int screen_width = 640;
const int screen_height = 480;
InitWindow(screen_width, screen_height, "Tiled Import Test");
SetTargetFPS(60);
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}
CloseWindow();
return 0;
}
Compiler output:
clang++ -o main.o -c -static --target=x86_64-w64-windows-gnu -std=c++17 -Iinclude main.cpp
In file included from main.cpp:3:
In file included from ./tileson.hpp:64:
In file included from /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/include/c++/memory:80:
/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/include/c++/bits/unique_ptr.h:81:2: warning: delete called on 'tson::IDecompressor<std::basic_string_view<char, std::char_traits<char> >, std::__cxx11::basic_string<char> >' that is abstract but has non-virtual destructor [-Wdelete-abstract-non-virtual-dtor]
delete __ptr;
^
....
There's multiple warnings like this.
Linker output:
clang++ -o tiled_test.exe -mwindows --target=x86_64-w64-windows-gnu -static-libgcc -static-libstdc++ -v main.o -Llib -lraylib -lopengl32 -lgdi32 -lwinmm
clang version 10.0.0-4ubuntu1
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/ld" -m i386pep --subsystem windows -Bdynamic -o tiled_test.exe /usr/x86_64-w64-mingw32/lib/crt2.o /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/crtbegin.o -Llib -L/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32 -L/usr/x86_64-w64-mingw32/lib -L/usr/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib main.o -lraylib -lopengl32 -lgdi32 -lwinmm -Bstatic -lstdc++ -Bdynamic -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/crtend.o
/usr/bin/ld: /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/libstdc++.a(tinfo.o):(.text$_ZNKSt9type_infoeqERKS_+0x0): multiple definition of `std::type_info::operator==(std::type_info const&) const'; main.o:main.cpp:(.text$_ZNKSt9type_infoeqERKS_[_ZNKSt9type_infoeqERKS_]+0x0): first defined here
When Tileson is not included there are no errors or warnings.
Removing -static and -static-libgcc -static-libstdc++ fixes the linker error but the warnings remain.
Hello, @samfromcadott :smile:
Glad the linker error worked out. I presume you use the Tileson version of the last release (1.3.0)?
If so I recommend to use the version from the master branch, as it will be updated as soon as a new feature or bug is fixed, and should be pretty stable. It should also contain a fix for the more serious warning. See picture below from README:

Some minor warnings will probably retain for a while, as Tileson supports the major compilers for both Windows (MSVC), Linux (GCC) and OS X(Clang/LLVM, though GCC probably works here, too), and they have a slightly different implementation of C++, and some things may be considered a warning in one but not the other.
With that said, I would recommend to use the MSVC compiler when on Windows, as I've had some strange problems using MinGW for modern C++ in the past, but as long as it works, it works :slightly_smiling_face:
Also: Raylib is amazing! :partying_face:
Hope this answers your question :slightly_smiling_face: If you have any other concerns, just create an issue, and I will answer as fast as I can.
Thanks for getting back to me. I had a feeling the problem was being caused by something other than Tileson. I'll try MSVC or look into other cross-compilation solutions for Windows builds in the future.
I came back to this issue and now I think it's being caused by Json11. I modified the above code to include Json11.hpp without tileson_min.hpp and got the same error when compiling with -static -static-libgcc -static-libstdc++.
@samfromcadott : Do you have a more detailed output of the error in Json11 you're talking about? And is it an error, which prevents you from compiling, or simply a warning?
I get errors when compiling with -static -static-libgcc -static-libstdc++ and the target x86_64-w64-windows-gnu.
clang++ -o main.o -c -static --target=x86_64-w64-windows-gnu -std=c++17 -Iinclude main.cpp
clang++ -o tiled_test.exe -mwindows --target=x86_64-w64-windows-gnu -static-libgcc -static-libstdc++ -v main.o -Llib -lraylib -lopengl32 -lgdi32 -lwinmm
clang version 10.0.0-4ubuntu1
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/ld" -m i386pep --subsystem windows -Bdynamic -o tiled_test.exe /usr/x86_64-w64-mingw32/lib/crt2.o /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/crtbegin.o -Llib -L/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32 -L/usr/x86_64-w64-mingw32/lib -L/usr/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib main.o -lraylib -lopengl32 -lgdi32 -lwinmm -Bstatic -lstdc++ -Bdynamic -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/crtend.o
/usr/bin/ld: /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/libstdc++.a(tinfo.o):(.text$_ZNKSt9type_infoeqERKS_+0x0): multiple definition of `std::type_info::operator==(std::type_info const&) const'; main.o:main.cpp:(.text$_ZNKSt9type_infoeqERKS_[_ZNKSt9type_infoeqERKS_]+0x0): first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)