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

Author Topic: link errors  (Read 1361 times)

0 Members and 1 Guest are viewing this topic.

annaL

  • Newbie
  • *
  • Posts: 3
    • View Profile
link errors
« on: April 04, 2022, 09:24:31 pm »
Hi -

I'm really excited about these tools, but I'm having a little getting started issue. I downloaded SFML-2.5.1-windows-vc14-32-bit from the SFML site. I'm using Visual Studio 2015 which I believe is actually running a 32 bit platform. I made a simple test case that only calls the following:


#include "SFML\Window.hpp"
#include "SFML\Graphics.hpp"

int main()
{
    // Create the main window
    int width = 640;
    int height = 480;
    sf::RenderWindow window(
      sf::VideoMode(width, height),       // size of the client area we want
      L"hdmidisplay"                      // The text to appear on the window title
    );
    return EXIT_SUCCESS;
}

but I get link errors when I compile - pasted below.

Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK1120   5 unresolved externals   SFMLTest   C:\Temp\SFMLTest\x64\Debug\SFMLTest.exe   1   
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __cdecl sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QEAA@III@Z) referenced in function main   SFMLTest   C:\Temp\SFMLTest\SFMLTest\Window.obj   1   
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __cdecl sf::String::~String(void)" (__imp_??1String@sf@@QEAA@XZ) referenced in function main   SFMLTest   C:\Temp\SFMLTest\SFMLTest\Window.obj   1   
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __cdecl sf::String::String(wchar_t const *)" (__imp_??0String@sf@@QEAA@PEB_W@Z) referenced in function main   SFMLTest   C:\Temp\SFMLTest\SFMLTest\Window.obj   1   
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: __cdecl sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QEAA@VVideoMode@1@AEBVString@1@IAEBUContextSettings@1@@Z) referenced in function main   SFMLTest   C:\Temp\SFMLTest\SFMLTest\Window.obj   1   
Error   LNK2019   unresolved external symbol "__declspec(dllimport) public: virtual __cdecl sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UEAA@XZ) referenced in function main   SFMLTest   C:\Temp\SFMLTest\SFMLTest\Window.obj   1   

I included my vcxproj. I'm linking to the debug version of the lib files, and I'm compiling for debug x64. I'm not sure what I'm doing wrong. Do I need to compile new lib files? If so, do I download source to compile from github?

I really appreciate your help. I tried to look through the forum and tutorials as much as possible. I'm sorry to bother you with such a simple problem.

Thanks,
Anna

fallahn

  • Sr. Member
  • ****
  • Posts: 464
  • Buns.
    • View Profile
    • Trederia
Re: link errors
« Reply #1 on: April 04, 2022, 11:13:38 pm »
I downloaded SFML-2.5.1-windows-vc14-32-bit from the SFML site.

 I'm compiling for debug x64

You can't mix 32/64 bit libs/build. You either need the 64bit libs, or switch to a 32 bit build  :)

annaL

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: link errors
« Reply #2 on: April 05, 2022, 12:58:10 am »
I'm still a little confused, I'm sorry! As I understand it I should be linking to SFML lib files that are compatible with my Visual Studio platform (as opposed to my OS). It is my understanding that Visual Studio 2015 isn't offered as a 64 bit program, but it still allows you to compile for either 64 bit or 32 bit operation. So, in order to compile a 64 bit program I need to use the 64 bit SFML libs and I need to upgrade to a 64 bit version of Visual Studio? 

Thank you so much for your help! I'm sorry I'm asking such silly questions.

Best regards,
Anna

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10235
    • View Profile
    • development blog
    • Email
Re: link errors
« Reply #3 on: April 05, 2022, 08:00:59 am »
Binaries for VS 2015 can certainly be downloaded for 64-bits: https://www.sfml-dev.org/download/sfml/2.5.1/

As fallahn pointed out, you've currently set things up for x64 (i.e. 64.bits), but are using, by your own account, 32-bits SFML libraries. This is incompatible with each other. ;)



If you use x64 for your compiler, you also need to use SFML's 64-bits libraries.

Btw. I highly recommend updating to VS 2022.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

fallahn

  • Sr. Member
  • ****
  • Posts: 464
  • Buns.
    • View Profile
    • Trederia
Re: link errors
« Reply #4 on: April 05, 2022, 10:26:02 am »
To clarify: It doesn't matter if Visual Studio itself is a 32 bit or 64 bit application. Either version can compile 32 or 64 bit programs. You just need SFML to match the program you're compiling.

annaL

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: link errors
« Reply #5 on: April 05, 2022, 09:26:52 pm »
Thank you!!!! It works. This is so exciting. But, I realized I've been thinking about SFML wrong. I was trying to load an array of data into a texture, and then display the texture in my window. But I think these functions are meant for working with an actual image file, not just arrays. So I get an error. I think I'm using the wrong class entirely. Could you point me in a better direction?

Thank you so much for all your help! I'm really excited that this is nearly functional.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10235
    • View Profile
    • development blog
    • Email
Re: link errors
« Reply #6 on: April 05, 2022, 11:14:50 pm »
For general use of SFML, I highly recommend to check out the tutorials on the topic you're interested in and for more details, look at the API documentation.

If you have an array of pixel data in the RGBA layout, you can call update() on the texture directly.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

 

anything