Unresolved External Error - How to know what libraries are mising ? VS2013 - c++

How do I know what libraries are required when I get such errors ? Is there a strategy on to determine the library I need given the error ? Note that this is a library problem Below is just one of the 90+ unresolved errors.
Error 74 error LNK2001: unresolved external symbol "public: virtual bool __cdecl pcl::search::Search<struct pcl::PointXYZRGB>::getSortedResults(void)" (?getSortedResults#?$Search#UPointXYZRGB#pcl###search#pcl##UEAA_NXZ) c:\Users\Haziq\documents\visual studio 2013\Projects\PCL-Tutorial\PCL-Tutorial\main.obj PCL-Tutorial

Yes, you can write code to check all installed .a and .so libraries on the system, generating the symbol table for each one, and GREPping the output for the symbol(s) that remain undefined.

Related

How should I deal with "Fatal error LNK1120" when I tried to compile Ipopt-3.9.3 in Windows 10 & Visual C++ 2010

all.
I’m compiling Ipopt-3.9.3 in Windows 10 & Visual C++ 2010 Express.
I’ve built the projects of libCoinBlas, libConHSL, libCoinLapack as well as libIpopt, and generated libCoinBlas.lib, libCoinHSL.lib, libCoinLapack.lib as well as libIpopt.lib in the correct paths but with some warnings.
While when I tried to build the projects of IpoptAmplSolver and hs071_cpp, there exists the following fatal errors.
5>  Generating Code...
5> Creating library Release\IpoptAmplSolver.lib and object Release\IpoptAmplSolver.exp
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlc_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlc_
5>dlascl.obj : error LNK2019: unresolved external symbol _disnan_ referenced in function _dlascl_
5>dpotf2.obj : error LNK2001: unresolved external symbol _disnan_
5>Release\IpoptAmplSolver.exe : fatal error LNK1120: 3 unresolved externals
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
5>------ Rebuild All started: Project: hs071_cpp, Configuration: Release Win32 ------
5>  hs071_main.cpp
5>  hs071_nlp.cpp
5>  Generating Code...
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlc_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlc_
5>dlascl.obj : error LNK2019: unresolved external symbol _disnan_ referenced in function _dlascl_
5>dpotf2.obj : error LNK2001: unresolved external symbol _disnan_
5>LIBCMT.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
5>Release\hs071_cpp.exe : fatal error LNK1120: 4 unresolved externals
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
Is there anyone who can kindly tell me how should I deal with it?
Thank you very much for your attention, and I’m looking forward to your kind aid.
Finally, I've solved this problem which is due to the undefined functions. I think my case is about a released software package rather than some specific procedure code, hence, it's a little different and relative simple.
Without knowing the specifics of the libraries you are using, I recommend that you try the following to deal with this error:
The error tells you that the linker is missing code for some function calls. This probably means that a library file is not found. Make sure that the linker can find all needed lib files. Check the property pages. Under the Linker->General->Additional library directories, make sure that the directories where your lib-files are located are present and under Linker->Input->Additional dependencies, make sure that the the lib-files are listed. Also make sure that the parameters are present for the different Configurations.
If this still does not help, check if your libraries depend on other libraries. These should be mentioned in the documentation of the libraries you are using.
I've not built this, but here's what I would try from the start. From what you've said, you've compiled the .lib files that it links against and it's failing during linking.
So here are your options...
1) You've either missed a .lib file in the input list for the linker.
2) The actual .lib file doesn't contain the symbol that the linker needs (you can check this by dumping the symbols of the .lib file)
3) Your .lib file is compiled with either the wrong platform than what you're linking with or with the wrong type ie. release/debug.
4) The symbols in your lib are decorated because you're compiling as C++ instead of C, or visa-versa.
If you go through the above steps above, I'm pretty sure you'll find your problem, but you've not really given enough information to properly answer your question. Personally, I'd have a guess that you're compiling C as C++ or you've got the wrong platform type set for one of your lib files.
Thank you all very much for your patient and detailed advices that inspired me, and I finally find out that I should add some C files which define the necessary functions into my project. The detailed solution is as follows.
For example, I want to eliminate
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
Step 1: Run
f2c iladlr.f
In the Visual Stuido Command Prompt and generate iladlr.c.
Step 2: Add iladlr.c to my project.
Step 3: Rebuild.
Finally, everything goes well.

