Hi,
Im brand new to SFML, and I can't figure it out. I tried following this tutorial to get everything set up:
http://www.cplusplus.com/forum/beginner/95295/#msg511542I followed it to the letter (except for the Doxygen part), and I'm getting 31 unresolved externals linking errors.
First, I created a brand new blank c++ project. I put examples/window/window.cpp into the project and tried to build:
1> Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: float __thiscall sf::Time::asSeconds(void)const " (__imp_?asSeconds@Time@sf@@QBEMXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Clock::Clock(void)" (__imp_??0Clock@sf@@QAE@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class sf::Time __thiscall sf::Clock::getElapsedTime(void)const " (__imp_?getElapsedTime@Clock@sf@@QBE?AVTime@2@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" (__imp_??1Window@sf@@UAE@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class sf::Vector2<unsigned int> __thiscall sf::Window::getSize(void)const " (__imp_?getSize@Window@sf@@QBE?AV?$Vector2@I@2@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::setActive(bool)const " (__imp_?setActive@Window@sf@@QBE_N_N@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glClearDepth@8 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glColorPointer@16 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glDepthMask@4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glDisable@4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glDisableClientState@4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glDrawArrays@12 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glEnableClientState@4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glFrustum@48 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glVertexPointer@16 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function _main
1>c:\users\xxx\documents\visual studio 2012\Projects\Default\Debug\Default.exe : fatal error LNK1120: 31 unresolved externals
As I said above, I followed the tutorial exactly, with linking to the correct folders for both Includes and Libraries, and it doesn't work.
I also tried just using the VisualC++11 (32 bit) download straight from the SFML page in case I didn't configure cmake properly, and I'm getting the exact same errors.
Secondly, and slightly less important, the tutorial I linked to above has you create a convenience header:
//sfml.h
#pragma once
#ifndef SFMLFULL_INCLUDED
#define SFMLFULL_INCLUDED
#define SFML_STATIC
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#if defined(_DEBUG) || defined(DEBUG)
#pragma comment(lib,"sfml-graphics-s-d.lib")
#pragma comment(lib,"sfml-audio-s-d.lib")
#pragma comment(lib,"sfml-network-s-d.lib")
#pragma comment(lib,"sfml-window-s-d.lib")
#pragma comment(lib,"sfml-system-s-d.lib")
#pragma comment(lib,"sfml-main-d.lib")
#else
#pragma comment(lib,"sfml-graphics-s.lib")
#pragma comment(lib,"sfml-audio-s.lib")
#pragma comment(lib,"sfml-network-s.lib")
#pragma comment(lib,"sfml-window-s.lib")
#pragma comment(lib,"sfml-system-s.lib")
#pragma comment(lib,"sfml-main.lib")
#endif
#endif // SFMLFULL_INCLUDED
When I try and include the convenience header, I get errors like this:
1>c:\users\xxx\documents\visual studio 2012\projects\default\default\source.cpp(24): error C3861: 'glClearDepth': identifier not found
1>c:\users\xxx\documents\visual studio 2012\projects\default\default\source.cpp(25): error C3861: 'glClearColor': identifier not found
1>c:\users\xxx\documents\visual studio 2012\projects\default\default\source.cpp(28): error C2065: 'GL_DEPTH_TEST' : undeclared identifier
1>c:\users\xxx\documents\visual studio 2012\projects\default\default\source.cpp(28): error C3861: 'glEnable': identifier not found
1>c:\users\xxx\documents\visual studio 2012\projects\default\default\source.cpp(29): error C2065: 'GL_TRUE' : undeclared identifier
...
As if the compiler doesn't include any of the .h files that sfml.h says to include (but I don't get any errors in sfml.h itself.
So to get the link errors that I'm getting above, I have to use the includes exactly as they are written in the example.
Please help, I have no idea where to start, google searching for these terms turns up pages talking about linking to the correct libraries, but I thought that's what I already did when I told the project to use library directories .../lib/release and .../lib/debug?
Thanks!
(I'm using MS VisualStudio 2012 Update 2 V11.0.60315.01 running in Windows 7 Profession 64 bit)