0

OS: Windows 7

I have the source, as well as all the library files I'm using in one directory, on my desktop. I'm running the shell by using msys.bat, which was created when I installed MinGW. I've tried to run the following (and many others):

g++ -I. -L. -o opengltest.exe opengltest.cpp -lglew32 -lglew32s -lglew32.dll

I recieve the following error:

c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lglew32.dll

collect2: ld returned 1 exit status

This also happens when I use the -L switch and the entire C:/Users/... path, but I get the same error. Again, glew32.dll is in the same directory that the .cpp is in, which is the same directory I'm working in within the shell. I've tried multiple solutions from multiple posts, and it still seems like I'm missing something. I thought using the -L. was a straightforward way to tell MinGW to look in the working directory, but apparently it doesn't work that way.

1
  • I also noticed when I remove the -L., it returns errors that it can't find the other libraries either, which tells me that the switch is working correctly, it's just something about the .dll file it doesn't like.
    – EindacorDS
    Sep 15, 2013 at 16:25

1 Answer 1

1

Do not link against both the dynamic and static linking version of glew in the same application. This makes no sense. Also do no link against glew32.dll, this makes equally little sense.

Most importantly, do not use the DLL version of glew with g++ at all - it will not work (see one of my previous answers to understand why). Instead, #define GLEW_STATIC (better if you use -DGLEW_STATIC as a compiler switch) and only link to glew32s.

7
  • So glew32.lib and glew32.dll essentially contain the same information only one is formatted as a static library and the other is dynamic? Based on your suggestion, I added #define GLEW_STATIC to opengltest.cpp, then I ran g++ -I. -L. -o opengltest.exe opengltest.cpp -lglew32s, and I got a laundry list of undefined reference errors. For reference, here is the source I'm trying to compile, and here is a screengrab of the errors I get.
    – EindacorDS
    Sep 15, 2013 at 23:21
  • Well, you still have to link against opengl32, so add -lopengl32 Sep 15, 2013 at 23:22
  • No, glew32.lib is the import library, glew32.dll is the corresponding dynamic link library. DLLs work a little bit differently than normal shared objects. In any case, you do not need either one in your software. Sep 15, 2013 at 23:24
  • After reading the GLEW installation link, there are a few other things I don't get: It says "you may also need to change the include directives in glew.c". How does that factor in here? Nowhere in my working directory is a file called glew.c.
    – EindacorDS
    Sep 15, 2013 at 23:26
  • After adding -lopengl32 it's giving me a shorter list of errors, and they all seem to be regarding glut. In the installation instructions it mentions the glut.h file, but I thought that functionality was handled by the freeglut library. I didn't write this code, and the author seemed able to run it, so I'm guessing these errors have more to do with compiling than they do with an ommitted include file. Any thoughts? Really appreciate the help, by the way.
    – EindacorDS
    Sep 15, 2013 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.