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

Author Topic: Issue with building a window  (Read 5109 times)

0 Members and 1 Guest are viewing this topic.

roystben

  • Newbie
  • *
  • Posts: 5
    • View Profile
Issue with building a window
« on: July 13, 2011, 07:41:31 am »
Here is the error that is showing up.

1>------ Build started: Project: Window, Configuration: Debug Win32 ------
1>window-window.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" (__imp_??1Window@sf@@UAE@XZ) referenced in function _main
1>window-window.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Display(void)" (__imp_?Display@Window@sf@@QAEXXZ) referenced in function _main
1>window-window.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function _main
1>window-window.obj : 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
1>C:\Users\Ben\Desktop\Window\Debug\Window.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I am using Visual C++ 2010, any info on how to fix this would be great.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Issue with building a window
« Reply #1 on: July 13, 2011, 07:44:18 am »
You must link to the sfml-window library.
Laurent Gomila - SFML developer

roystben

  • Newbie
  • *
  • Posts: 5
    • View Profile
Issue with building a window
« Reply #2 on: July 13, 2011, 09:14:29 am »
I have linked it, and yet the issue persists.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Issue with building a window
« Reply #3 on: July 13, 2011, 10:49:49 am »
How did you link it exactly?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

roystben

  • Newbie
  • *
  • Posts: 5
    • View Profile
Issue with building a window
« Reply #4 on: July 13, 2011, 07:26:54 pm »
Went to the project properties, VC++ Directories Include Directories, and Linker additional library directories.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Issue with building a window
« Reply #5 on: July 13, 2011, 07:52:59 pm »
That was not exact enough ;)

Did you insert "sfml-window-d.lib" in Debug configuration and "sfml-window.lib" in Release configuration? Additionally, you have to link the other SFML modules you use, including those being used indirectly by another module (sfml-system in your case).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

roystben

  • Newbie
  • *
  • Posts: 5
    • View Profile
Issue with building a window
« Reply #6 on: July 13, 2011, 09:07:38 pm »
Ahh, misunderstood, did not know I had to add "sfml-window.lib" to the linker. Thank you for your help.

And yet another issue occurs, "This program cant start because sfml-window.dll is missing from your computer.", and as far as I know I have included the correct directories to have it find the dll.

blindley

  • Newbie
  • *
  • Posts: 12
    • View Profile
Issue with building a window
« Reply #7 on: July 13, 2011, 11:11:04 pm »
You need to copy sfml-window.dll either:

1) to the same directory as your executable, or
2) to some other location that windows knows to search for.  http://msdn.microsoft.com/en-us/library/ms682586%28v=vs.85%29.aspx

This is not something you set through Visual Studio.  I would recommend you just stick with option (1), because when you distribute your program, your users are unlikely to have the dll installed on their own system, and you might forget that they need it.

What I do is whenever I start a new project, I just copy every single dll that I think I might need to my output directory.  Then I don't have to worry about it while I'm developing.  When your project is finished and ready for distribution, you can always remove the ones you didn't end up using.

Also, if you're going to run your program from within Visual Studio (ctrl-F5), you'll need an additional copy of the dlls in your actual project directory, not your output directory, becuase Visual Studio runs the program from there, instead of the output directory.  I recommend you instead just run the program from it's own folder via a your shell.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Issue with building a window
« Reply #8 on: July 14, 2011, 12:04:57 am »
Quote from: "blindley"
What I do is whenever I start a new project, I just copy every single dll that I think I might need to my output directory.  Then I don't have to worry about it while I'm developing.
Yes, you do, at latest if you upgrade SFML. You duplicate every dynamic linked library multiple times, so you could as well link statically (which is even the better approach in this case).

The simplest solution is to add the bin directory of SFML to the PATH environment variable. When starting an executable, the runtime searches for DLL files in that path. Every time you compile SFML's install project, the DLLs are automatically replaced. Like this, you can make sure that you are only using a single version and don't mix incompatible libraries.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

blindley

  • Newbie
  • *
  • Posts: 12
    • View Profile
Issue with building a window
« Reply #9 on: July 14, 2011, 12:50:11 am »
Good ideas.  It's just that when I was trying to compile and use the static libraries, I was having difficulties and I gave up and decided to just use the dynamic libraries.  I can't remember what the problem was.  As for adding SFML\bin to my path, I don't add anything to my path unless it absolutely needs to be there.  I'm paranoid about name conflicts.  I doubt I'll compile SFML all that often, but if it becomes an issue I'd rather just write a shell script that retrieves the files I need.

roystben

  • Newbie
  • *
  • Posts: 5
    • View Profile
Issue with building a window
« Reply #10 on: July 14, 2011, 03:33:36 am »
Relinking it somehow fixed the issue(s), thank you for your help.

RedIrony

  • Newbie
  • *
  • Posts: 23
    • View Profile
Issue with building a window
« Reply #11 on: July 19, 2011, 05:20:53 am »
I've been having a similar issue, so I figured I'd post here instead of making a new thread:

I'm going through the tutorials, and I got the first one to work, but when I tried to open up a window, I get a complaint from the linker:
Quote
1>BasicGraphics.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function "public: virtual int __thiscall BasicGraphics::run(void)" (?run@BasicGraphics@@UAEHXZ)
1>C:\Users\...\Documents\Visual Studio 2010\Projects\DDD\Debug\DDD.exe : fatal error LNK1120: 1 unresolved externals


The weird thing is that I was able to use the Clock class successfully, so I'm pretty sure that my include/lib directories are configured correctly... Also under Properties... > Linker > Input > Additional Dependencies I put sfml-system-d.lib and sfml-window-d.lib. Any idea what I could have missed? I'm not very experienced with linking to other libraries.[/quote]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Issue with building a window
« Reply #12 on: July 19, 2011, 07:38:56 am »
Have you defined SFML_DYNAMIC?
Laurent Gomila - SFML developer

RedIrony

  • Newbie
  • *
  • Posts: 23
    • View Profile
Issue with building a window
« Reply #13 on: July 19, 2011, 04:02:24 pm »
Under Properties > Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions I put:
SFML_DYNAMIC
WIN32
_DEBUG
_CONSOLE

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Issue with building a window
« Reply #14 on: July 19, 2011, 04:06:35 pm »
Have you recompiled SFML?
Laurent Gomila - SFML developer

 

anything