1
General / Re: Problem with compiling in windows (mingw)
« on: January 16, 2020, 08:45:47 am »
It works Thank you very much.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
OS:Windows 10 64 bit (1909)
terminal: cmder
Using SFML-2.5.1-windows-gcc-7.3.0-mingw-32-bit
Commandline:$make
g++ -std=c++14 -I../thirdparty/SFML-2.5.1/include -L../thirdparty/SFML-2.5.1/lib -lsfml-graphics -lsfml-window -lsfml-system main.cpp -o main.o
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x7c): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0xa2): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0xde): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x104): undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x124): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x144): undefined reference to `_imp___ZN2sf6Window5closeEv'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x171): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x18c): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x19e): undefined reference to `_imp___ZN2sf6Window7displayEv'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x1b2): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
C:\Users\ROY480~1\AppData\Local\Temp\cc7rGT79.o:main.cpp:(.text+0x1ee): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:15: main.o] Error 1
CXX=g++
CXXFLAGS=-std=c++14
# Include and link path
INC_PATH=-I../thirdparty/SFML-2.5.1/include
LIB_PATH=-L../thirdparty/SFML-2.5.1/lib
LIBS=-lsfml-graphics -lsfml-window -lsfml-system
EXE=test
SOURCES=main.cpp
OBJS=$(addsuffix .o, $(basename $(notdir $(SOURCES))))
%.o:%.cpp
$(CXX) $(CXXFLAGS) $(INC_PATH) $(LIB_PATH) $(LIBS) $< -o $@
all: $(EXE)
@echo Build complete for $(EXE)
$(EXE): $(OBJS)
$(CXX) $(CXXFLAGS) $(INC_PATH) $(LIB_PATH) $(LIBS) $^ -o $@
.PHONY: clean
clean:
$(RM) -f $(OBJS) $(EXE)
main.cpp#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
window.close();
}
// Clear screen
window.clear();
// Update the window
window.display();
}
}
$ g++ -v
Using built-in specs.
COLLECT_GCC=C:\i686-7.3.0-release-posix-dwarf-rt_v5-rev0\mingw32\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/i686-7.3.0-release-posix-dwarf-rt_v5-rev0/mingw32/bin/../libexec/gcc/i686-w64-mingw32/7.3.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-7.3.0/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw730/i686-730-posix-dwarf-rt_v5-rev0/mingw32 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-sjlj-exceptions --with-dwarf2 --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw730/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw730/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw730/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw730/prerequisites/i686-w64-mingw32-static --with-pkgversion='i686-posix-dwarf-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw730/i686-730-posix-dwarf-rt_v5-rev0/mingw32/opt/include -I/c/mingw730/prerequisites/i686-zlib-static/include -I/c/mingw730/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw730/i686-730-posix-dwarf-rt_v5-rev0/mingw32/opt/include -I/c/mingw730/prerequisites/i686-zlib-static/include -I/c/mingw730/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw730/i686-730-posix-dwarf-rt_v5-rev0/mingw32/opt/include -I/c/mingw730/prerequisites/i686-zlib-static/include -I/c/mingw730/prerequisites/i686-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw730/i686-730-posix-dwarf-rt_v5-rev0/mingw32/opt/lib -L/c/mingw730/prerequisites/i686-zlib-static/lib -L/c/mingw730/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
Thread model: posix
gcc version 7.3.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)
$ g++ --version
g++.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.