0

When I compile with gcc -g -o main.exe -Wall -std=c++11 -I./include/ -L./lib main.cpp -o main.exe -lraylib I get these compiler errors

C:\mingw-w64\bin/ld.exe: C:\Users\usr\AppData\Local\Temp\ccjms0zo.o: in function `_tcf_0':
c:/mingw-w64/lib/gcc/i686-w64-mingw32/12.1.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
C:\mingw-w64\bin/ld.exe: C:\Users\usr\AppData\Local\Temp\ccjms0zo.o: in function `_static_initialization_and_destruction_0':
c:/mingw-w64/lib/gcc/i686-w64-mingw32/12.1.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::Init()'    
collect2.exe: error: ld returned 1 exit status

I already tried relinking and reinstalling the library. I also have followed many tutorials on how to install Raylib. I tried different flags g++ main.cpp -lraylib -lGL -lm -lpthread -ldl -lrt -lX11. I just get different errors

C:\mingw-w64\bin/ld.exe: cannot find -lGL: No such file or directory
C:\mingw-w64\bin/ld.exe: cannot find -ldl: No such file or directory
C:\mingw-w64\bin/ld.exe: cannot find -lrt: No such file or directory
C:\mingw-w64\bin/ld.exe: cannot find -lX11: No such file or directory
collect2.exe: error: ld returned 1 exit status
Alex
  • 1
  • 2
  • You *must* use g++ to link C++ code, so the first snippet is broken by construction. As for the second: you left out the `-I./include` and `-L./lib` that tells the compiler where to look for header files and the linker for libraries, respectively.\ – Botje Mar 27 '23 at 07:50
  • I have added the flags to the second one and it looks like this `g++ main.cpp -lraylib -I./include -L./lib -lGL -lm -lpthread -ldl -lrt -lX11` but I still get the same errors. – Alex Mar 27 '23 at 14:56

0 Answers0