Install a library under Codeblocks for MinGW

April 2018


You have a version of CodeBlocks making use of the MinGW compiler and you have recovered the binary of an external library that you want to use (it is also compiled for MinGW).
In the following example, we will use libcurl library to illustrate the method used: e.g, the date at which the lines were written, the current and stable version of libcurl:
(Get the updated version on
This method can be used with Codeblocks (with MinGW) for any library compiled for MinGW.


Decompress in a directory - centralize the external libraries

Unpack the archive containing the compiled library in an easy to access directory (with a name without spaces).
  • For example: c:\libs\curl-7.28.1-devel-mingw32\

Integration to the Codeblocks project: 2 steps

There are 2 modifications that are required to make use of an additional library under Codeblocks:

Indicate the compiler where to find the .h files.

Tell the compiler where to find the .h files will prevent errors when inserting #include corresponding to the library in the source code.
This is done in:
  • Project - Build options
  • Click on the project root (not on Target or Debug, otherwise the settings won't be applied)
  • Go to the "Search directories" tab > Add > fetch the directory that contains the .h files (in our example: libcurl c:\libs\curl-7.28.1-devel-mingw32\include) and select the directory .

Indicate the editor where to find the binaries of the library

Tell the editor where to find binaries of the library, will allow it to generate the executable after compilation, e.g for the environment MinGW (.a extension).
This is done in:
  • Click on the project root (not on Target or Debug, otherwise the settings won't be applied)
  • Go to the "Linker settings" tab > Add > fetch the directory that contains the .a files (in our example: libcurl c:\libs\curl-7.28.1-devel-mingw32\lib) and select the parts of the library needed.


The .dll files

Depending on how you set up your project (dynamic or static link), you may have to copy .dll files in the executable directory (or in the Windows PATH), to enable the dynamic loading of the library.

In the case of libcurl, the .dll are found in: c:\libs\curl-7.28.1-devel-mingw32\bin

You need to add them, for example, in the "Target" of the project, containing the executable generated after compilation (or somewhere in the PATH), and this is only necessary when compiling with dynamic links and to start the executable outside of the development environment.

===Relative or absolute paths==

When you configure Codeblocks parameter, after selecting a resource, you will be prompted with a message: "Keep this as a relative path?".

If you choose to keep the relative path, it means that CodeBlocks won't store the absolute path to the specified resource (e.g "c:\libs\curl-7.28.1-devel-mingw32\lib\libcurl.a"), but only the path relative to the project directory (e.g "..\..\..\libs\curl-7.28.1-devel-mingw32\lib\libcurl.a").

It is useful to specify a relative path if the resources are available in the project directory. The project can be compiled on another machine with CodeBlocks.

Do not copy the external library in the MinGW directory

It might work and there are many tutorials that recommend this step.

However, I do not recommend doing this, unless you want to:

- Mess with the installation of CodeBlocks.
- Reinstall all your libraries because you have updated CodeBlocks or MinGW.
- Do not know how to update your libraries.

Original document published by Dal on
Published by deri58. Latest update on January 30, 2013 at 07:37 AM by deri58.
This document, titled "Install a library under Codeblocks for MinGW," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
C Language - Generate random values
CAML- Categorical Abstract Machine Language