View Full Version : winmm.lib

10-23-2002, 09:45 PM
I just wrote a very simple opengl app using C++ and glut. But when it compiles it gives me some linking errors. Here is the code:

#include <windows.h>
#include <gl\glut.h>

void init(void);
void display(void);

int main(int argc, char** argv)
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB) ;
glutInitWindowSize (400, 100) ;
glutInitWindowPosition (100, 100) ;
glutCreateWindow ("First Chapter - Opening an OpenGL Window") ;

init() ;
glutDisplayFunc (display) ;
glutMainLoop () ;
return 0 ;

void init(void)
glClearColor(1.0, 1.0, 1.0, 0.0) ;
glShadeModel(GL_FLAT) ;

void display(void)
glutSwapBuffers() ;

That code is just from a tutorial I followed on opening a window using glut. The error I get when compiling is this:

link gltest,,,user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved

Warning 2: File Not Found winmm.lib
Error 43: Not a Valid Library File

--- errorlevel 1

I know that I need this winmm.lib, but I cannot find it anywhere at all, so I figure I'm just doing something wrong. What is going on? What do I need to do to fix this?

BTW, I'm using that free digital mars compiler, could that be part of the problem?

10-23-2002, 11:08 PM
U have to include winmm.lib at your linking project.
1)click project
2)select setting
3)select link
4)type winmm.lib in the object/library module.
That;s it.

10-24-2002, 08:53 AM
U have to include winmm.lib at your linking project.
1)click project
2)select setting
3)select link
4)type winmm.lib in the object/library module.
That;s it.
Ummm, no, that's not it. I'm not familiar with this particular compiler, but the error message indicates that he does not have winmm.lib and that opengl32.lib is not the right one. Did you get this opengl32.lib with your compiler or somewhere else? You do realize that most compilers can't read the library files of other compilers, don't you? Try to get the correct libraries. If you can't find them, get another compiler. Try downloading Dev-C++ from: http://www.bloodshed.net/dev/devcpp.html

10-24-2002, 09:19 PM
Thanks for telling me about that compiler aaron, I was looking for something like that. But now, when I compile (same code) I get:

Building Makefile: "C:\Dev-Cpp\gluttest\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\gluttest\Makefile.win" all
g++.exe gluttest.o -o "gluttest.exe" -L"C:/Dev-Cpp/lib" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/g++-3" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/gl" -s

gluttest.o(.text+0x17):gluttest.cpp: undefined reference to `__glutInitWithExit@12'
gluttest.o(.text+0x37):gluttest.cpp: undefined reference to `__glutCreateWindowWithExit@8'
gluttest.o(.text+0x5b):gluttest.cpp: undefined reference to `__glutCreateMenuWithExit@8'
gluttest.o(.text+0xd0):gluttest.cpp: undefined reference to `glutInitDisplayMode@4'

gluttest.o(.text+0xe2):gluttest.cpp: undefined reference to `glutInitWindowSize@8'
gluttest.o(.text+0xf1):gluttest.cpp: undefined reference to `glutInitWindowPosition@8'
gluttest.o(.text+0x116):gluttest.cpp: undefined reference to `glutDisplayFunc@4'
gluttest.o(.text+0x11e):gluttest.cpp: undefined reference to `glutMainLoop@0'
gluttest.o(.text+0x148):gluttest.cpp: undefined reference to `glClearColor@16'
gluttest.o(.text+0x155):gluttest.cpp: undefined reference to `glShadeModel@4'
gluttest.o(.text+0x16f):gluttest.cpp: undefined reference to `glClear@4'
gluttest.o(.text+0x177):gluttest.cpp: undefined reference to `glutSwapBuffers@0'

make.exe: *** [gluttest.exe] Error 1

Execution terminated

I found the libwinmm.a which I assume is the winmm.lib for devc++. But when I add libwinmm.a into "Linker Options/Optional libs or object files" under Project Options it says it cannot find it. Then when I put in the entire path to the libwinmm.a file, I guess it finds it, but it gives me the original error again.

10-25-2002, 02:08 AM
hm, i don't see any undefined references depending on winmm.lib.
for those listed, include opengl32.lib and glu32.lib.

(btw, i don't know any compiler having libraries not ending with *.lib .. so i guess your libwinmm.a file 'was' just the sourcecode for your compiler to build winmm.lib)

10-25-2002, 05:38 AM
Libraries for GCC (The GNU Compiler Collection) are named lib<name>.a. The ".a" stands for "archive". You include them with the command -l<name>. Dev-C++ is just an IDE for the Windows port of GCC (and a very good one at that). I don't see any libraries in the line that links your code:

"g++.exe gluttest.o -o "gluttest.exe" -L"C:/Dev-Cpp/lib" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/g++-3" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/gl" -s
To include libraries in your project, go to the Project menu, then Project Options. In the line that says "Linker Options/Optional Libs or Object Files" enter -lopengl32 and -lglut32 and any other libraries that you decide you need.

10-25-2002, 01:21 PM
Thank you very much aaron, that worked.