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

Author Topic: LNK2001  (Read 2108 times)

0 Members and 2 Guests are viewing this topic.

DroomNop

  • Newbie
  • *
  • Posts: 5
    • View Profile
LNK2001
« on: July 28, 2010, 04:34:08 pm »
I just started to learn SFML and I can't even get through the second example code. The first one, http://www.sfml-dev.org/tutorials/1.6/start-vc.php, compiled fine. But the second tutorial program, about threads, gives me this error:

 
Code: [Select]
error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (__imp_?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z) c:\documents and settings\~~~~\my documents\visual studio 2010\Projects\SFML3\SFML3\sfml-system-s.lib(Thread.obj) SFML3


The code is

Code: [Select]

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

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

int main() {
    sf::Thread Thread(&ThreadFunction);

    Thread.Launch();

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

    return EXIT_SUCCESS;
}


I used "Release" option and linked to "sfml-system-s.lib", with Visual Studio 2010. The tutorial said it would work, so first I didn't compile SFML myself, then when I got this error I tried, but I wasn't even able to compile it because of tons of errors.

The thread-example DOES compile fine when using sfml-system.lib when declared with SFML_DYNAMIC. But I'd like a static link. How can I solve this problem? I don't want to download vc2008 just for this.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LNK2001
« Reply #1 on: July 28, 2010, 04:38:04 pm »
I think you'll have to compile SFML with VS 2010.

A lot of people already did it, you should be able to find useful information on this forum, or even precompiled binaries.
Laurent Gomila - SFML developer

DroomNop

  • Newbie
  • *
  • Posts: 5
    • View Profile
LNK2001
« Reply #2 on: July 28, 2010, 05:16:55 pm »
Me turd, I managed to compile sfml, I got a few warnings though, I hope it's nothing important. The thread example runs fine now.

If anyone needs to compile it with Visual Studio 2010 go to