Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: "Absorving" SFML into one DLL - MSVC  (Read 8127 times)

0 Members and 1 Guest are viewing this topic.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
"Absorving" SFML into one DLL - MSVC
« 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.
Code: [Select]

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
Code: [Select]
needs to have dll-interface to be used by clients of class 'pE::PackageHeader'

Thanks

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
"Absorving" SFML into one DLL - MSVC
« Reply #1 on: January 30, 2011, 09:48:24 am »
You would have to enable "Link Library Dependancies" - but that comes with a whole bunch of problems of its own. :)

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
"Absorving" SFML into one DLL - MSVC
« Reply #2 on: January 30, 2011, 10:05:04 am »
Could you not compile sfml yourself as part of your project?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
"Absorving" SFML into one DLL - MSVC
« Reply #3 on: January 30, 2011, 10:13:46 am »
Quote
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.

Quote
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:
Code: [Select]
#ifdef _MSC_VER
    #pragma warning(disable : 4251)
#endif
Laurent Gomila - SFML developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
"Absorving" SFML into one DLL - MSVC
« Reply #4 on: January 30, 2011, 04:06:14 pm »
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

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
"Absorving" SFML into one DLL - MSVC
« Reply #5 on: January 30, 2011, 04:35:35 pm »
In the CMake config, did you uncheck the "SHARED_LIBRARY" option?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
"Absorving" SFML into one DLL - MSVC
« Reply #6 on: January 30, 2011, 04:42:12 pm »
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:

 
Code: [Select]
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.

Code: [Select]
#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;
}

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
"Absorving" SFML into one DLL - MSVC
« Reply #7 on: January 30, 2011, 04:52:06 pm »
forgot to define SFML_STATIC?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
"Absorving" SFML into one DLL - MSVC
« Reply #8 on: January 30, 2011, 05:01:08 pm »
Release preprocessor:

WIN32
_WINDOWS
NDEBUG
SFML_STATIC
_CRT_SECURE_NO_DEPRECATE
SFML_EXPORTS
GLEW_STATIC
STBI_FAILURE_USERMSG
CMAKE_INTDIR=\"Release\"

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
"Absorving" SFML into one DLL - MSVC
« Reply #9 on: January 30, 2011, 05:51:19 pm »
You have to define SFML_STATIC  in your own project.
Laurent Gomila - SFML developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
"Absorving" SFML into one DLL - MSVC
« Reply #10 on: January 30, 2011, 05:52:17 pm »
I dont recall doing that in SFML1.6, is it new? ;D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
"Absorving" SFML into one DLL - MSVC
« Reply #11 on: January 30, 2011, 05:56:50 pm »
Yes it is. In SFML 1.6 it was SFML_DYNAMIC for linking to dynamic libraries.
Laurent Gomila - SFML developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
"Absorving" SFML into one DLL - MSVC
« Reply #12 on: January 30, 2011, 06:06:30 pm »
EDIT: Everything seems allright, thanks for the help

 

anything