SFML community forums

Help => General => Topic started by: wgan on May 23, 2014, 02:48:49 pm

Title: vs 2013 express build error Error 2 error LNK2001
Post by: wgan on May 23, 2014, 02:48:49 pm
windows 8 64bit, latest snapshot, followed every step in
http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php
and
http://www.sfml-dev.org/tutorials/2.0/start-vc.php
and it built just fine with static link (both release and debug), but when i do a little test using the hello code vs threw a bunch of errors like the format of this one:

Error 2 error LNK2001: unresolved external symbol __imp_glReadPixels E:\src\SFML\test\sfml-graphics-s.lib(RenderWindow.obj)

SFML_STATIC is set, any ideas what went wrong?
Title: Re: vs 2013 express build error Error 2 error LNK2001
Post by: zsbzsb on May 23, 2014, 04:54:44 pm
https://github.com/SFML/SFML/wiki/FAQ#build-link-static
Title: Re: vs 2013 express build error Error 2 error LNK2001
Post by: eXpl0it3r on May 23, 2014, 05:00:40 pm
As zsbzsb pointed out, things have changed. If you look in the tutorials of version 2.0 (current stable version 2.1), you should not except it to work for the latest development version.
Title: Re: vs 2013 express build error Error 2 error LNK2001
Post by: wgan on May 24, 2014, 03:57:38 pm
which i suppose to add these lib in the additional link input in VS2013? it failed with same error, then i suppose these libs were made in 2012, so i need to build each external library (from source) in 2013 by myself?
Title: Re: vs 2013 express build error Error 2 error LNK2001
Post by: eXpl0it3r on May 24, 2014, 11:00:52 pm
You add the extlibs directory to the General->Additional Library Directories setting and add the libraries themselves Input->Additional Dependencies.

No, all these libraries are C libraries and as such have a clear defined ABI and don't need rebuilding between different compiler versions.
Title: Re: vs 2013 express build error Error 2 error LNK2001
Post by: wgan on May 25, 2014, 02:10:04 pm
still getting the same errors, should the adding ext lib part be done while building the SFML source or individual project stage?
Title: AW: vs 2013 express build error Error 2 error LNK2001
Post by: eXpl0it3r on May 25, 2014, 06:18:46 pm
When building SFML CMake does all the work.

If you link your project statically against SFML you need to specify the additional libraries.
Title: Re: AW: vs 2013 express build error Error 2 error LNK2001
Post by: wgan on May 26, 2014, 12:36:54 am
When building SFML CMake does all the work.

If you link your project statically against SFML you need to specify the additional libraries.

thats where i was stuck, i don't think i missed a single step and setting, it still gives the same error, additional libraries were added, SFML_STATIC was set.

does this error mean that in the link stage the compiler simply can't find the proper libraries?

Title: AW: vs 2013 express build error Error 2 error LNK2001
Post by: eXpl0it3r on May 26, 2014, 08:07:31 am
If it's still the same error as above, you're not linking against OpenGL (opengl32).
Title: Re: vs 2013 express build error Error 2 error LNK2001
Post by: wgan on May 26, 2014, 01:29:54 pm
cheers, the build went through without any error this time except the code doesn't run as expected, its supposed to show a cyan circle instead what i've got here is blank screen, but since now i got it linked i'll figure it out by myself, thank you for your help!

ps here the code maybe its for 1.2 i haven't got a chance to look into it

#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 480), "SFMLApplication");
        sf::CircleShape shape;
        shape.setRadius(40.f);
        shape.setPosition(100.f, 100.f);
        shape.setFillColor(sf::Color::Cyan);
       
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                window.clear();
                window.draw(shape);
                window.display();
        }
}