I'm trying to make a game engine library but i'm having some trouble with setting up the project, properly.
i have an include folder where i keep the library headers.
and every class in the header files, have a __declspec(dllexport) for the MSVS compiler.
problem is, when i then try to create another project, for testing the engine, and include the headers, and then compile it, i get both an .exe and a .lib.
which i guess is because the headers still have the __declspec(dllexport) in them, which makes the MSVS compiler think it has to create a lib file even though its not building a library
how can i go about fixing this?
do i have to just, manually remove all the __declspec(dllexport) when im done making the engine, or?
In your dll project you need __declspec(dllexport). In all other projects that uses the dll you need __declspec(dllimport). You can solve the problem with macros.
When you make a dll project in visual studio you have already the macro _WINDLL defined while in standard project you have not. So you can do this:
1 2 3 4 5 6 7 8 9 10 11
#if defined _WINDLL
#define DLLTAG __declspec(dllexport)
#else
#define DLLTAG __declspec(dllimport)
#endif
...
DLLTAG class foo
{
};
Instead of _WINDLL you may define in the project settings your own proprocessor definition.
In your dll project you need __declspec(dllexport). In all other projects that uses the dll you need __declspec(dllimport). You can solve the problem with macros.
When you make a dll project in visual studio you have already the macro _WINDLL defined while in standard project you have not. So you can do this:
1 2 3 4 5 6 7 8 9 10 11
#if defined _WINDLL
#define DLLTAG __declspec(dllexport)
#else
#define DLLTAG __declspec(dllimport)
#endif
...
DLLTAG class foo
{
};
Instead of _WINDLL you may define in the project settings your own proprocessor definition.
In your dll project you need __declspec(dllexport). In all other projects that uses the dll you need __declspec(dllimport). You can solve the problem with macros.
When you make a dll project in visual studio you have already the macro _WINDLL defined while in standard project you have not. So you can do this:
1 2 3 4 5 6 7 8 9 10 11
#if defined _WINDLL
#define DLLTAG __declspec(dllexport)
#else
#define DLLTAG __declspec(dllimport)
#endif
...
DLLTAG class foo
{
};
Instead of _WINDLL you may define in the project settings your own proprocessor definition.
In your dll project you need __declspec(dllexport). In all other projects that uses the dll you need __declspec(dllimport). You can solve the problem with macros.
When you make a dll project in visual studio you have already the macro _WINDLL defined while in standard project you have not. So you can do this:
1 2 3 4 5 6 7 8 9 10 11
#if defined _WINDLL
#define DLLTAG __declspec(dllexport)
#else
#define DLLTAG __declspec(dllimport)
#endif
...
DLLTAG class foo
{
};
Instead of _WINDLL you may define in the project settings your own proprocessor definition.