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.
////////////////////////////////////////////////////////////
// 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
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]