0

Im getting this error:

mingw32-make: Circular square.o <- square.o dependency dropped.
g++ -o main.exe square.o application.cpp -DGLEW_STATIC -LC:\\Coding\\lib\\ -IC:\\\\Coding\\Learn-OpenGL\\include\\ -lglfw3 -lglew32 -lgdi32 -lopengl32
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0xf): undefined reference to `_imp____glewGenBuffers'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x2a): undefined reference to `_imp____glewGenBuffers'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x45): undefined reference to `_imp____glewBindBuffer'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x62): undefined reference to `_imp____glewBindBuffer'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x7f): undefined reference to `_imp____glewBufferData'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0xaf): undefined reference to `_imp____glewBufferData'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0xe5): undefined reference to `_imp____glewEnableVertexAttribArray'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0xf8): undefined reference to `_imp____glewEnableVertexAttribArray'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x10b): undefined reference to `_imp____glewVertexAttribPointer'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x14f): undefined reference to `_imp____glewDeleteBuffers'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x16a): undefined reference to `_imp____glewDeleteBuffers'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x1bc): undefined reference to `_imp____glewBindBuffer'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x1d9): undefined reference to `_imp____glewBindBuffer'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x234): undefined reference to `_imp____glewBufferSubData'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: square.o:square.cpp:(.text+0x264): undefined reference to `_imp____glewBufferSubData'

When trying to compile this Makefile (I know the makefile is bad)

main: application.cpp square.o square.hpp
    g++ -o main.exe square.o application.cpp -DGLEW_STATIC -LC:\\Coding\\lib\\ -IC:\\\\Coding\\Learn-OpenGL\\include\\ -lglfw3 -lglew32 -lgdi32 -lopengl32

square.o: square.cpp square.o
    g++ -c square.cpp -IC:\\\\Coding\\Learn-OpenGL\\include\\

Now here is the thing: from what I understand, its having a hard time linking glew to the square.o file, but when it was just application.cpp, everything worked as expected. What is the problem with square.o?

Serket
  • 3,785
  • 3
  • 14
  • 45
  • The problem isn't linking with `square.o`, it's about linking the whole application into `main.exe`. What the messages says is that the `square.cpp` file is using glew functions, and those can't be found when linking `main.exe`. – Some programmer dude Oct 21 '20 at 07:39
  • What is the purpose of the dependency to `square.o` to create `square.o` in the Makefile: `square.o: square.cpp square.o` ? Why not make it `square.o: square.cpp` or: `%.o : %.cpp` and `g++ -c -o $@ $< ...`? – Ted Lyngmo Oct 21 '20 at 07:41
  • Aren't these a bit too many backslashes? `-IC:\\\\Codin...` – Gerhardh Oct 21 '20 at 09:15

0 Answers0