I have a library (lib file + .h header file). I like to turn it into a DLL so I can easiliy use it in VB6. Is there a convenient way to do this?
Simply include the header file an a .def file in a new dll project and link it with the static lib.
The details of how to export symbols with a def file are here http://msdn.microsoft.com/en-us/library/d91k01sh(VS.80).aspx
Related
For example, I have 3 modules : Module1.cpp/h Module2.cpp/h and Module3.cpp/h, Now I will build it as a static library named as Modules.lib
Then I will create another project that will be built as a DLL. Modules.lib will be imported to the project since some source code have dependencies on Modules.lib. I will build it as Library.dll
Now this Library.dll will be used by a Windows App. How can I use the functions/classes in Modules.lib that was imported in Library.dll? How can I also export the header files(Module1.h, etc). When I add them in the header file of the dll, there is an error. The dll header file cannot find the included header file.
I can't find a specific example for this. Please show me an example. Thank you very much.
I want to include iostream inside a c++ dll file but am getting "fatal error: iostream: No such file or directory" error.
How can I include header files in a dll file?
There's no such a thing like "include header files in a dll file".
What you can do is:
include header files in a source code file (i.e. *.cpp),
then compile it to create a shared library (DLL file on Windows platform).
With Visual Studio 2013 I'm writing a Dynamic Library and I need to use some third-party libraries. Each library comes in the form of header .h, a .dll and .lib files. I added the library's directory to my project, I changed the "Configuration Properties -> C/C++ -> Additional Include Directories" to include the header file and I added the .lib file to the Additional Dependencies of the Linker.
If I try to include the header .h in my .cpp file using
#include "library.h"
everything works fine and the compiler it gives no error. But if I put this line in my header .h file and try to compile I get this error:
error C1083: Cannot open include file: 'library.h': No such file or directory
Any ideas? Thanks in advance.
I have a simple class (the analog clock from the Qt examples) that I want as a test to compile into a shared library. So what I want in the end is to have a .dll file and a .lib file.
What I did was simply create a new project, add the analog clock header and source file and then configure TEMPLATE = lib in the pro file.
Yet this only creates a .dll file and the article I found on the docs is not very helpful.
Does anyone know how can I solve this, and end up with both the dll and lib files?
EDIT 1
After doing this
#if defined(TEST)
#define AnalogClockPlug Q_DECL_EXPORT
#else
#define AnalogClockPlug Q_DECL_IMPORT
#endif
and then simply adding AnalogClockPlug in front of my main class and defining TEST in my pro file, qt generated a lib file.
Yet I am not sure I understand why exactly, or even if it is correct.
Q_DECL_EXPORT is just the same (under Windows) as __declspec(dllexport) pragma. It makes all the methods of your class to go to the dll 'exports' table (a special section in dll binary file).
Lib utility just reads the dll exports, and produces what is called 'the import library' - it's not like a usual static lib, containing actual code, but just a bunch of records stating that 'such procedure name' is to be found in 'such dll name'.
If you don't have that pragma, your dll exports table is empty, and lib utility refuses to output empty lib file. That's all.
To make a static library you will also need to add
CONFIG+= staticlib
to the .pro file
So in VS 2012, I've created a static library that i want to use in another project. When I try to use the library, I get errors trying to compile using the source files
"fatal error C1083: Cannot open source file: '<file used in library>.cpp':
No such file or directory
I feel like I'm missing something simple to make it work the way I want but I can't wrap my head around the way to do it.
Also, this may be irrelevant, but is there any automated way to combine headers to a single .h file to use for a library?
It looks like you're adding .cpp files from the library to your project. That's not the way to use a static library, instead add the library's .lib file (with the full path) in Configuration Properties | Linker | Input | Additional Dependencies, and then just add #include directives in your project's files to include any headers from the library you need to use.