Alright. I am (attempting) to use this http://sites.google.com/site/rcorcs/download/systemsoftware simple database library in VC++ 2008 Express. I admit that I am a newbie to C++, since Ive used only "light" programming languages like python, php, java.

To use it I have the header files, and as "lib" folder I have a dll and a ".a" file. In a project before I used a .dll and a .makefile file to create a .lib, but this time I dont know what to do anymore. I have found out that the ".a" in linux is the equivalent of a ".lib" in windows, but I have not found any way to use it in VC++.

Could somebody please tell me what to do in order to be able to use this library(In VC++ 2008 ofc)?

Recommended Answers

All 4 Replies

If it's not a library that was built for Windows, you won't be able to use it.

libraries with *.a extension were produced with GNU compiler, such as g++ on *nix and MinGW on MS-Windows. They are not usable with Microsoft compilers.

Ok. Thank you, I will try to build it on my own then.

Depending on the way that the DLL was compiled, it might be possible for you to use it from a VS2008 project.

The easiest solution, of course, is to contact the issuer of the library in question and ask for a VisualC++ import library (or the source code so that you can recompile the DLL yourself). If they don't want to bother providing that, then, besides cursing at them or considering finding another library with similar capabilities, you can read further.

First of all, the dll was compiled with MinGW (almost certainly). The .dll file contains the actual code and the .a file is called an "import library" (and the "a" stands for "archive" which is GNU jargon for "static library").

Second, all DLLs are not the same. The main thing that can be different is the name-mangling (which is a kind of encoding of the names of the functions) which is different from one compiler to the next (but usually, each compiler-vendor adopts some convention that make libraries compiled with different versions of the compiler compatible with each other). Generally, the name-mangling of one compiler(-brand) is not compatible with the name-mangling of another. Fortunately, the name-mangling can be disabled by specifying that the functions (and the library) should be compatible with or callable from C code, because C doesn't have or need name-mangling. So, if the functions in the headers (whose code are in the DLL) are all declared with extern "C" or within a giant extern "C" { .... } , then it means that you should able to use those functions from pretty much anywhere (any C++ compiler, C compiler, or even Python or others). If it is not the case, then you will not be able to use that library from a VS2008 project.

So, at this point, if all the DLL functions are C-compatible, then all you need is to generate an import library for the DLL. This could be a tedious process if there is a large amount of code, but essentially, you can follow these instructions. If that fails, you can try to use the functions by loading them at run-time (which doesn't require an import library), see this page.

If the above is prohibitively long to do, then the only solution remaining is to switch to MinGW for your project, or find another library instead of that one. To use MinGW, you can also use the Qt Creator IDE which will install MinGW too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.