User forums > Using Code::Blocks
LIB files HowTo
russellman:
I have code block ver 1 rc 2, windows xp, GNU gcc compileer, and MinGw.
I wount to use PlaySound() it's header is #include <mmsystem.h> The lib is winmm.lib .
In visual c++ 6 to add a lib to code you.
#include <mmsystem.h> //include the HEADER file for PlaySound().
#pragma comment(lib,"Winmm.lib") //include the LIB file for PlaySound().
Then you can use PlaySound().
How do you do it in code::block ver 1 rc 2?
Gary Russell
ghrussel@swbell.net
TDragon:
Most standard Platform SDK libraries (including winmm) are included in MinGW with the .a extension. So you would use either #pragma comment(lib,"libwinmm.a"), or the more portable method of adding "winmm" to the list of libraries to link (found in your project's Build Options).
russellman:
When I add #pragma comment(lib,"libwinmm.a") I get
error
mingw32-g++.exe: .objs\lib\libwinmm.o: No such file or directory
(found in your project's Build Options). I tried it too.
thomas:
#pragma comment(lib,"Winmm.lib") is a non-standard Microsoft feature (felony).
No IDE supports this, and this is a common stumbling block when using any other IDE.
You have to add the link libraries in the project's linker options (on the left side of that dialog). It is normally not necessary to worry about the extension, in most cases the base name will do (the IDE takes care of the rest).
An alternative for gcc is to specify the libraries by giving the -l flag in "additional options" (but forget about that, it is a lot more comfortable to let the IDE do the dirty work).
TDragon:
--- Quote from: thomas on March 29, 2006, 01:11:03 am ---No IDE supports this, and this is a common stumbling block when using any other IDE.
--- End quote ---
Not sure exactly what you mean by this, but DMC supports #pragma comment(lib, "..."). I'm too lazy to check whether GCC does, so I'll assume it doesn't. Whatever the case, it is indeed an inappropriate and error-prone way of specifying link libraries.
Navigation
[0] Message Index
[#] Next page
Go to full version