Unresolved External Symbol Error

I really hate this error because no matter how much you click on them they won't show you any hint at all about the errors. And when you search the web it will take you like a couple of searches before you can even find a clue on how to resolve this $"(!)"(' error!

So below are my collection of unresolved external Symbol errors and the solution.

Possible solutions:

1. Add external libraries to your application. You can do this by going to your code properties (right click your top file on solutions explorer for visual studio -> Linker -> Input). Yup,it's all about the libraries! There is no choice but familiarize yourself with the windows library.

2. Your program which you may have copied from somewhere might be pointing to a different library. If the library was compiled using release then you can not use it for debug or else you will get these errors!

3. Your program maybe using variables from your header file that is either not being used or placed in a wrong block.

Anyway here is what I encountered today and I'll just add some more as I encounter them.

In English
===========
error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function _main
fatal error LNK1120: 1 unresolved externals

My System - Japanese
====================
error LNK2019: 未解決の外部シンボル _inet_ntoa@4 が関数 "int __cdecl doit(int,char * *)" (?doit@@YAHHPAPAD@Z) で参照されました。
LNK2019: 未解決の外部シンボル _gethostbyname@4 が関数 "int __cdecl doit(int,char * *)" (?doit@@YAHHPAPAD@Z) で参照されました。
error LNK2019: 未解決の外部シンボル _WSAGetLastError@0 が関数 "int __cdecl doit(int,char * *)" (?doit@@YAHHPAPAD@Z) で参照されました。
error LNK2019: 未解決の外部シンボル _gethostname@8 が関数 "int __cdecl doit(int,char * *)" (?doit@@YAHHPAPAD@Z) で参照されました。
error LNK2019: 未解決の外部シンボル _WSAStartup@8 が関数 _main で参照されました。
fatal error LNK1120: 外部参照 5 が未解決です。


Using solution 1:

Add wsock32.lib
================================================================================

Another link error - LNK2001

>main.obj : error LNK2001: 外部シンボル ""public: int __thiscall ClassSamp::Cleanup(void)"

Make sure that it is not declared in another part of the code. For example in this case the Cleanup is declared inside the class but I forgot to put the :: when I created the function.

コメント

人気の投稿