2012-03-20 53 views
3

所以我做一個傍克隆,和我目前正在與下面的輸出編譯它:正與SFML,收到「解析外部符號」輸出

1>------ Build started: Project: Pong, Configuration: Debug Win32 ------ 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Image::Create(unsigned int,unsigned int,class sf::Color const &)"  ([email protected]@[email protected]@[email protected]@@Z) referenced in function "public: void __thiscall Display::load_resources(void)" ([email protected]@@QAEXXZ) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" ([email protected]@@[email protected]@Z) referenced in function "public: void __thiscall Display::load_resources(void)" ([email protected]@@QAEXXZ) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Texture::LoadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class sf::Rect<int> const &)" ([email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function "public: void __thiscall Display::load_resources(void)" ([email protected]@@QAEXXZ) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Font::LoadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function "public: void __thiscall Display::load_resources(void)" ([email protected]@@QAEXXZ) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Sprite::SetTexture(class sf::Texture const &,bool)" ([email protected]@[email protected]@[email protected]@[email protected]) referenced in function "public: void __thiscall Display::loadSprites(void)" ([email protected]@@QAEXXZ) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Sprite::~Sprite(void)" ([email protected]@@[email protected]) referenced in function "public: void __thiscall Ball::setSprite(class sf::Sprite)" ([email protected]@@[email protected]@@@Z) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class sf::Sprite & __thiscall sf::Sprite::operator=(class sf::Sprite const &)" ([email protected]@@[email protected]@@Z) referenced in function "public: void __thiscall Ball::setSprite(class sf::Sprite)" ([email protected]@@[email protected]@@@Z) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Sprite::Sprite(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall Ball::Ball(void)" ([email protected]@[email protected]) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Transformable::SetPosition(float,float)" ([email protected]@[email protected]@[email protected]) referenced in function "public: void __thiscall Ball::updateSprite(void)" ([email protected]@@QAEXXZ) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Image::~Image(void)" ([email protected]@@[email protected]) referenced in function [email protected]@[email protected]$0 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Texture::~Texture(void)" ([email protected]@@[email protected]) referenced in function [email protected]@[email protected]$0 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Font::~Font(void)" ([email protected]@@[email protected]) referenced in function [email protected]@[email protected]$0 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Image::Image(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall Display::Display(void)" ([email protected]@[email protected]) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Texture::Texture(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall Display::Display(void)" ([email protected]@[email protected]) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Font::Font(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall Display::Display(void)" ([email protected]@[email protected]) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Sprite::Sprite(class sf::Sprite const &)" ([email protected]@@[email protected]@@Z) referenced in function "public: void __thiscall Game::reset(void)" ([email protected]@@QAEXXZ) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl sf::Keyboard::IsKeyPressed(enum sf::Keyboard::Key)" ([email protected]@[email protected]@[email protected]@@Z) referenced in function "public: void __thiscall Game::update(void)" ([email protected]@@QAEXXZ) 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" ([email protected]@@[email protected]) referenced in function _main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Close(void)" ([email protected]@[email protected]@QAEXXZ) referenced in function _main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Display(void)" ([email protected]@[email protected]@QAEXXZ) referenced in function _main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int,struct sf::ContextSettings const &)" ([email protected]@@QAE[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function _main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" ([email protected]@@[email protected]@Z) referenced in function _main 
1>C:\Users\Owner\Documents\Visual Studio 2010\Projects\Pong\Debug\Pong.exe : fatal error LNK1120: 22 unresolved externals 

所有我讀過說我」 m連接不正確,但我有所有的文件,我應該需要在包含部分...我做錯了什麼?

+1

在編譯過程中使用頭文件,鏈接時需要'.lib'文件。您需要將SFML庫添加到鏈接器選項。 – hmjd 2012-03-20 14:23:52

回答

3

如果要鏈接靜態SFML庫,則需要在項目配置的預處理器部分中定義SFML_STATIC。

如果您不這樣做,您將得到__declspec(dllimport)相關的鏈接錯誤,因爲標題不再與它們所用的庫匹配。