Good day.

Task: WinAPI + OpenGL + SOIL to create a window, and then load and display a .png image.

What is done: Created a window, drew several primitives in it using openGL.

What doesn’t work: build a project with SOIL

What I write for: compile and compile - g ++. Exe (MinGW.org GCC-6.3.0-1) 6.3.0, I write the code in Notepad ++, I work with g ++ from the command line, OS - Windows 10.

Link libraries: OpenGL was originally present on the computer, so the need to download the library arose only with regard to SOIL. I downloaded SOIL from the official site as a zip archive. After unpacking, I opened the lib folder where I found the file libSOIL.a. I copied this file, and also the SOIL.h file to the folder where the sources of my project lie.

How I try to compile: All my own source code is in the main.cpp file. In the same directory where main.cpp is, there are files SOIL.h and libSOIL.a.

I collect with the help of the g ++ command main.cpp -o main.exe -mwindows -l opengl32 -I. -l SOIL. But g ++ writes: s: / mingw / bin /../ lib / gcc / mingw32 / 6.3.0 /../../../../ mingw32 / bin / ld.exe: cannot find -lSOIL

Then I decide to specify the directory in which libSOIL.a is: g ++ main.cpp -o main.exe -mwindows -l opengl32 -I. -L. -l SOIL. But then g ++ cannot find openGL and produces a lot of messages like - ./libSOIL.a(SOIL.o):SOIL.c:(.text+0x3e): undefined reference to `glGetString @ 4 '

Question: please tell me, what mistakes do I make in the above commands for g ++ and how to fix them?

  • one
    -lopengl32 put after -lSOIL - Croessmah
  • Thank you, @Croessmah! That helped. Could you explain - what is the role of specifying the names of libraries in this case? If it's not difficult for you, write it in the answer and I will indicate it as a solution. - Bakuard
  • one

2 answers 2

The error was in the sequence of specifying the link libraries. In the comments questionable user @Croessmah answered.

    in the compiler, the -L flag shows the path where non-standard libraries are located