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

Author Topic: Window Problems - Need help!  (Read 6866 times)

0 Members and 1 Guest are viewing this topic.

Kainevg

  • Newbie
  • *
  • Posts: 2
    • View Profile
Window Problems - Need help!
« on: July 02, 2010, 07:46:10 am »
Hello,

I downloaded SFML today and have been looking through what people have done using it..

Now anyway, i'm fairly new to C++ but as I have learnt Action-Script 3.0 (Big improvement from 2.0 as it is now OOP so it can relate more to other languages) I understand the fundamentals and I am learning quickly.

I am using Visual Studio 2010 Express for my C++ programming and I have compiled SFML for use with this version of VS. I attempted the very first tutorial where it takes a look at the Clock. This worked for me perfectly fine so I then went on to make a window using the Graphics class.

I created a new Win32 Project called WindowProject and then set it to be "Empty". I went into WindowProject's properties and set the Configuration to be All Configurations.

In Configuration Properties > VC++ Directories I added C:\SFML-1.6\include; in the "Include Directories" field and in the Library Directories field I added "C:\SFML-1.6\lib\vc2010;".

In Linker > Input > Additional Dependencies I put sfml-graphics-s.lib; I also put the file sfml-graphics-s.lib into the location where my .exe would be.

The code I used was exactly the same as the tutorial and when compiling I get these errors:

