0

Hi so i am using msVS++2010 and have been attempting to set up SFML all day.... I downloaded 1.6 from the site, then rebuilt it in VS2010, but sad to find that this did not result in a sfml-system-d.lib file, which is what i am used to using, and only produced new system-s and system-s-d libs.

I then closely watched this Video to find that he ran his test code by adding the external lib of sfml-system-s-d and so i added the sfml-system-d.dll next the .exe and got the following exact same code the video showed to work:

#include <iostream>
#include <SFML/System.hpp>

int main(int argc, char **argv)
{
    sf::Clock clock;

    sf::Sleep(0.1f);

    while(clock.GetElapsedTime() < 5.0f)
    {
        std::cout << clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }
}

obviously clock and sleep are working, but when i add the simple line of code 'sf::Thread thread();' an error box pops up saying "unable to start program," "configuration is incorrect," "Review the manifest file for possible errors," "renstalling my fix it."

Also: when trying to run the first program of the tutorials regarding threads:

#include <SFML/System.hpp>
#include <iostream>

void ThreadFunction(void* UserData)
{
    // Print something...
    for (int i = 0; i < 10; ++i)
        std::cout << "I'm the thread number 1" << std::endl;
}

int main()
{
    // Create a thread with our function
    sf::Thread Thread(&ThreadFunction);

    // Start it !
    Thread.Launch();

    // Print something...
    for (int i = 0; i < 10; ++i)
        std::cout << "I'm the main thread" << std::endl;

    return EXIT_SUCCESS;
}

I get 8 unresovled external symbols like this one:

1>sfml-system-s-d.lib(Thread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::ios_base::width(int)" (__imp_?width@ios_base@std@@QAEHH@Z)
 fatal error LNK1120: 8 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Lastly this is how my project is set up:

  • include directory to out of the box, freshly downloaded SFML 1.6/include
  • lib directory to the VS2010 rebuilt SFML (debug/release DLL setting, and static).
  • extra dependency on sfml-system-s-d.lib file.
  • out of frusteration i placed every dll file next to the .exe

1 Answer 1

2

It sounds like you might not be linking to the CRT when building SFML. (ios_width is iostream, which requires the CRT library.)

You need to rebuild SFML, except this time do the following:

0. copy this list of libs

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib

  1. go into each individual Project's Properties -> Configuration -> Linker -> Input. or if it doesn't have 'Linker' go into Properties -> Configuration -> Librarian.

  2. Set "Ignore Default Libraries" to "no" and it will probably work

  3. If you wanna be 100% safe, click on additional dependencies, expand it, and click "edit." now just paste in the libs above

  4. If your in the 'librarian' tab, set Link Library Dependencies to YES

  5. repeat steps 1-4 each time you change the build setting of Debug DLL, Debug static, etc.

When I recompiled SFML (granted, I have a static compile because 1.6 is the last of the 1.x line, and 2.0 isn't compatible ;)) I had to add those references. It will ignore (and 'warn' about ignoring) anything it doesn't need, but they are the defaults ;)

Unfortunately you'll need to update everything in the SFML solution, as, if I recall correctly, they are all missing the default libraries.

Sign up to request clarification or add additional context in comments.

3 Comments

So all i need to do is change the dependencies? would'nt i also need some dll files?
Do i need to change the dependencies in each project (main, audio, graphics), and every time i switch fom say Debug DLL to Debug Static
Sorry, lost the net for a while (rather unexpectedly). Changing dependencies should be all that's required, and yes, each project configuration (Debug DLL, Debug static, Release DLL, Release static) will need to be reconfigured. If you use the static build route (i.e. build Debug Static or Release Static) you don't need any DLLs other than openal32 or libsndfile for release (if that's what you mean), and you shouldn't need anything beyond what's in the source distribution to build.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.