Reputation: 191
So, I made a dll and it compiles great. Then I referenced this dll I made in another project and received this error message:
error C1083: Cannot open include file: 'openssl\ssl.h': No such file or directory
this .h file is used inside the dll, I would think that by referencing the dll I should not have to include this file directly... Shouldn't a dll have all the files needed for it's purpose "inside it"?
Upvotes: 2
Views: 2656
Reputation: 4788
No, because:
.dll
is a compiled, binary file that can be dynamically loaded at runtime by .exe
programs..h
(or .hpp
) file contains source code definitions of function prototypes or data structures for your C/C++ program, which are used during compilation.To compile your source code, you'd need to:
#include
the header file(s) so that the rest of your code knows what the data structures and function signatures stored in the DLL look like..lib
or .a
file equivalent of the .dll
file.If all goes well, then the .exe
file generated by the compilation process will be able to dynamically load in and use the (already compiled) functions stored in the .dll
file.
Upvotes: 2
Reputation: 23900
Shouldn't a dll have all the files needed for it's purpose "inside it"?
No. A DLL contains machine code.
The main difference between .c
and .h
files is that .c
files contain Code and .h
files contain Headers (i.e. that's what they're supposed to, although they're not bound to). You need those header files in order for the compiler to know what to look for in the DLL. After your program has been compiled and linked, the header files are not required anymore.
That's why the authors of libraries written in C or C++ which are not open source usually provide precompiled binaries as well as header files.
A file format containing machine code and headers would be possible, but to my knowledge, no such format exists, and it would be really bad if it did, because for a lot of programs that would mean huge executable files.
Upvotes: 3