<p>When building projects in C++, I've found debugging linking errors to be tricky, especially when picking up other people's code.  What strategies do people use for debugging and fixing linking errors?</p>

[{'answer_id': 34967, 'author': 'Nathan Fellman', 'author_id': 1084, 'author_profile': 'https://Stackoverflow.com/users/1084', 'pm_score': 2, 'selected': False, 'text': "<p>One of the common linking errors I've run into is when a function is used differently from how it's defined.  If you see such an error you should make sure that every function you use is properly declared in some .h file.<br>\nYou should also make sure that all the relevant source files are compiled into the same lib file.  An error I've run into is when I have two sets of files compiled into two separate libraries, and I cross-call between libraries.</p>\n\n<p>Is there a failure you have in mind?</p>\n"}, {'answer_id': 34993, 'author': 'Rob Walker', 'author_id': 3631, 'author_profile': 'https://Stackoverflow.com/users/3631', 'pm_score': 2, 'selected': False, 'text': '<p>The C-runtime libraries are often the biggest culprit.  Making sure all your projects have the same settings wrt single vs multi-threading and static vs dll.</p>\n\n<p>The MSDN documentation is good for pointing out which lib a particular Win32 API call requires if it comes up as missing.</p>\n\n<p>Other than that it usually comes down to turning on the verbose flag and wading through the output looking for clues.</p>\n'}, {'answer_id': 41043, 'author': 'Joe Schneider', 'author_id': 1541, 'author_profile': 'https://Stackoverflow.com/users/1541', 'pm_score': 6, 'selected': True, 'text': '<p>Not sure what your level of expertise is, but here are the basics. </p>\n\n<p>Below is a linker error from VS 2005 - yes, it\'s a giant mess if you\'re not familiar with it.</p>\n\n<pre><code>ByteComparator.obj : error LNK2019: unresolved external symbol "int __cdecl does_not_exist(void)" (?does_not_exist@@YAHXZ) referenced in function "void __cdecl TextScan(struct FileTextStats &amp;,char const *,char const *,bool,bool,__int64)" (?TextScan@@YAXAAUFileTextStats@@PBD1_N2_J@Z)\n</code></pre>\n\n<p>There are a couple of points to focus on: </p>\n\n<ul>\n<li>"ByteComparator.obj" - Look for a ByteComparator.cpp file, this is the source of the linker problem</li>\n<li>"int __cdecl does_not_exist(void)" - This is the symbol it couldn\'t find, in this case a function named does_not_exist()</li>\n</ul>\n\n<p>At this point, in many cases the fastest way to resolution is to search the code base for this function and find where the implementation is. Once you know where the function is implemented you just have to make sure the two places get linked together.</p>\n\n<p>If you\'re using VS2005, you would use the "Project Dependencies..." right-click menu.  If you\'re using gcc, you would look in your makefiles for the executable generation step (gcc called with a bunch of .o files) and add the missing .o file.</p>\n\n<hr>\n\n<p>In a second scenario, you may be missing an "external" dependency, which you don\'t have code for.  The Win32 libraries are often times implemented in static libraries that you have to link to.  In this case, go to <a href="http://msdn.microsoft.com/en-us/default.aspx" rel="noreferrer">MSDN</a> or <a href="http://www.google.com/microsoft" rel="noreferrer">"Microsoft Google"</a> and search for the API.  At the bottom of the API description the library name is given.  Add this to your project properties "Configuration Properties->Linker->Input->Additional Dependencies" list.  For example, the function timeGetTime()\'s <a href="http://msdn.microsoft.com/en-us/library/ms713418(VS.85).aspx" rel="noreferrer">page on MSDN</a> tells you to use Winmm.lib at the bottom of the page.</p>\n'}]
['https://Stackoverflow.com/questions/34955', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3575/']