why do we need to "build" a library

Hi guys sorry about the confusing title but why do we need to build a library or framework before we can actually use it?

for example yesterday I installed FLTK and before I could use it I had to build the solution even though I added the include files and .lib files to the compiler

it was the same case for SDL and WXWidgets I had to "build" the framework before I could use it,why can't I just use the framework right away when I have added the includes and .lib files?

thanks
If you're on Windows, there are Windows builds available for SDL, and I'm almost certain there are for wxWidgets. I could not tell you why you're building them.

Your question somewhat confuses me. A .lib file is the product of building a library. It's not possible to have the .lib corresponding to a library before the library is built. I have no idea what you're doing such that you have a .lib but are not able to "use" the library (whatever that means).
Windows recognises two kinds of lib file.

One is a static library; compiled code, ready to link against. When you have one of these, you don't need to build anything.

The other is an import library, that goes with a *.dll file, and is helpful in linking against that *.dll file. Generally, you create (or get) the *.lib and its *.dll together.

https://stackoverflow.com/questions/32548951/are-there-different-types-of-lib-files?rq=1


All that aside, if you downloaded the set of files under "Development Libraries" here - https://www.libsdl.org/download-2.0.php - then you don't need to build any SDL.

What did you actually download?

Last edited on
A 'library' is simply compiled code that lacks a 'main' or entry point. Many windows libraries actually come compiled, or many commercial ones do; often you don't get the source code only the lib/dll etc files when you buy a library. A lot of opensource, portable (usable on unix/win/etc) and such libraries are in source code format and those you have to build because they are source code, and not compiled for your system.

so it will vary; you are just using the ones that need to be compiled.
MANY/MOST of the opensource etc libraries can be found in a compiled format for windows because someone did it for you and uploaded it.





Your question somewhat confuses me. A .lib file is the product of building a library. It's not possible to have the .lib corresponding to a library before the library is built. I have no idea what you're doing such that you have a .lib but are not able to "use" the library (whatever that means).


Actually I didn't have the .lib files from FLTK until I built it that is true but what I did have in the lib folder before I built it was .a files ?

Also come to think of it i didn't have to build SDL but I did have to build WXwidgets

thanks guys
Last edited on
I just downloaded the FLTK tarball and I don't see any .a files. It would be rather unusual for a source archive to include .a files.
There are multiple C++ compilers, particularly for Windows. MSVC++, differently ported GCC, etc. Not all follow exactly same conventions. Therefore, not all lib/dll are equal. Your chances to succeed can be better, if you compile both the framework and your app with same toolchain.

That said, yes, many packages are available precompiled. Just pay attention to what you download.


When you compile your app, you do generate object files and then link those object files and necessary libraries. For that, those libraries have to exists. If your own app is divided into main executable and some libraries, you have to link your libraries before linking the main executable.

If you have to update some code, then you don't have to recompile everything, just the affected parts. Such dependencies are part of a project.
Thanks guys,I remember when I was building and compiling wxwidgets before I could use it I had to put the following command into the command line to build and compile it

mingw32-make -f makefile.gg BUILD=release SHARED=1 MONOLITHIC=1

I'm not sure exactly what this did especially the ming32 with the - make flag

and SHARED=1 and MONOLITHIC=1

why did I need to use this command in order to build and compile wxwidgets?
The makefile gives instructions on how to build the library. SHARED=1 means you have to put the generated dynamic link libraries (DLLs) in the same folder as your .exe to run the executable by itself. MONOLITHIC=1 is a wxWidgets-specific option that combines all the functionality to be inside one DLL instead of multiple DLLs.

https://wiki.wxwidgets.org/WxWidgets_Build_Configurations

Personally, I started using msys2's utilities at the end of last year, which I find to be much easier for compiling libraries for MinGW.
Topic archived. No new replies allowed.