Thread: )': Visual C++ & SFML compilation problems! :'(

  1. #1
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51

    )': Visual C++ & SFML compilation problems! :'(

    Hi all,

    After having followed the SFML tutorial on the website ( www.sfml-dev.org ) & successfully running their clock sample I decided to try my luck at compiling one of the sample programs included in the SFML download bundle.
    However, my luck ran out when compiling the Window sample program & the build log says:
    Code:
    1>------ Build started: Project: pong, Configuration: Debug Win32 ------
    1>sfml-graphics.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2B0
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    If you have any ideas how I can get around this I'd be very grateful! The file cannot be corrupt since I literally just downloaded it & have made no changes!

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Are you using the correct version of the binary files for your version of Visual C++.
    They must match because Microsoft C++ DLLs are not compatible with each other.
    VS 2008 C++ DLLs do not work with VS 2005 compilers.

    What is your version of Visual C++?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51
    I'm using Visual Studio 2010 Express C++ edition, the SFML tutorial said it's compatible.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by JM1082 View Post
    I'm using Visual Studio 2010 Express C++ edition, the SFML tutorial said it's compatible.
    Are you using any Binary files from the web-site?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51
    I'm not sure, but I don't think so! I've literally followed the steps in the tutorial!

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Code:
    Copy the *.lib files in SFML-x.y\lib to the VC\lib directory of your Visual Studio installation
    FYI: Library files are binary files.
    C++ Libraries are NOT necessary compatible with different versions of the same compiler.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  7. #7
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51
    Ooops I didn't realise, I thought binary files could only end .bin :-S

    I've copied those files in anyway! ^^

  8. #8
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51
    I think the problem may have something to do with the project's Linker > Input > Additional dependencies.

    When I add or remove one or both of the sfml-graphics-d.dll & sfml-graphics.dll parameters from the field I get different errors depending which I take out!

    Hope this helps! ^^

  9. #9
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    You want sfml-graphics-d.lib or sfml-graphics.lib in the Additional Dependencies. Lib files are bits the linker uses, dll files are bits your program uses.

  10. #10
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51
    After implementing that change I get this error instead:

    Code:
    1>------ Build started: Project: pong, Configuration: Debug Win32 ------
    1>pongMain.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Display(void)" (__imp_?Display@Window@sf@@QAEXXZ) referenced in function _WinMain@16
    1>pongMain.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: float __thiscall sf::Clock::GetElapsedTime(void)const " (__imp_?GetElapsedTime@Clock@sf@@QBEMXZ) referenced in function _WinMain@16
    1>pongMain.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Clock::Clock(void)" (__imp_??0Clock@sf@@QAE@XZ) referenced in function _WinMain@16
    1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
    1>C:\Users\J\Documents\Visual Studio 2010\Projects\pong\Debug\pong.exe : fatal error LNK1120: 4 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  11. #11
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51
    After including all of the SFML.lib & SFML-d.lib files to the additional dependencies field AND adding all of the SFML.lib & SFML-d.lib files to the program's directory I'm still getting this error:

    Code:
    1>------ Build started: Project: pong, Configuration: Debug Win32 ------
    1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
    1>C:\Users\J\Documents\Visual Studio 2010\Projects\pong\Debug\pong.exe : fatal error LNK1120: 1 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  12. #12
    Registered User
    Join Date
    Nov 2011
    Posts
    48
    As was mentioned earlier, the binaries provided by SFML don't work in Visual Studio 2010. Assuming you are using 1.6, I have libraries compiled for Visual Studio 2010 available here. Once you have them downloaded, read this guide which goes into extreme detail on how to setup Visual C++ Express 2010 to work with SFML. If that fails, at the end there is a preconfigured but empty project you can simply download, unzip and go from there. If you are using SFML 2.0, VS 2010 binaries are available at the bottom of this post ( which coincidentally is about how to build SFML 2.0 ). The directions I linked earlier should work for you unchanged regardless to which version you are using.


    Why oh why they don't provide pre-compiled binaries for VS2010 even though it's what 99% of people use these days, I just don't know. It would massively cut down on support incidents on the sfml website and would make things a ton easier for new developers.


    Try the above, and if it doesn't work, try the pre-configured project. If that still doesn't work, let me know and I will see if I can help.

  13. #13
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51
    Thanks Serapth!

    Game From Scratch has been really helpful! Thanks so much for your advice!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visual Studio 2010 - DirectX compilation error.
    By PieMonster in forum Game Programming
    Replies: 2
    Last Post: 09-04-2011, 01:44 PM
  2. Visual Studio 2010 x64 compilation
    By n1mda in forum Windows Programming
    Replies: 1
    Last Post: 07-20-2010, 05:20 AM
  3. Dev-C++ Compilation Problems
    By Bnchs400 in forum Tech Board
    Replies: 4
    Last Post: 10-10-2007, 07:58 AM
  4. SDL compilation problems
    By OnionKnight in forum C Programming
    Replies: 7
    Last Post: 01-07-2006, 05:58 PM
  5. Compilation problems?
    By MagSteve in forum C++ Programming
    Replies: 1
    Last Post: 05-03-2004, 04:29 PM