I'm trying to start a C++ game engine project.
I don't have much knowledge of dll's and lib's but figured the engine itself would be a dll and I would have separate dll projects such as renderer, input, etc that would be used by the engine and the engine dll would be used by the game.
I seem to have the engine project referenced fine in the demo.exe project(by adding a reference and adding the path to additional include directories) but when trying to add a reference to a renderer dll project in the engine dll project I'm getting:
error LNK1104: cannot open file 'MyPath\Renderer.lib' MyPath\LINK
Engine
Why is it mentioning libs?
Many DLLs comes with corresponding LIB libraries, that are only needed at linking stage. So basically there are 2 types of LIB libraries:
Real static library that contains all the object files
Library with only definitions for the linker, this kind of libraries comes with DLLs
So basically you need to link this LIB file in order to be able to work with DLL
So I sorted my problem. As they were new projects they had no methods implemented yet, so no lib was being created, so nothing to reference to..silly me.
One last thing though, I'm having trouble defining the dllimport/dllexport macro for a header file. I'm trying to get it to define dllexport when its the exporting project but say my project is 2 names, e.g "awesome engine" then how do I realise the export macro that apparently is created automatically? Should I use an underscore for the space?
#ifdef AWESOME_ENGINE_EXPORTS // Or AWESOMEENGINE_EXPORTS?
#define DLL __declspec(dllexport)
#else
#define DLL __declspec(dllimport)
#endif
the engine project referenced fine in the demo.exe project(by adding a reference and adding the path to additional include directories)
Some libraries can be linked statically, meaning that you need only header files (.h
/.hpp
) and .lib
files. Other libraries might require dynamic linkage that will result into your program being dependent on some DLL files, but usually you will need to have header files to know what is in those DLLs anyway. Sometimes, which seems to be your case, you need all of them: header files, static libraries and DLLs.
Header files contain declarations, they define the structure of your classes, they declare prototypes of your functions, etc. Static libraries (.lib
files) are binaries, that contain definitions of your functions, variables and so on, that need to be resolved at compile time, so when they are missing, the linker will complain. Dynamically linked libraries (DLLs) are binaries as well, but they are resolved at run-time, meaning that the time when you really need them is when you run your program.
Generally,
The library may give you it's APIs in two modes:
Dynamic: Smaller executable file, but needs its DLLs.
Static: Larger executable file, but stand-alone.
First of all, decide how do you want to use that library, statically or dynamically?! Then configure your project which the compiler be able to find header files of that library.
Then if it's necessary add LIB files to your project.
In your case: Check if you added LIB files correctly to your project or makefile, or not?