• ### Popular Now

• 11
• 9
• 10
• 9
• 10

This topic is 980 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have zlib and tmxloader in, the includes work fine but I am getting 3 weird errors.

tmx::MapLoader ml("maps/desert.tmx");

window.draw(ml);

Yet these are my errors:

Error	1	error LNK2001: unresolved external symbol "private: virtual void __thiscall tmx::QuadTreeNode::draw(class sf::RenderTarget &,class sf::RenderStates)const " (?draw@QuadTreeNode@tmx@@EBEXAAVRenderTarget@sf@@VRenderStates@4@@Z)	F:\GAMES BY ME\TiledLoader\SFMLGame\Game.obj	SFMLGame

Error	2	error LNK2019: unresolved external symbol "public: __thiscall tmx::MapLoader::MapLoader(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned char)" (??0MapLoader@tmx@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@Z) referenced in function "void __cdecl Map(class sf::RenderWindow &)" (?Map@@YAXAAVRenderWindow@sf@@@Z) F:\GAMES BY ME\TiledLoader\SFMLGame\Game.obj SFMLGame Error 3 error LNK2019: unresolved external symbol "public: bool __thiscall tmx::MapLoader::Load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Load@MapLoader@tmx@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "void __cdecl Map(class sf::RenderWindow &)" (?Map@@YAXAAVRenderWindow@sf@@@Z)	F:\GAMES BY ME\TiledLoader\SFMLGame\Game.obj	SFMLGame



Can't seem to figure out where I am going wrong here..

##### Share on other sites
Sounds like you didn't link to the library (that is, set up the linker).

##### Share on other sites

I don't have Visual Studio installed, so I can't give exact directions, but with any DLL you need to both #include the headers by the header names and tell the compiler what import file (.lib) to link to, by the import file's name.

Not only do you give it the names of the headers and the DLL's, but then the compiler also needs to know where to look for those names.

[this] is telling the compiler where to find the headers.

[this] is telling the compiler where to find the import files.

...but you still need to tell the compiler what import file to look for (that is to say, the import file's name). I believe it's this step that you're missing.

Since I don't use Visual Studio, I'm not sure of the exact location, but this screenshot looks like it's under "Linker -> Input -> [Additional dependencies: ]"

And finally, if it's a DLL rather than a static lib, your program needs to be able to find the .DLL file once it's ran. Usually this means copying the DLL to the same directory where your game's .exe is located, unless the DLL is installed to some location where the .exe can find it in the user's search paths.

Since most DLLs work very similarly, that's likely why the Github file neglected to mention it.

##### Share on other sites

I don't have Visual Studio installed, so I can't give exact directions, but with any DLL you need to both #include the headers by the header names and tell the compiler what import file (.lib) to link to, by the import file's name.

Not only do you give it the names of the headers and the DLL's, but then the compiler also needs to know where to look for those names.

[this] is telling the compiler where to find the headers.

[this] is telling the compiler where to find the import files.

...but you still need to tell the compiler what import file to look for (that is to say, the import file's name). I believe it's this step that you're missing.

Since I don't use Visual Studio, I'm not sure of the exact location, but this screenshot looks like it's under "Linker -> Input -> [Additional dependencies: ]"

And finally, if it's a DLL rather than a static lib, your program needs to be able to find the .DLL file once it's ran. Usually this means copying the DLL to the same directory where your game's .exe is located, unless the DLL is installed to some location where the .exe can find it in the user's search paths.

Since most DLLs work very similarly, that's likely why the Github file neglected to mention it.

Yeah, for some reason, there are no .dll's or libs included. Would CMAKE bring these missing DLLs and libs in?

Edited by Elit3d

##### Share on other sites

If there is no DLL or Libs, either the source code is supposed to be integrated into your own project (in which case, you forgot to add the .cpp files to your code, unless it's header only), or else it needs to be compiled first - CMake would work, only if the library is set up to be compiled by CMake.

Reading the README of this particular project, it sounds like the .cpps are supposed to be added directly to your project, just like as if they were files you wrote. However, you still need to link to the proper zlib library.

Based on your error message, you probably forgot to include the .cpps.

Basically, "unresolved external symbol" means the compiler can find the function's declaration (usually in the header files), but not the function's definition (usually in the .cpp files, or, if a DLL or static library, in the .lib file). That's why I assumed at first you weren't linking to the .lib - but if it doesn't have a .lib, that likely means you aren't adding the .cpp's to your project.

##### Share on other sites

If there is no DLL or Libs, either the source code is supposed to be integrated into your own project (in which case, you forgot to add the .cpp files to your code, unless it's header only), or else it needs to be compiled first - CMake would work, only if the library is set up to be compiled by CMake.

Reading the README of this particular project, it sounds like the .cpps are supposed to be added directly to your project, just like as if they were files you wrote. However, you still need to link to the proper zlib library.

Based on your error message, you probably forgot to include the .cpps.

Basically, "unresolved external symbol" means the compiler can find the function's declaration (usually in the header files), but not the function's definition (usually in the .cpp files, or, if a DLL or static library, in the .lib file). That's why I assumed at first you weren't linking to the .lib - but if it doesn't have a .lib, that likely means you aren't adding the .cpp's to your project.

Yeah, I forgot to include the CPP's in the project lol! All working now thanks :)