최근에 Visual Studio를 설치하고 SFML 라이브러리 및 Boost 라이브러리로 약간의 작업을 시작했지만 이상한 (나에게) 오류가 발생했습니다. 정적 클래스의 헤더 파일에서 정적 void 함수를 선언 할 때 Visual Studio에서는 "findTextures '에 대한 함수 정의가 없다는 것을 알려줍니다. BOOST_FOREACH 코드가 함수에있는 경우에만 나타납니다. 왜 이런 일이 일어나는 지 아십니까? 무리 감사.Visual Studio C++ 및 Boost Lib : BOOST_FOREACH가있는 경우에만 함수 정의를 찾을 수 없습니다.
이것은 TextureLoader.h 다음과 같습니다
#include <SFML/Graphics.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <iostream>
class TextureLoader {
public:
static const sf::Texture& getTexture(sf::String l_name);
static void findTextures();
private:
static std::map<sf::String, sf::Texture> textures;
};
그리고 이것은 TextureLoader.cpp 클래스입니다 :
#include "TextureLoader.h"
// Get texture using name
const sf::Texture& TextureLoader::getTexture(sf::String l_name) {
return textures.at(l_name);
}
void TextureLoader::findTextures() {
namespace fs = boost::filesystem;
fs::path targetDir("/Textures");
fs::directory_iterator it(targetDir), eod;
BOOST_FOREACH(fs::path const &p, std::make_pair(it, eod)) {
if(fs::is_regular_file(p)) {
std::cout << p.filename();
}
}
}
출력 :
1>------ Build started: Project: MasterTest, Configuration: Debug Win32 ------
1>TextureLoader.cpp
1>Unknown compiler version - please run the configure tests and report the results
1>TextureLoader.obj : error LNK2001: unresolved external symbol "private: static class std::map<class sf::String,class sf::Texture,struct std::less<class sf::String>,class std::allocator<struct std::pair<class sf::String const ,class sf::Texture> > > TextureLoader::textures" ([email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected][email protected][email protected]@@[email protected]@@[email protected]@@[email protected]@[email protected]@A)
1>F:\Coding\VSProjects\MasterTest\Debug\MasterTest.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "MasterTest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Visual Studio의 * exact * 및 * complete * 출력이 없으면 실제로 도움이되지 않습니다. 오류 메시지 (* 출력 * 창에서 * 오류 * 오류 메시지를 인용하지 않음)는 누구에게나 당신을 도울 수있는 필수 요소입니다. –
@JanHudec 님이 질문을 편집했으며 오류 로그를 추가했습니다. :) – Crack498
** OUTPUT ** 창에서 ** TEXT **와 (과) 같이하시기 바랍니다. –