Hey, I have no idea if this thread already exists. I did try to make one before but it seemse like it didn't work.
So here goes !

My question is - How do I put my .o files into an object library file?
I'm using c++ visual studio express 2008.
And I have created an gui library which I then want to reuse in other projects without having to have the .h and .cpp files within the new project.
And in order to do so I guess I'll need an object library file.
I do have my .o files or if I'm right object files, but I have no idea how to create an object library.
So if you know how to, please tell me.


7 Years
Discussion Span
Last Post by 140chris140

if I was unclear.
I need the information from my .o files or from my .h and .cpp files
into an object library. So I can use the functions from my .h/.cpp files outside of that project. Without adding the files into my project.
I just want to be able to #include "file.h" in order to be able to use the functions.


You probably want to start a new VS project that aims to build a library and add your work this far to that project.

The very basic (simplified) scenario goes something like this ...

The output of the project will be a library file (.lib) and optionally a dynamic link library (.dll). When you have your library built, you supply a header .h file, the .lib file, and if you built a .dll, then the .dll too, to anyone who uses the library. (If you don't build a .dll, then the code actually is in the .lib file, in which case it's called a static library).

The header file exposes your library's interface, keeping the end-user's compiler happy (and the end-user too).

The .lib file is needed in order for the end-user to be able to link with your library. And if you built a .dll, then the .dll, containing the actual code, must be available for the end-user at run-time.

Microsoft provides some terse documentation, just detailing out the steps needed for building libraries -> Creating Reusable Code (C++)

Perhaps just go through the steps described there, building a couple of libraries as you go.

Edited by mitrmkar: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.