2
votes

I am trying to use GLEW in a program I'm creating, but my compiler will not compile it, instead it throws a ton of errors at this line gcc -g -c glew.c -o glew.o. This is my Makefile:

MY_LIBS = 
glewex: glew.o main.o glew.h
    g++ main.o glew.o glew.h -o glewex $(MY_LIBS)
glew.o: glew.c
    gcc -g -c glew.c -o glew.o
main.o: main.cpp
    g++ -g -c main.cpp -o main.o

It simply outputs hundreds of errors that look like this:

__glewActiveTexture redeclared without dllimport attribute: previous import ignored [ -Wattributes ]

2

2 Answers

4
votes

Try this:

gcc -g -DGLEW_STATIC -c glew.c -o glew.o

That should prevent DLL import/export decorations from getting added to the declarations.

-2
votes

You don't want to add the library source files to the compiler input of your project. You should add the library to the list of linker inputs; either statically (libglew.a) or dynamic (-lglew).

I.e. either

gcc -o … -lglew

or

gcc -o … libglew.a

When linking GLEW statically you must add -DGLEW_STATIC to the compiler options generating the compilation units (.o files)