Chunky by FelipeFS
Chunky by FelipeFS
GPWiki.org
It is currently Sun Sep 21, 2014 2:02 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: SFML library not linking
PostPosted: Fri Dec 14, 2012 4:49 pm 
Rookie

Joined: Fri Dec 14, 2012 4:23 pm
Posts: 4
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.


Last edited by AliceLiddell on Sat Dec 15, 2012 12:19 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Dec 14, 2012 8:28 pm 
Double Guru
User avatar

Joined: Fri Aug 12, 2005 8:58 am
Posts: 2009
Location: LA, CA
Without seeing how your project is setup I can't really help with the linking. However your main function is declared wrong.
Code:
int main()

should be
Code:
int main(int argc, char** argv)

_________________
My Development Blog | My Website | My Current 3d Engine


Top
 Profile  
 
PostPosted: Sat Dec 15, 2012 2:17 am 
Seoushi wrote:
Without seeing how your project is setup I can't really help with the linking. However your main function is declared wrong.
Code:
int main()

should be
Code:
int main(int argc, char** argv)


I have a developer's library in front of me, I read examples from it all the time it never uses those parameters in the function header. Here I'll show you

http://www.youtube.com/watch?v=aMFk2y-J ... e=youtu.be

its a video showing how I set up the first example that compiles and runs fine and how the second wont run.


Top
  
 
PostPosted: Sat Dec 15, 2012 9:04 am 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3807
Location: South Africa
Hi AliceLiddell, welcome to GPWiki!

It sounds like you've forgotten one of the steps but it's been a while since I've had to fiddle with the linker on Visual C++. Could you upload the project somewhere?

Did you define the SFML_DYNAMIC macro and are the .dll's available to the .exe (either in system PATH or in the root directory with the .exe)? My bandwidth isn't great so I haven't had a look at the video.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
PostPosted: Sat Dec 15, 2012 10:32 am 
http://code.google.com/p/alicestanley-c ... akechanges here you go I'm not sure how I managed to mess this up


Top
  
 
PostPosted: Sat Dec 15, 2012 7:46 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3807
Location: South Africa
The problem seems to be that you did not list the .lib's for system and window. I made the additional dependency list as follows, and it linked and built, but didn't run for some reason.

Quote:
sfml-graphics.lib
sfml-window.lib
sfml-system.lib


Also, when I copied the dll's into the project directory, only the window dll complained about being overwritten, so you're missing the other ones.

Another thing I noticed was that I had to setup the include and lib directories for the project, which makes me think you've set them up as global settings. This is probably bad practice because it means those paths will be on the search path for every single project you create, regardless of whether it's SFML related or not.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

Powered by phpBB® Forum Software © phpBB Group