How do I include additional libraries with Code::Blocks?

Pages: 12
I need to make a program using TransparentBlt(), and thus I need the msimg32.lib library. The problem is that I can't figure out how to add msimg32.lib to my libraries. I'm using Code::Blocks, and I assume that it comes standard with Code::Blocks.
If this is any help, a book on programming I have has instructions for how to add msimg32.lib on Microsoft Visual Studio:
1. Open the project in Visual Studio (Visual C++).
2. Right-click on the project's folder in Solution Explorer and click Properties in the pop-up window.
3. Click the Linker folder in the left pane of the Properties window and then click Input.
4. Click next to Additional Dependencies in the right pane and type msimg32.lib.
5. Click the OK button to accept the changes to the project.
It came standard with mine, only in Code::Blocks you want "libmsimg32.lib". It's functionally the same thing.
Ok, I'll use that instead of msimg32.lib, but I still don't know how to add libraries with Code::Blocks.
#pragma comment(lib, "Your library name here")
If it don’t work try to give the full path to the file “c:\\program…”
Last edited on
What might be the full path to the library? Would it be through Code::Blocks?
Projects->Build Options
linker settings and under "Link libraries:"

full path: “C:\CodeBlocks\MinGW\lib\ + -.lib, .a FILE-”
Add "msimg32" to the link libraries, without any extension.
It still says TransparentBlt() as undeclared.
Last edited on
Have you defined _WIN32_WINNT 0x0501 first ? Mingw headers and code::blocks appwizard default are set to compile for windows95.
Only add msimg import library if you get 'unresolved reference' linker error, not 'undeclared identifier' compiler error.
Humm like modaran say maybe defined _WIN32_WINNT 0x0501first
Add this at the begin of your code
1
2
3
4
5
6
7
#ifndef WINVER
#define WINVER 0x0501
#else
#if defined(_WIN32_WINNT) && (WINVER 0x0400)
#error WINVER setting conflicts with _WIN32_WINNT setting
#endif
#endif 


Source: http://www.gamedev.net/topic/363728-transparentblt-win32-function-help/
@ modoran: I get the "undeclared identifier" compiler error.
@ sahzz: If I add that I get an error at #if defined... saying "missing binary operator before token '0x0400' "
You need to define WINVER 0x410 (or greater) as a global macro.
TransparentBlt & Co. were added with Windows 98, which 0x410 stands for.
To do this in Code::Blocks, add WINVER=0x0410 to #defines in Build Options.
Ok, so this is the list of all modifications to Build Options:

-Added libmsimg32 to Link Libraries under Linker.
-Added WINVER=0x0410 to #defines under Compiler.

After adding these, I get the same error.
FORCING the definition of the Windows version isn't going to help. That is a global macro setup so that the compiler knows what versions of what files to use when operating. What are you hoping to accomplish with that except to create MORE issues later down the road?

Why hasn't anyone asked the OP if they have included "WinGdi.h"? : http://msdn.microsoft.com/en-us/library/dd145141(VS.85).aspx

I've included <windows.h>, but not "WinGdi.h" specifically.
I'm glad I could help.
FORCING the definition of the Windows version isn't going to help.

Huh? Of course it is. If you do not set WINVER/_WIN32_WINNT accordingly, the appropriate function declarations of newer WinAPI functions (those that were introduced after Windows 95) will not be included.

Why hasn't anyone asked the OP if they have included "WinGdi.h"?

What for? windows.h is guaranteed to include wingdi.h, so that would be redundant.
closed account (3hM2Nwbp)
I think Computergeek01 means lying to the compiler about the windows version.
I don't think you understand. WINVER denotes to minimum Windows version you wish to support, not your own.
You can compile a program for Windows 7 on a Windows 95 machine just fine - in fact, you don't need Windows at all.
Last edited on
Pages: 12