Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't reference a library project (DLL) because .lib file is missing

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?

like image 956
EvilWeebl Avatar asked Mar 09 '13 16:03

EvilWeebl


People also ask

How do I open a .LIB file in Visual Studio?

To load the LIB file, select File → Load Library..., navigate to the location of your LIB file, select the file, and click Open.

What .LIB file contains?

Lib file is basically a timing model file which contains cell delay, cell transition time, setup and hold time requirement of the cell. So Lib file basically contains the timing and electrical characteristics of a cell or macros.

Can I use a DLL without lib?

Solution 1 Technically yes: you might use a DLL without having its import library ( . lib file), via DLL explicit linking[^]. However, if you don't have the DLL header file ( *. h ), that is you don't know DLL 's function signatures, then your task is extremely hard.


2 Answers

Many DLLs comes with corresponding LIB libraries, that are only needed at linking stage. So basically there are 2 types of LIB libraries:

  1. Real static library that contains all the object files

  2. 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

like image 174
nogard Avatar answered Sep 21 '22 10:09

nogard


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
like image 29
EvilWeebl Avatar answered Sep 21 '22 10:09

EvilWeebl