SFML community forums
Help => General => Topic started by: Grimshaw on January 30, 2011, 02:29:11 am
-
I've got a problem and i am not sure where it is coming from...
I am building an engine, that engine is one DLL file, so when i build my project, i use it from the applications linking against engine.lib and then putting engine.dll in the same directory.
Now the problem: when i build, i link the DLL against sfml2 static libraries, and i get unresolved externals.
1>PerceptionDisplay.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall sf::Window::OnEvent(class sf::Event const &)" (?OnEvent@Window@sf@@EAEXABVEvent@2@@Z)
1>PerceptionDisplay.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall sf::RenderTarget::Draw(class sf::Drawable const &)" (?Draw@RenderTarget@sf@@UAEXABVDrawable@2@@Z)
1>VisionPrimitives.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall sf::Shape::GetNbPoints(void)const " (?GetNbPoints@Shape@sf@@QBEIXZ)
I am not sure what is causing this, in theory i can simply make my dll swallow all the static .lib it depends on, right? So the end user only uses engine.lib and engine.dll, without the need to know anything about sfml..And still have the sfml api exposed if he wants to use it.
I think i may be missing some knowledge on how to work with DLL's, if anyone could brief me shortly i'd appreciate.
Other issue is when i export a class which has a vector or string member, i get a compiler warning, and when i compile sfml, which does the same thing here and there, no warnings... What am i doing wrong? :O
needs to have dll-interface to be used by clients of class 'pE::PackageHeader'
Thanks
-
You would have to enable "Link Library Dependancies" - but that comes with a whole bunch of problems of its own. :)
-
Could you not compile sfml yourself as part of your project?
-
Now the problem: when i build, i link the DLL against sfml2 static libraries, and i get unresolved externals.
You're using 1.6 headers, these functions don't exist anymore in SFML 2.
Other issue is when i export a class which has a vector or string member, i get a compiler warning, and when i compile sfml, which does the same thing here and there, no warnings... What am i doing wrong? :O
Nothing. Just add this:
#ifdef _MSC_VER
#pragma warning(disable : 4251)
#endif
-
You were right, i was including SFML 1.6 by mistake from a old build directory.
Now i have another problem, a lot of unresolved externals when using sfml-graphics-s.lib, but it works with sfml-graphics.lib... Weird
Like the sfml-graphics-s.lib isnt recognized or something
-
In the CMake config, did you uncheck the "SHARED_LIBRARY" option?
-
For sure, i have all libraries compiled for sfml2, debug and release, static and release, just like sfml 1.6 used to be!
But the static ones aren't working for some reason:
error LNK2001: unresolved external symbol "__declspec(dllimport) private: virtual bool __thiscall sf::RenderWindow::Activate(bool)" (__imp_?Activate@RenderWindow@sf@@EAE_N_N@Z)
1>hey.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: virtual void __thiscall sf::RenderWindow::OnResize(void)" (__imp_?OnResize@RenderWindow@sf@@EAEXXZ)
1>hey.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: virtual void __thiscall sf::RenderWindow::OnCreate(void)" (__imp_?OnCreate@RenderWindow@sf@@EAEXXZ)
1>hey.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual unsigned int __thiscall sf::RenderWindow::GetHeight(void)const " (__imp_?GetHeight@RenderWindow@sf@@UBEIXZ)
a lot of those, even in a test project with REALLY minimal code.
#include <SFML/Graphics.hpp>
#pragma comment(lib, "sfml-system-s.lib")
#pragma comment(lib, "sfml-window-s.lib")
#pragma comment(lib, "sfml-graphics-s.lib")
int main(int argc, char **argv){
sf::Clock clocly;
sf::RenderWindow windowly;
return 0;
}
-
forgot to define SFML_STATIC?
-
Release preprocessor:
WIN32
_WINDOWS
NDEBUG
SFML_STATIC
_CRT_SECURE_NO_DEPRECATE
SFML_EXPORTS
GLEW_STATIC
STBI_FAILURE_USERMSG
CMAKE_INTDIR=\"Release\"
-
You have to define SFML_STATIC in your own project.
-
I dont recall doing that in SFML1.6, is it new? ;D
-
Yes it is. In SFML 1.6 it was SFML_DYNAMIC for linking to dynamic libraries.
-
EDIT: Everything seems allright, thanks for the help