Code: [Select]
1>------ Build started: Project: WindowProject, Configuration: Debug Win32 ------
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-graphics-s.lib(RenderTarget.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-graphics-s.lib(Color.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-graphics-s.lib(Image.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-graphics-s.lib(View.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-graphics-s.lib(GraphicsContext.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-graphics-s.lib(Drawable.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-graphics-s.lib(Matrix3.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Close(void)" (?Close@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (?GetEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::IsOpened(void)const " (?IsOpened@Window@sf@@QBE_NXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Window::~Window(void)" (??1Window@sf@@UAE@XZ) referenced in function "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@UAE@XZ)
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2019: unresolved external symbol "public: __thiscall sf::Window::Window(void)" (??0Window@sf@@QAE@XZ) referenced in function "public: __thiscall sf::RenderWindow::RenderWindow(void)" (??0RenderWindow@sf@@QAE@XZ)
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2001: unresolved external symbol "private: virtual void __thiscall sf::Window::OnEvent(class sf::Event const &)" (?OnEvent@Window@sf@@EAEXABVEvent@2@@Z)
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Create(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (?Create@Window@sf@@QAEXVVideoMode@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@2@@Z) referenced in function "public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z)
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Create(void *,struct sf::WindowSettings const &)" (?Create@Window@sf@@QAEXPAXABUWindowSettings@2@@Z) referenced in function "public: __thiscall sf::RenderWindow::RenderWindow(void *,struct sf::WindowSettings const &)" (??0RenderWindow@sf@@QAE@PAXABUWindowSettings@1@@Z)
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::SetActive(bool)const " (?SetActive@Window@sf@@QBE_N_N@Z) referenced in function "private: virtual bool __thiscall sf::RenderWindow::Activate(bool)" (?Activate@RenderWindow@sf@@EAE_N_N@Z)
1>sfml-graphics-s.lib(Image.obj) : error LNK2001: unresolved external symbol "public: bool __thiscall sf::Window::SetActive(bool)const " (?SetActive@Window@sf@@QBE_N_N@Z)
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2019: unresolved external symbol "public: unsigned int __thiscall sf::Window::GetWidth(void)const " (?GetWidth@Window@sf@@QBEIXZ) referenced in function "public: virtual unsigned int __thiscall sf::RenderWindow::GetWidth(void)const " (?GetWidth@RenderWindow@sf@@UBEIXZ)
1>sfml-graphics-s.lib(RenderWindow.obj) : error LNK2019: unresolved external symbol "public: unsigned int __thiscall sf::Window::GetHeight(void)const " (?GetHeight@Window@sf@@QBEIXZ) referenced in function "public: virtual unsigned int __thiscall sf::RenderWindow::GetHeight(void)const " (?GetHeight@RenderWindow@sf@@UBEIXZ)
1>sfml-graphics-s.lib(GraphicsContext.obj) : error LNK2019: unresolved external symbol "public: void __thiscall sf::Context::SetActive(bool)" (?SetActive@Context@sf@@QAEX_N@Z) referenced in function "public: __thiscall sf::priv::GraphicsContext::GraphicsContext(void)" (??0GraphicsContext@priv@sf@@QAE@XZ)
1>sfml-graphics-s.lib(GraphicsContext.obj) : error LNK2019: unresolved external symbol "public: static class sf::Context & __cdecl sf::Context::GetGlobal(void)" (?GetGlobal@Context@sf@@SAAAV12@XZ) referenced in function "public: __thiscall sf::priv::GraphicsContext::GraphicsContext(void)" (??0GraphicsContext@priv@sf@@QAE@XZ)
1>sfml-graphics-s.lib(GraphicsContext.obj) : error LNK2019: unresolved external symbol "public: static bool __cdecl sf::Context::IsContextActive(void)" (?IsContextActive@Context@sf@@SA_NXZ) referenced in function "public: __thiscall sf::priv::GraphicsContext::GraphicsContext(void)" (??0GraphicsContext@priv@sf@@QAE@XZ)
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Kaine\Documents\Visual Studio 2010\Projects\WindowProject\Debug\WindowProject.exe : fatal error LNK1120: 17 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




Im sure it is something very simple im just overlooking or have done wrong.. I hope you guys can help (Im sure you can  :D)

Thanks in advance - Kaine

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Window Problems - Need help!
« Reply #1 on: July 02, 2010, 08:14:48 am »
Quote
In Linker > Input > Additional Dependencies I put sfml-graphics-s.lib

You also need sfml-window and sfml-system (sfml-graphics depend on them).

Quote
I also put the file sfml-graphics-s.lib into the location where my .exe would be.

Static libraries are integrated to the final executable, they are not needed at runtime. You only need to do so for DLLs.

Quote
Im sure it is something very simple im just overlooking or have done wrong..

Yep. It is even written with bold characters in the VC++ tutorial ;)
In debug mode, you must link to debug libraries ("-d" suffix).
Laurent Gomila - SFML developer

Kainevg

  • Newbie
  • *
  • Posts: 2
    • View Profile
Window Problems - Need help!
« Reply #2 on: July 02, 2010, 10:06:49 am »
No need to make me feel stupid  :D

Ill try this out soon when I get a chance though im sure your fix will work..

Thanks heaps :D

Edit: Its fixed now! Thanks :D.. I was running it as a windows application but I changed it to console and it works fine now

Edit:

I added the sfml-window-s.lib and sfml-system-s.lib and that got rid of 16 errors but im still getting a compiler error.

Code: [Select]
1>------ Build started: Project: WindowProject, Configuration: Release Win32 ------
1>MSVCRT.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16
1>C:\Users\Kaine\Documents\Visual Studio 2010\Projects\WindowProject\Release\WindowProject.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


And this the code im using for the window:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // A key has been pressed
            if (Event.Type == sf::Event::KeyPressed)
            {
                // Escape key : exit
                if (Event.Key.Code == sf::Key::Escape)
                    App.Close();

                // F1 key : capture a screenshot
                if (Event.Key.Code == sf::Key::F1)
                {
                    sf::Image Screen = App.Capture();
                    Screen.SaveToFile("screenshot.jpg");
                }
            }
        }

        // Clear the screen with red color
        App.Clear(sf::Color(200, 0, 0));

        // Display window contents on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Window Problems - Need help!
« Reply #3 on: July 02, 2010, 02:21:33 pm »
You must define a WinMain entry point (instead of main), or simply link to sfml-main.
Laurent Gomila - SFML developer