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

Author Topic: *RESOLVED* Is this a linking problem? "unresolved external symbol"  (Read 4730 times)

0 Members and 1 Guest are viewing this topic.

garlicfiend

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
*RESOLVED* Is this a linking problem? "unresolved external symbol"
« on: September 05, 2020, 09:46:54 pm »
Hi all, I'm new here

I followed the installation guide.  Initially, I got a bunch of errors when trying to build the test code at the end of the guide, and I thought I finally had my linking sorted, but I left with only three errors.

I installed Visual Studio 2017 (specifically to have a compatible version of SFML).
I downloaded and extracted SFML-2.5.1-windows-vc15-64-bit

I followed the "SFML and Visual Studio" guide on the SFML website.

The guide says I "you must select "Win32 application"." VS 2017 doesn't list that as an option, so I picked Visual C++ > Empty Project.

I put the SFML include directory in the C++ Additional Include Directories, and the SFML lib directory in the Linker Additional Libray Directories. I also added C:\\SFML\lib\sfml-window-d.lib; C:\\SFML\lib\sfml-graphics-d.lib; to Linker > Input > Additional Dependencies

I also added sfml-window-d-2.dll and sfml-gfraphic-d-2.dll to the output directory.

Here is the code I compiled (straight off the installation guide):

#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                window.clear();
                window.draw(shape);
                window.display();
        }

        return 0;
}

And here are the build report:

1>------ Build started: Project: Tut1, Configuration: Debug x64 ------
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QEAA@PEBDAEBVlocale@std@@@Z) referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl sf::String::~String(void)" (__imp_??1String@sf@@QEAA@XZ) referenced in function main
1>C:\Users\garli\source\repos\Tut1\x64\Debug\Tut1.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "Tut1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Hoping someone can help me out with this,

Thank you!
« Last Edit: September 08, 2020, 04:55:07 am by garlicfiend »

Zel

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Is this a linking problem? "unresolved external symbol" only for sf::String
« Reply #1 on: September 06, 2020, 03:37:15 am »
SMFLGraphics and  SMFLwindow both have SFMLsystem as a dependancy.

Try adding SFML-system-d.lib and SFML-system-d.dll.


garlicfiend

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Is this a linking problem? "unresolved external symbol" only for sf::String
« Reply #2 on: September 08, 2020, 04:54:12 am »
Thank you, that worked!

Zel

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: *RESOLVED* Is this a linking problem? "unresolved external symbol"
« Reply #3 on: September 08, 2020, 06:14:13 am »
You are welcome.