kuroni/bongocat-osu

Undefined Reference during build.

ThePuceMoose opened this issue · 10 comments

On trying to build I get many "undefined reference" errors. I've been trying for a few hours and can't figure out why. I have not yet edited the code in any way from the release version.

c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x36): undefined reference to `vtable for sf::Sprite'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x45): undefined reference to `vtable for sf::Sprite'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x56): undefined reference to `vtable for sf::Sprite'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x65): undefined reference to `vtable for sf::Sprite'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x76): undefined reference to `vtable for sf::Sprite'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x85): more undefined references to `vtable for sf::Sprite' follow
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x370): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x414): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x4bd): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x56a): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x613): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj/ctb.o:ctb.cpp:(.text+0x6b3): more undefined references to `sf::Sprite::setTexture(sf::Texture const&, bool)' follow

My Makefile:

SRCDIR := src
OBJDIR := obj
ICODIR := ico
SRC := $(wildcard $(SRCDIR)/*.cpp)
OBJ := $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(SRC))
ICO := $(ICODIR)/ico.res
CXXFLAGS := -std=c++17 -s -O2 -mwindows
LDFLAGS := -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
INCFLAGS := -IC:\Users\Simon\Desktop\SFML-2.5.1\include -Iinclude
LIBFLAGS := -LC:\Users\Simon\Desktop\SFML-2.5.1\lib
DEFINES := -DSFML_STATIC

.PHONY: test clean

bin/bongo.exe: $(OBJ) $(ICO)
	$(CXX) -o $@ $^ $(DEFINES) $(INCFLAGS) $(LIBFLAGS) $(CXXFLAGS) $(LDFLAGS)

$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
	$(CXX) -c -o $@ $^ $(DEFINES) $(INCFLAGS) $(LIBFLAGS) $(CXXFLAGS) $(LDFLAGS)

$(ICODIR)/ico.res: $(ICODIR)/ico.rc
	windres -O coff -o $@ $^

test:
	bin/bongo.exe

clean:
	rm $(OBJ)

Release: bongocat-osu-1.4.3.4
OS: Windows 10
Compiler: g++ (MinGW.org GCC Build-20200227-1) 9.2.0
SFML: 2.5.1, GCC 7.3.0 MinGW (SEH) - 64-bit

Can you try make clean and make again to see if the problem persists?

EDIT: If it still persists, try using all 3 different versions of SFML.

Problem persist after make clean
Full readout: https://hastebin.com/usonatomex.coffeescript

I appreciate your fast responses! Will try different versions tomorrow, need sleep.

Using SFML 2.5.1 GCC 7.3.0 MinGW (DW2) - 32-bit reduces errors to:

C:\Users\Simon\Desktop\bongocat-osu-1.4.3.4>make
g++ -c -o obj/ctb.o src/ctb.cpp -DSFML_STATIC -IC:\Users\Simon\Desktop\SFML-2.5.1-32\include -Iinclude -LC:\Users\Simon\Desktop\SFML-2.5.1-32\lib -std=c++17 -s -O2 -mwindows -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
g++ -c -o obj/data.o src/data.cpp -DSFML_STATIC -IC:\Users\Simon\Desktop\SFML-2.5.1-32\include -Iinclude -LC:\Users\Simon\Desktop\SFML-2.5.1-32\lib -std=c++17 -s -O2 -mwindows -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
g++ -c -o obj/jsoncpp.o src/jsoncpp.cpp -DSFML_STATIC -IC:\Users\Simon\Desktop\SFML-2.5.1-32\include -Iinclude -LC:\Users\Simon\Desktop\SFML-2.5.1-32\lib -std=c++17 -s -O2 -mwindows -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
g++ -c -o obj/main.o src/main.cpp -DSFML_STATIC -IC:\Users\Simon\Desktop\SFML-2.5.1-32\include -Iinclude -LC:\Users\Simon\Desktop\SFML-2.5.1-32\lib -std=c++17 -s -O2 -mwindows -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
g++ -c -o obj/mania.o src/mania.cpp -DSFML_STATIC -IC:\Users\Simon\Desktop\SFML-2.5.1-32\include -Iinclude -LC:\Users\Simon\Desktop\SFML-2.5.1-32\lib -std=c++17 -s -O2 -mwindows -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
g++ -c -o obj/osu.o src/osu.cpp -DSFML_STATIC -IC:\Users\Simon\Desktop\SFML-2.5.1-32\include -Iinclude -LC:\Users\Simon\Desktop\SFML-2.5.1-32\lib -std=c++17 -s -O2 -mwindows -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
g++ -c -o obj/taiko.o src/taiko.cpp -DSFML_STATIC -IC:\Users\Simon\Desktop\SFML-2.5.1-32\include -Iinclude -LC:\Users\Simon\Desktop\SFML-2.5.1-32\lib -std=c++17 -s -O2 -mwindows -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
g++ -o bin/bongo.exe obj/ctb.o obj/data.o obj/jsoncpp.o obj/main.o obj/mania.o obj/osu.o obj/taiko.o ico/ico.res -DSFML_STATIC -IC:\Users\Simon\Desktop\SFML-2.5.1-32\include -Iinclude -LC:\Users\Simon\Desktop\SFML-2.5.1-32\lib -std=c++17 -s -O2 -mwindows -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Simon\Desktop\SFML-2.5.1-32\lib/libsfml-system-s.a(Err.cpp.obj):Err.cpp:(.text+0x3d): undefined reference to `_imp____acrt_iob_func'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Simon\Desktop\SFML-2.5.1-32\lib/libsfml-system-s.a(Err.cpp.obj):Err.cpp:(.text+0x9a): undefined reference to `_imp____acrt_iob_func'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Simon\Desktop\SFML-2.5.1-32\lib/libsfml-system-s.a(Err.cpp.obj):Err.cpp:(.text+0x113): undefined reference to `_imp____acrt_iob_func'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Simon\Desktop\SFML-2.5.1-32\lib/libsfml-system-s.a(Err.cpp.obj):Err.cpp:(.text+0x193): undefined reference to `_imp____acrt_iob_func'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Simon\Desktop\SFML-2.5.1-32\lib/libsfml-system-s.a(Err.cpp.obj):Err.cpp:(.text+0x1ee): undefined reference to `_imp____acrt_iob_func'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Simon\Desktop\SFML-2.5.1-32\lib/libsfml-system-s.a(Err.cpp.obj):Err.cpp:(.text+0x252): more undefined references to `_imp____acrt_iob_func' follow
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(wcharmap.o):(.text+0x208): undefined reference to `WideCharToMultiByte@32'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingwex.a(codeset.o):(.text+0xbe): undefined reference to `GetCPInfo@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingwex.a(codeset.o):(.text+0x143): undefined reference to `GetCPInfo@8'
collect2.exe: error: ld returned 1 exit status
make: *** [bin/bongo.exe] Error 1

Can you try the Code::Blocks one?

You mean the SFLM 2.5.1 GCC 5.1.0 TDM (SJLJ) - Code::Blocks - 32-bit one?
Using that results in a larger number of errors, however they are different to the 64bit SFLM.
Readout: https://hastebin.com/okejaxitip.coffeescript

Hm, can you try using / instead of \ in the path file? I'm not sure if that would do anything.

No luck, results in same errors.

Fixed it!
Problem was I was using a newer version of g++, v9.2.0.
I downloaded an older version of MinGW using g++ 7.3.0 from here.

I had to copy the msys folder out of the newer MinGW to allow me to use "make" in cmd as it is not included in the older version of MinGW
Bongocat now builds successfully!

To summarise, I used:
g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 7.3.0
msys 1,0
SFML 2.5.1 GCC 7.3.0 MinGW (DW2) - 32-bit

Thank you for your help :)

Alright, thanks a lot for your report!

Something extra to add to this, if you build SFLM yourself from source code you can use a newer version of g++.
SFLM must be built with the same version of g++ as you are building BongoCat with.
The pre-copiled downloads of SFLM for MinGW were built with g++ 7.3.0, so can only be used with that.