Hello everyone this is my first post on the game programming wiki! I am really glad to be posting on here and I'm sure I'll be posting often, this website is beautifully organized.
I am trying to use the SFML 1.6 graphics library in a program I am putting together using some of the tutorials included on SFML's website, I am going to mention I am using Visual C++ 2008 express with service pack 1 included. The program wont compile even with SFML's tutorial source:
Code:
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
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;
}
it is copied exactly from the website so I don't see how it could be any sort of coding problem, seems to be a compiler error, I included "sfml-graphics-d.lib" into my project's additional dependencies settings its very strange. If I follow the tutorial for setting up my IDE I get system.hpp to link just fine using the same steps. The code I'm using to test my IDE is here:
Code:
#include <SFML/System.hpp>
#include <iostream>
int main()
{
sf::Clock Clock;
while (Clock.GetElapsedTime() < 5.f)
{
std::cout << Clock.GetElapsedTime() << std::endl;
sf::Sleep(0.5f);
}
std::cout << "Success! Press Enter to terminate!";
std::cin.get();
return 0;
}
I left the SFML files separated from the Visual Studio install files in a different location and everything worked fine. But when I go to compile the c plus plus program that uses the SFML graphics package it wont build, here is the error log:
Code:
1>------ Build started: Project: opengl, Configuration: Debug Win32 ------
1>Compiling...
1>test.cpp
1>Linking...
1>LINK : C:\Users\AliceLiddell\Desktop\opengl\Debug\opengl.exe not found or not built by the last incremental link; performing full link
1>test.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ) referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Close(void)" (?Close@Window@sf@@QAEXXZ) referenced in function _main
1>test.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>test.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::IsOpened(void)const " (?IsOpened@Window@sf@@QBE_NXZ) referenced in function _main
1>test.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>C:\Users\AliceLiddell\Desktop\opengl\Debug\opengl.exe : fatal error LNK1120: 5 unresolved externals
1>Build log was saved at "file://c:\Users\AliceLiddell\Desktop\opengl\Debug\BuildLog.htm"
1>opengl - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I usually get it to compile then I get an error message saying there is no dll in the directory so I just plant it there and it worked fine for the test I ran using SFML's system library. I don't even know what to do I tried using google but I just got results for people who didn't know how to properly link a library in the IDE they use to program with. I'm very confused please help me out I don't think it has to do with me "not knowing the language". I'm currently reading a developer's library so it isn't a huge deal this gets sorted out right away but I am kind of sad about this whole thing. I had it working once before but now it seems it wont. If it is my fault (is most likely) maybe you could give me a definition of what I did wrong so I can research so I don't do it anymore.