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

Author Topic: First compiling error  (Read 2204 times)

0 Members and 1 Guest are viewing this topic.

user007

  • Newbie
  • *
  • Posts: 4
    • View Profile
First compiling error
« on: April 08, 2012, 01:44:09 am »
1>sfml-graphics-d.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x310
I am using Visual Studio 2008
I downloaded the full SDK version for Windows - Visual C++ 2008

I added the include and lib folders as described in the tutorial.
and how i know i not need to copy libs and includes to vc.

I try to make variations added 2 patch even copy files  to vc
 copy all dll in all project folders
And i download  "window-window.cpp" from tutorial
Trying all the combinations I could come up with, I still get a similar error to the one above. :-\

Hare image :

thx for eny help

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: First compiling error
« Reply #1 on: April 08, 2012, 08:31:52 am »
Does the tutorial say to link to .dll files? No :)
Laurent Gomila - SFML developer

user007

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: First compiling error
« Reply #2 on: April 08, 2012, 12:48:46 pm »
btw i linked it!i have windows xp.
now i reinstalled  everythink

now console projects compiling  but not the window.


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

HWND Button;


////////////////////////////////////////////////////////////
/// Function called whenever one of our windows receives a message
///
////////////////////////////////////////////////////////////
LRESULT CALLBACK OnEvent(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam)
{
    switch (Message)
    {
        // Quit when we close the main window
        case WM_CLOSE :
        {
            PostQuitMessage(0);
            return 0;
        }

        // Quit when we click the "quit" button
        case WM_COMMAND :
        {
            if (reinterpret_cast<HWND>(LParam) == Button)
            {
                PostQuitMessage(0);
                return 0;
            }
        }
    }

    return DefWindowProc(Handle, Message, WParam, LParam);
}


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \param Instance : Instance of the application
///
/// \return Error code
///
////////////////////////////////////////////////////////////
INT WINAPI WinMain(HINSTANCE Instance, HINSTANCE, LPSTR, INT)
{
    // Define a class for our main window
    WNDCLASS WindowClass;
    WindowClass.style         = 0;
    WindowClass.lpfnWndProc   = &OnEvent;
    WindowClass.cbClsExtra    = 0;
    WindowClass.cbWndExtra    = 0;
    WindowClass.hInstance     = Instance;
    WindowClass.hIcon         = NULL;
    WindowClass.hCursor       = 0;
    WindowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BACKGROUND);
    WindowClass.lpszMenuName  = NULL;
    WindowClass.lpszClassName = TEXT("SFML App");
    RegisterClass(&WindowClass);

    // Let's create the main window
    HWND Window = CreateWindow(TEXT("SFML App"), TEXT("SFML Win32"), WS_SYSMENU | WS_VISIBLE, 200, 200, 660, 520, NULL, NULL, Instance, NULL);

    // Add a button for exiting
    Button = CreateWindow(TEXT("BUTTON"), TEXT("Quit"), WS_CHILD | WS_VISIBLE, 560, 440, 80, 40, Window, NULL, Instance, NULL);

    // Let's create two SFML views
    HWND View1 = CreateWindow(TEXT("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 20,  20, 300, 400, Window, NULL, Instance, NULL);
    HWND View2 = CreateWindow(TEXT("STATIC"), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 340, 20, 300, 400, Window, NULL, Instance, NULL);
    sf::RenderWindow SFMLView1(View1);
    sf::RenderWindow SFMLView2(View2);

    // Load some images to display
    sf::Image Image1, Image2;
    if (!Image1.LoadFromFile("datas/win32/image1.jpg") || !Image2.LoadFromFile("datas/win32/image2.jpg"))
        return EXIT_FAILURE;
    sf::Sprite Sprite1(Image1);
    sf::Sprite Sprite2(Image2);
    Sprite1.SetCenter(Sprite1.GetSize() / 2.f);

    // Create a clock for measuring elapsed time
    sf::Clock Clock;

    // Loop until a WM_QUIT message is received
    MSG Message;
    Message.message = static_cast<UINT>(~WM_QUIT);
    while (Message.message != WM_QUIT)
    {
        if (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE))
        {
            // If a message was waiting in the message queue, process it
            TranslateMessage(&Message);
            DispatchMessage(&Message);
        }
        else
        {
            // Clear views
            SFMLView1.Clear();
            SFMLView2.Clear();

            // Draw sprite 1 on view 1
            Sprite1.SetRotation(Clock.GetElapsedTime() * 100);
            SFMLView1.Draw(Sprite1);

            // Draw sprite 2 on view 2
            Sprite2.SetX(cos(Clock.GetElapsedTime()) * 100);
            SFMLView2.Draw(Sprite2);

            // Display each view on screen
            SFMLView1.Display();
            SFMLView2.Display();
        }
    }

    // Destroy the main window (all its child controls will be destroyed)
    DestroyWindow(Window);

    // Don't forget to unregister the window class
    UnregisterClass(TEXT("SFML App"), Instance);

    return EXIT_SUCCESS;
}
Now i get this errors i linked and everythink how in tutorial and i use debug version
Code: [Select]
1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Sprite::~Sprite(void)" (__imp_??1Sprite@sf@@UAE@XZ) referenced in function _WinMain@16
1>main.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>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Drawable::SetX(float)" (__imp_?SetX@Drawable@sf@@QAEXM@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall sf::RenderTarget::Draw(class sf::Drawable const &)" (__imp_?Draw@RenderTarget@sf@@UAEXABVDrawable@2@@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Drawable::SetRotation(float)" (__imp_?SetRotation@Drawable@sf@@QAEXM@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::Clear(class sf::Color const &)" (__imp_?Clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Drawable::SetCenter(class sf::Vector2<float> const &)" (__imp_?SetCenter@Drawable@sf@@QAEXABV?$Vector2@M@2@@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class sf::Vector2<float> __thiscall sf::Sprite::GetSize(void)const " (__imp_?GetSize@Sprite@sf@@QBE?AV?$Vector2@M@2@XZ) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Sprite::Sprite(class sf::Image const &,class sf::Vector2<float> const &,class sf::Vector2<float> const &,float,class sf::Color const &)" (__imp_??0Sprite@sf@@QAE@ABVImage@1@ABV?$Vector2@M@1@1MABVColor@1@@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (__imp_??0Color@sf@@QAE@EEEE@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Image::~Image(void)" (__imp_??1Image@sf@@QAE@XZ) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Image::LoadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?LoadFromFile@Image@sf@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Image::Image(void)" (__imp_??0Image@sf@@QAE@XZ) referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(void *,struct sf::WindowSettings const &)" (__imp_??0RenderWindow@sf@@QAE@PAXABUWindowSettings@1@@Z) referenced in function _WinMain@16
1>D:\Visual Studio 2008\Projects\test2\Debug\test2.exe : fatal error LNK1120: 15 unresolved externals
1>Build log was saved at "file://d:\Visual Studio 2008\Projects\test2\test2\Debug\BuildLog.htm"
1>test2 - 16 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========/code]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: First compiling error
« Reply #3 on: April 08, 2012, 06:07:46 pm »
Have you linked sfml-graphics?
Laurent Gomila - SFML developer

user007

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: First compiling error
« Reply #4 on: April 08, 2012, 10:36:10 pm »
after i link sfml-graphic-d.lib i gert erorr i try to do this code in this linked project with debug setings
i add all libs.
adding this:SFML_DYNAMIC
placed in all project folders needed files..
hmm why im no lacky with this/ ..enyway kiding :)
Code: [Select]
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

    // Start main loop
    bool Running = true;
    while (Running)
    {
        App.Display();
    }

    return EXIT_SUCCESS;
}

and i get this error:
Code: [Select]
1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>D:\Visual Studio 2008\Projects\test2\Debug\test2.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://d:\Visual Studio 2008\Projects\test2\test2\Debug\BuildLog.htm"
1>test2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I think it somethink with antry point i even trued turn on console sub system they run but after windows open with the console i cant klick on window just on console wind....ok this is bad bcsose i cant run samples what mast teach me ;) im sceared a bit bcose spending so mach time on it i beter go direct x way..just talks ..thx for ansveres.and sory for my bad lanuage
« Last Edit: April 08, 2012, 10:48:31 pm by user007 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: First compiling error
« Reply #5 on: April 09, 2012, 10:10:58 am »
You must link to sfml-main.
Laurent Gomila - SFML developer