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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
EindacorDS
  • 107
  • 1
  • 3
  • 11
  • 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 '13 at 16:25

1 Answers1

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.

Community
  • 1
  • 1
Andon M. Coleman
  • 42,359
  • 2
  • 81
  • 106
  • 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](http://pastebin.com/gCanrGkX) is the source I'm trying to compile, and [here](http://i.imgur.com/fuSeb9C.jpg) is a screengrab of the errors I get. – EindacorDS Sep 15 '13 at 23:21
  • Well, you still have to link against opengl32, so add `-lopengl32` – Andon M. Coleman Sep 15 '13 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. – Andon M. Coleman Sep 15 '13 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 '13 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 '13 at 23:39
  • You also need to link against glut, so add `-lglut` or `-lglut32` (not sure which). – Andon M. Coleman Sep 15 '13 at 23:41
  • Since I'm trying to use freeglut, I added `-lfreeglut` instead. It compiles, but the exe will not run. Instead I get an error that says "the application was unable to start correctly (0xc000007b). I read in another post that this may be due to the libraries being 64 bit instead of 32. I also got a warning in MinGW that says `Warning: .drectv '/DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized` – EindacorDS Sep 16 '13 at 00:00