Live555 and Visual Studio 2010

I am trying to compile Live555 test programs in Visual Studio 2010, but I wasn't able to do so.
I compiled the libraries without any problems
BasicUsageEnvironment.lib
groupsock.lib
liveMedia.lib
UsageEnvironment.lib
but when it comes to the test programs, I just couldn't get anywhere. Here is the compiler message when I compile files in the mediaServer.
Has anyone encountered this problem before?
error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3#YAXPAX#Z)
error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2#YAPAXI#Z)
error LNK2001: unresolved external symbol ___security_cookie
error LNK2001: unresolved external symbol ___CxxFrameHandler3
error LNK2001: unresolved external symbol #__security_check_cookie#4
error LNK2001: unresolved external symbol __RTC_CheckEsp
error LNK2001: unresolved external symbol __RTC_Shutdown
error LNK2001: unresolved external symbol __RTC_Shutdown
error LNK2001: unresolved external symbol __RTC_InitBase
error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info##6B#)
error LNK2001: unresolved external symbol "public: virtual bool __thiscall Medium::isSource(void)const " (?isSource#Medium##UBE_NXZ)
<more errors>
Complete dump here: http://pastebin.com/4bVQAcdp
Update
I failed to build the project earlier because I unchecked the "Precompiled header" option when creating projects for all the libraries. When linking the libraries to my mediaServer project, VS was unable to resolve all the functions.
I was able to make it work by rebuilding them with "Precompiled header" option checked, and add #include "stdafx.h" to each and every *.cpp file.
Afterthought: I have a feeling that I only need to turn on "Precompiled header" option for the mediaServer project. Let me know if you have tried and succeeded. ;-)
Update 2
Nope. I had to turn on Precompiled Header for each and every one of the static library projects. And add #include "stdafx.h" to ~200 *.cpp files. Yep.
Update
I took a look at your full dump:
1>UsageEnvironment.lib(HashTable.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3#YAXPAX#Z)
Based on this first error, what ever source you compiled for your UsageEnviroment Lib, has a reference to a delete operator function. My guess is that either you don't have the correct source code you altered it. Can paste the UsageEnvironment.hh file contents?
I happened to be working on building this right now, I just got it working this morning, and per your request I compiled the Test Program "mediaServer". We are operating on a few assumptions here, we are assuming that you built the static libraries correctly.
Assuming the static libraries are correct this is the solution your looking for:
Include:
c:\Live555\BasicUsageEnvironment\include
c:\Live555\liveMedia\include
c:\Live555\UsageEnvironment\include;
c:\Live555\groupsock\include
$(IncludePath)
Lib Paths:
"*Insert path to your lib files here*";
$(LibraryPath)
Linker input:
Ws2_32.lib
groupsock.lib
BasicUsageEnvironment.lib
liveMedia.lib
UsageEnvironment.lib
libBasicUsageEnvironment.lib
libgroupsock.lib
Your solution folder should look like this:
Make sure the files in Bold are there.
your Source Folder should have the following files:
mediaServer:
**DynamicRTSPServer.cpp**
**DynamicRTSPServer.hh**
**live555MediaServer.cpp**
mediaServer.vcxproj
mediaServer.vcxproj.filters
ReadMe.txt
**rtcp_from_spec.c**
**rtcp_from_spec.h**
stdafx.cpp
stdafx.h
targetver.h
**version.hh**
Based on your errors its looks like you have incorrect source files included in your project, those unresolved reference don't appear anywhere in the live555 project tar file.
http://live555.com/liveMedia/public/live555-latest.tar.gz
If this solution doesn't work, please provide screen shots of your project settings for the following tabs:
include directories
Linker Input
File listing for your project folder.
Let me know if this helps, if this doesn't work we will have to look into how your static libraries were built. We need to see where in your code, those external references are being made, and what ever is making those references need to be excluded as they don't appear in the live555 archive referenced in the link below.

unresolved external symbol inflateEnd (and others) while using boost Zlib

I'm in the process of converting 32bit project to x64. In most cases it just means appending 64 to library paths (and eventually building those libraries for x64). Now I assume all libraries are already ready and the code is also x64 compatible. But I keep getting errors for boost zlib library, like these:
error LNK2019: unresolved external symbol inflateEnd
error LNK2019: unresolved external symbol inflate
error LNK2019: unresolved external symbol inflateInit_
error LNK2019: unresolved external symbol deflateEnd
error LNK2019: unresolved external symbol deflate
error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::default_compression"
error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::deflated"
error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::default_strategy"
I enabled verbose mode for linker (in MS Visual Studio you do this by adding /VERBOSE:LIB to additional linker options). Thanks to that, I can see this output line:
Searching .\..\..\libs\boost145\stage\lib64\libboost_zlib-vc100-mt-gd-1_45.lib
That would imply that the library was found in the boost145\stage\lib64. So what should I be looking for now?
One strange thing is that file that defines the first group of missing symbols (those that are not within boost) has header files within the project, zlib.h and zconf.h. Maybe this is some hint? The zlib.h defines external symbols as:
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
Obvious question is: where the hell is lib file for this header file?
I had the same issue, to resolve the errors I download the source from zlib and built the x64 dlls/libs locally. There were a couple issues with solution file downloaded, fixes are described below.
Zlib 1.2.8 source code: http://zlib.net/zlib128.zip
Solution File for VS2012 is located at: zlib-1.2.8\contrib\vstudio\vc11\zlibvc.sln
Fixes:
Change:
<Command>cd ..\..\..\contrib\masmx64
bld_ml64.bat</Command>
to:
<Command>cd ..\..\contrib\masmx64
bld_ml64.bat</Command>
In zlibvc project properties -> Linker -> Advanced -> Image Has Safe Exception Handlers -> set to No (/SAFESEH:NO). Info about SAFESEH: Compiling libffi with VS2012 fails with fatal error LNK1281: Unable to generate SAFESEH image

DLL linking to static libraries

We have a project which is an executable, which loads DLL files at run time as plugins.
We're trying to make a new plug in which has many library dependencies, and some of those dependencies are the same library but different versions that other plugins link to.
Because the libraries are depended on by different plugins at different versions, I would like to statically link/build any dependencies into the new plugin - that way they can't conflict with the old plugin dependencies. As far as I know, nothing in the dependencies of the plugin need to be exported, they're just used by the plugin.
Is it possible to do this?
I've tried building all the static libs in visual studio as static libraries with the runtime set to Multithreaded DLL with the /MD flag, but when I try to build dynamiclibB.dll, I get linker errors. If I set dynamiclibB to build as a static library, it doesn't have the linker errors.
I haven't tried linking newplugin.dll to the static library version of dynamiclibB yet, but I think I have exactly the same situation, so I see no reason why it would work there where it doesn't one level down.
I don't want to build dynamiclibB as a static library anyway, as it would be good to be able to update newplugin.dll without including dynamiclibB.dll if it hasn't been changed, as in, to decouple the update process. This line of reasoning would suggest that I should have .dlls for everything, but the conflicts of versions is what worries me, I think.
I cannot build the plugins as static libraries as they need to be loaded at run time.
Absolutely everything is being built in release mode for now, to avoid that complication.
What am I missing?
An attempt at a diagram that might help understand the situation:
program.exe
|
________________
| |
oldplugin.dll newplugin.dll
| |
dynamiclibA.dll dynamiclibB.dll
|
_________________________
| | |
staticlibA.lib slibC.lib slibD.lib
Update:
Providing some more information now that I know what's happening, and know that more specific details are actually relevant.
So library A, represented by dynamiclibA and staticlibA was zlib.
The library we were compiling (dynamiclibB) for use in the newplugin was PoDoFo.
The error messages we got were:
Error 19 error LNK2001: unresolved external symbol
_deflateInit_ E:\Work\podofo_bin\src\PdfFiltersPrivate.obj podofo_shared Error 20 error LNK2001: unresolved external symbol
_inflateEnd E:\Work\podofo_bin\src\PdfFiltersPrivate.obj podofo_shared Error 21 error LNK2001: unresolved external symbol
_inflateEnd E:\Work\podofo_bin\src\libpng16.lib(pngread.obj) podofo_shared Error 22 error LNK2001: unresolved external symbol
_deflate E:\Work\podofo_bin\src\PdfFiltersPrivate.obj podofo_shared Error 23 error LNK2001: unresolved external symbol
_deflate E:\Work\podofo_bin\src\libpng16.lib(pngwutil.obj) podofo_shared Error 24 error LNK2001: unresolved external symbol
_deflateEnd E:\Work\podofo_bin\src\PdfFiltersPrivate.obj podofo_shared Error 25 error LNK2001: unresolved external symbol
_deflateEnd E:\Work\podofo_bin\src\libpng16.lib(pngwrite.obj) podofo_shared Error 26 error LNK2001: unresolved external symbol
_inflateInit_ E:\Work\podofo_bin\src\PdfFiltersPrivate.obj podofo_shared Error 27 error LNK2001: unresolved external symbol
_inflateInit_ E:\Work\podofo_bin\src\libpng16.lib(pngrutil.obj) podofo_shared Error 28 error LNK2001: unresolved external symbol
_inflate E:\Work\podofo_bin\src\PdfFiltersPrivate.obj podofo_shared Error 29 error LNK2001: unresolved external symbol
_inflate E:\Work\podofo_bin\src\libpng16.lib(pngrutil.obj) podofo_shared
Putting the rest in an answer.
In my question, slibc.lib was libpng. Libpng also requires zlib, but it builds it from source inside its solution. We were able to use the output of that project in the way we desired, as in, zlib.lib built with /MD flag, without linking errors.
We've also managed to work out why this problem occurred:
another stackoverflow question was very relevant: https://stackoverflow.com/a/6559315/78823
Turns out that zlib has a #define ZLIB_WINAPI which defined the call convention to be STDCALL, which I don't understand, but it caused the linker errors. The other answer suggests to remove the define, and I suppose that's what libpng did with its zlib project.
I'm guessing that the reason why the linker errors only occurred when building the .dll and disappeared when building the .lib is because (correct me if I'm wrong, I don't fully understand this), build a .lib doesn't actually do the linking to the required functions, so would have been just passing on the linker errors to the next level up; I think we would have seen the same errors (but in different objs/projects perhaps) when compiling newplugin.dll, but we didn't get far enough to check that before we tried other things.

Why will I have link errors when invoking a library (building the library is successful) in C++

I have a question related to invoking a C++ library. The compilation of the library is successful. After that, the library is invoked by a normal executable program. However, several link errors occur.I give an example to illustrate my problem.
I have download an old version of TIFF library (version 3.6.1) and then compiled it to a static library: tiff.lib. After that I wrote an executable program for reading and writing TIFF files by invoking the library. However, the following errors appear:
2>tiff.lib(tif_jpeg.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
2>tiff.lib(tif_lzw.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
2>tiff.lib(tif_dirinfo.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
2>tiff.lib(tif_luv.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
2>tiff.lib(tif_pixarlog.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
2>tiff.lib(tif_zip.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
2>tiff.lib(tif_dirwrite.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
2>tiff.lib(tif_write.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
2>tiff.lib(tif_dirread.obj) : error LNK2001: unresolved external symbol __TIFFmalloc
I cannot understand why I will receive link errors as tiff.lib has been built successfully and it has also been linked successfully by my executable program. If something wrong with tiff.lib, I expect the link errors should appear during the compilation and link procedure when building the lib. Any ideas will be appreciated!
EDIT: I add some details in order to find the solution. tiff.lib is built as a static library, and when I use dumpbin.exe /exports tiff.lib to display all definitions exported in the library, the following message is given:
Dump of file tiff.lib
File Type: LIBRARY
Summary
3B8 .bss
9405 .data
D5640 .debug$S
C38 .debug$T
C4E .drectve
19E79 .rdata
84 .rtc$IMZ
84 .rtc$TMZ
3363E .text
It seems that no symbols are exported.
I think tiff.lib is C library and you are linking in c++. So I guess you will need to use extern "C" to include its header .h file.
extern "C"
{
#include<tiff.h>
}
Something like that above is just example. Also make sure you are setting correct calling convention in project property page of your c++ project
C/C++ ----------> Advanced ---------->Call Convention--->_cdecl(/Gd) //Set only if required
C/C++----------->Advanced------------>Compile As----->C++ Code(/TP)
Based on the discussions, I have come to realize that my program's error lies in the fact that some functions have not been defined correctly. It may happen that in some libraries the function may be declared in the head file with the keyword "extern". However, the implementation of the function is defined in another file, which could be excluded when building the library. Function calling conversion, as explained by #praks411, is another scenario, which you should consider when you meet with the same problem.