Search code examples
c++visual-studio-2012releaselnk2019premake

Premake generated solution wont compile in Release but compiles in Debug


I have a Project set up in Premake that consists of a SharedLib and a ConsoleApp that links to that SharedLib. Furthermore, the SharedLib links to the SFML binaries.
I successfully setup before:
- A premake Project that contains a ConsoleApp and a SharedLib it links to
- A premake Project that contains a ConsoleApp that links to the SFML binaries
But combining both just wont work out in the releasebuild

Here is the output that MSVC 2012 produces:

2>  main.cpp
2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(void)" (__imp_??0RenderWindow@sf@@QAE@XZ) referenced in function _main
2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ) referenced in function _main
2>..\..\.bin\Example\Release\Example.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The folder structure of my premake Project:

SFML_PROJECT
|-- .libraries
|   `-- SFML-2.3.2-Win32
|       |-- include
|       |-- lib
|       `-- bin
|-- example
|   `-- main.cpp
|-- include
|   |-- App.h
|   `-- Config.h
|-- src
|   `-- App.cpp
`-- premake5.lua

And my premake5.lua (I am sorry for the rather large file but If I would shorten it I might miss something important)

To summarize my release config of the ConsoleApp:
- I added the SFML include
- I link to the SharedLib Project that links to the SFML binaries


Solution

  • I just added an empty constructor and destructor in App.h/App.cpp and it seems to work for now...

    I would really appreciate if somebody could explain me why I need to define those if I use App.h/App.cpp as part of a dll but not if I use them directly as part of an Executable.