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

Author Topic: Problems using SFML with Visual Studio 2015 Enterprise (Solved)  (Read 13033 times)

0 Members and 1 Guest are viewing this topic.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Problems using SFML with Visual Studio 2015 Enterprise (Solved)
« on: September 11, 2015, 08:43:22 pm »
Hello

I'm trying to add SFML to Visual Studio 2015 Enterprise, I've followed this tutorial EXACTLY the same way:
http://www.sfml-dev.org/tutorials/2.0/start-vc.php

And tried out the code listed there.
But it ain't working, I get this error:
Quote
Severity   Code   Description   Project   File   Line
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2001   unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Green" (__imp_?Green@Color@sf@@2V12@B)   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2001   unresolved external symbol "__declspec(dllimport) public: static class sf::RenderStates const sf::RenderStates::Default" (__imp_?Default@RenderStates@sf@@2V12@B)   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::CircleShape::~CircleShape(void)" (__imp_??1CircleShape@sf@@UAE@XZ) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (__imp_?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (__imp_?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Shape::setFillColor(class sf::Color const &)" (__imp_?setFillColor@Shape@sf@@QAEXABVColor@2@@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __thiscall sf::CircleShape::CircleShape(float,unsigned int)" (__imp_??0CircleShape@sf@@QAE@MI@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (__imp_??0Color@sf@@QAE@EEEE@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main   ConsoleApplication1   c:\Users\Niel\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj   1
Error   LNK1120   17 unresolved externals   ConsoleApplication1   c:\users\niel\documents\visual studio 2015\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe   1


The only problem I could think of, is that I'm using Visual C++ version 14, and not the supported ones by SFML.

I'm using Windows 8 by the way.

But anyway, how can I fix this problem?

Thanks for reading,
Niely
« Last Edit: September 18, 2015, 10:05:34 pm by Niely »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #1 on: September 11, 2015, 09:14:09 pm »
I'm trying to add SFML to Visual Studio 2015 Enterprise, I've followed this tutorial EXACTLY the same way:
http://www.sfml-dev.org/tutorials/2.0/start-vc.php
Latest version for SFML 2.3:  http://www.sfml-dev.org/tutorials/2.3/start-vc.php

The only problem I could think of, is that I'm using Visual C++ version 14, and not the supported ones by SFML.
You need to compile your application with the exact same compiler that was used to compile SFML (yes, that may sometimes mean down to the same minor patch version). The easiest way to ensure this is to not rely on pre-built binaries, but simply compile SFML yourself with the same compiler you use for your app.
Note: this goes for any C++ library and is not specific to SFML.
Also, you must take care to link the debug version of SFML if you build a debug version of your app. Same for release builds. If you mix them up, stuff will break.
« Last Edit: September 11, 2015, 09:41:56 pm by Jesper Juhl »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Problems using SFML with Visual Studio 2015 Enterprise
« Reply #2 on: September 11, 2015, 09:18:10 pm »
And for VS 2015 you'll also have to rebuild the SFML dependencies or use the not yet finalized feature/vs2015 branch.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #3 on: September 11, 2015, 09:19:05 pm »
How exactly would I do that all?
In G++ on Linux I just did g++ -input -output -SFML-libraries and ready. Why ain't this that simple on an IDE?


Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #4 on: September 11, 2015, 09:26:40 pm »
It is fairly simple.
Just use cmake to generate build files for your environment. Build the library and install it. Then build and link your app. It takes about 10 minutes tops and the tutorials explain how if you've never done it before.
Building the dependencies is a little more work, but not too big a deal.
If it's causing you too much trouble, either use VS2013 for now (which has pre-built binaries) or use eXpl0it3r's nightly builds for VS2015 or just wait for  official VS2015 binaries.
But really, building it yourself is not that difficult - and knowing how to build your dependencies from source (SFML or other libs) is something every developer should know how to (or learn how to) do since it's going to be needed/useful often. And SFML is amongst one of the easier libs to build...

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #5 on: September 12, 2015, 03:25:56 pm »
That tutorial is not working, I download SFML and there should be a CMakeLists.txt file, but there is none.

CMake error:

Quote
CMake Error: The source directory "C:/SFML" does not appear to contain CMakeLists.txt.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #6 on: September 12, 2015, 03:28:03 pm »
Clone the git repository.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #7 on: September 12, 2015, 03:48:06 pm »
Okay that worked.

I've now got a Nmake executable, but what exactly is my next step now? How can I now use my SFML library with Visual Studio (VC++)?

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #8 on: September 13, 2015, 04:33:54 am »
Use CMake as the file name suggests. There is even a tutorial on compiling with CMake: http://www.sfml-dev.org/tutorials/2.3/compile-with-cmake.php

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #9 on: September 13, 2015, 10:17:15 am »
I have followed that tutorial until the bottom, but I don't understand the bottom. Do I have to build SFML? How? And how do I use it with Visual Studio 2015 then?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #10 on: September 13, 2015, 10:19:14 am »
Yes, you have to build SFML. That's the whole point of the exercise.
Once it's built you use it just like you would the pre-built library.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #11 on: September 13, 2015, 10:35:25 am »
But I don't see the option 'build' anywhere in CMake.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #12 on: September 13, 2015, 11:00:33 am »
Did you read this http://www.sfml-dev.org/tutorials/2.3/compile-with-cmake.php ? It specifically says what to do and when.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #13 on: September 13, 2015, 11:03:14 am »
Yes, I've read it to the end.
But I don't understand if I now have to do:
nmake C:\SFML\ ./build or not.
Or nmake C:\SFML-build\ ./build
.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Problems using SFML with Visual Studio 2015 Enterprise
« Reply #14 on: September 13, 2015, 07:17:50 pm »
Not trying to be snarky or annoying (at least not too much), but have you considered actually trying some of the commands you are in doubt of?
Sometimes experimentation can provide results ;)