SFML community forums
General => General discussions => Topic started by: sakib on December 22, 2013, 10:01:36 pm
-
I am going through the SFML game development book and I hit a road block with the resource holder class. I am developing on mac using xCode.
I implemented the class based on the book and I am trying to use it but I get this error
Undefined symbols for architecture x86_64:
"ResourceHolder<sf::Texture, Textures::ID>::load(Textures::ID, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
for the following usage
ResourceHolder<sf::Texture, Textures::ID> textures;
try
{
std::string loc = resourcePath()+"Eagle.png";
textures.load(Textures::Airplane, loc);
}
catch (std::runtime_error& e)
{
std::cout << "Exception: " << e.what() << std::endl;
return 1;
}
I dont understand why this is happening.
I attached the source files if that helps
Thanks
-
Looks like a linker error. Did you follow the tutorial in the ReadMe.txt file? Is the implementation file ResourceHolder.inl included?
Make also sure you use the latest code from GitHub (https://github.com/SFML/SFML-Game-Development-Book), the one from the PacktPub homepage is outdated.
-
interesting... I implemented the resource holder class in a file called ResourceHolder.cpp. Why is that turning out to be a problem?
Also I never used a .inl file before, what is that supposed to be? I am really confused why we use inl file and not .cpp file
-
Templates must always be defined in the header, so that the compiler knows the full definition to substitute the template parameters. In order to keep interface and implementation separate, both are split into .hpp and .inl files, where the latter is included at the end of the former.