SFML community forums

Help => General => Topic started by: Charyb on August 20, 2010, 10:25:10 pm

Title: VS C++ Express : SFML Window tutorial
Post by: Charyb on August 20, 2010, 10:25:10 pm
I'm having trouble getting a window to run.
I recently just started out with SFML after learning a series of C++ tutorials and I think I'm ready to tackle this.

However I'm not very experienced when it comes to libraries and linking libraries to the compiler.

I believe I got SFML working for the very first tutorial, but when I got to the window tutorial it all went downhill.

For starters, here is my main.cpp file:
Code: [Select]

#include <SFML/Window.hpp>

int main()
{
sf::Window App(sf::VideoMode(800,600,32), "SFML Window");

bool running = true;
while(running)
{
App.Display();
}

return EXIT_SUCCESS;

}


In the project properties I had this:
Linker -> Input -> Additional Dependencies:
sfml-system.lib

That was from the last tutorial, I figured I needed to change it to:
sfml-window.lib
so I did.

When I compiled, no errors.
When I ran it I got this error:
Quote

Test.exe - System Error
The program can't start because sfml-system.dll is missing from your computer. Try reinstalling the program to fix this problem.


So I figured I needed the sfml-system.dll where my .exe was, which made no sense since I'm not using using system in my code, but I put it in there anyways. But then it occured to me I needed the sfml-window.dll since I am of course using that. After doing that, I ran it again:

Quote

Test.exe - Entry Point Not Found
The procedure entry point ?GetElapsedTime@Clock@sf@@QBEMXZ could not be located in the dynamic link library sfml-system.dll.


No idea what that means.
Title: VS C++ Express : SFML Window tutorial
Post by: Ari on August 20, 2010, 11:27:56 pm
I never used SFML with VS, but as far as I know sfml-window depends on sfml-system. So you should add both to the Linker.

Have you tried this?
Title: VS C++ Express : SFML Window tutorial
Post by: Charyb on August 21, 2010, 02:45:39 am
How do I link two?
sfml-system.lib sfml-window.lib ?
sfml-system.lib, sfml-window.lib ?
sfml-system.lib; sfml-window.lib ?
Title: VS C++ Express : SFML Window tutorial
Post by: Charyb on August 21, 2010, 08:00:56 am
Well I tried doing it like this:
sfml-system.lib sfml-window.lib

I still get the same error.
And yes, both the dlls are with the .exe.
Title: VS C++ Express : SFML Window tutorial
Post by: Laurent on August 21, 2010, 11:34:09 am
Don't forget to link the debug libraries (-d) in debug mode.
Title: VS C++ Express : SFML Window tutorial
Post by: bobasaurus on August 31, 2010, 04:35:54 am
Since you're using the dynamic libraries, don't forget to define SFML_DYNAMIC in the preprocessor properties:

Quote
Important: if you link against the dynamic libraries, you have to define the SFML_DYNAMIC  macro in your project's settings. If you don't, you'll get linker errors when compiling your application.
as seen in http://www.sfml-dev.org/tutorials/1.6/start-vc.php

Though, since you could successfully compile the program, it's probably just a problem with where you placed the dll files.  If I have a project named sfml_test, I would paste the dll files into:

C:\Documents and Settings\blah\My Documents\Visual Studio 2008\Projects\sfml_test\sfml_test

since this directory is automatically searched when running the program through visual studio.
Title: VS C++ Express : SFML Window tutorial
Post by: PeterWelzien on September 05, 2010, 04:38:56 pm
Quote from: "Charyb"
How do I link two?
sfml-system.lib sfml-window.lib ?
sfml-system.lib, sfml-window.lib ?
sfml-system.lib; sfml-window.lib ?

sfml-system.lib; sfml-window.lib