unresolved external symbol __imp__Inf and __imp__Nan - c++

I just tried to build Qt for WinCE7.0 using VS2008 after lots of code modification I successfully compiled main libraries.
While Compiling the QtScript library I received the following linker errors:
1>Linking...
1> Creating library ..\..\lib\QtScript4.lib and object ..\..\lib\QtScript4.exp
1>BytecodeGenerator.obj : error LNK2019: unresolved external symbol __imp__Inf referenced in function "public: static double __cdecl QTWTF::FloatHashTraits<double>::emptyValue(void)" (?emptyValue#?$FloatHashTraits#N#QTWTF##SANXZ)
1>Executable.obj : error LNK2001: unresolved external symbol __imp__Inf
1>MathObject.obj : error LNK2001: unresolved external symbol __imp__Inf
1>DateMath.obj : error LNK2019: unresolved external symbol __imp__Nan referenced in function "double __cdecl QTWTF::parseDateFromNullTerminatedCharacters(char const *,bool &,int &)" (?parseDateFromNullTerminatedCharacters#QTWTF##YANPBDAA_NAAH#Z)
1>JSValue.obj : error LNK2001: unresolved external symbol __imp__Nan
1>..\..\lib\QtScript4.dll : fatal error LNK1120: 2 unresolved externals
I have absolutely no idea which libraries I missed to link with!
Thanks

If you're using Windows, I'll assume you're building in MSVS. I often start projects WITHOUT default libs and if I happen to touch "out of reach" terriotry from another lib, I add what I need as I go along.
Fortunately, MSVS is great at helping me with this. Just turn VERBOSE compiling status and see what libs it's trying to access, then just add them:
right click the project, linker, show progress -> select VERBOSE
Another method is when I check MSDN for Microsoft functions and see the lib they are declared in and add it (since VERBOSE can be overkill on my poor output window). I don't know if Qt has a detailed reference documentation (also stating the libs) but it's worth a shot.
When all else fails, just add all libs Qt could possibly want (make sure IGNORE STANDARD LIBS is disabled) then check VERBOSE and only keep those in the list.
Assuming you have all the libraries in the project, another problem is mismatched dependencies (right click the solution, startup project -> select the one you need, [project dependencies -> map each dependency for the specified libs).
Also make sure when you import an extern the lib is defined in Linker->Input.
However, if you modified the source (either adding new functions/global or static vars or you modified function signatures), the unresolved external reference means a function/var definition has no associated body. Either implement one or add { } in the definition; so if that's the case, check the functions/vars from the error message.

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.

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.

Unresolved external symbol _IID / _CLSID

I created a default ATL project with MSVC 2010 with a simple default ATL dialog. Then I added the second project into solution, named MyControls, where I created ATL DHTML Control with a help of Wizard. Then I placed ATL DHTML Control to ATL dialog.
Now I would like to call some methods of that ATL DHTML Control in ATL dialog's OnInitDialog function. In order to be able to make a call like:
CComPtr<IDHTMLControl> ptr;
HRESULT hr = GetDlgControl(IDC_ACTIVEX_CONTROL_DHTML
, IID_IDHTMLControl, (void**)&ptr);
I am including the file DHTMLControl.h from MyControls project. However, I get the following errors:
Error 1 error LNK2001: unresolved external symbol _IID_IDHTMLControl
Error 2 error LNK2001: unresolved external symbol _LIBID_MyControlsLib
Error 3 error LNK2001: unresolved external symbol _CLSID_DHTMLControl
Error 4 error LNK2001: unresolved external symbol _IID_IDHTMLControlUI
Note: It appears that I am linking MyControls.lib incorrectly, however, I added MyControls.lib to Linker->Input->Additonal Dependencies & specified ../$(Configuration) in the Linker->General->Additional Library Directories.
Anyone have an idea?
Thanks!
The problem is related to how you link one project with the other. There is something missing here and since you don't show the code, it's a pure guess only.
On control project you have a type library which, when being built, also generates files MyControls_i.h, MyControls_i.c, MyControls_p.c. I suppose that on the application project you included _i.h file which declared symbols as externals, and you did not include the _i.c file with symbols actually defined.

Linking DLL with Visual C++

I'm trying to use an external DLL (provided by AutoItX) with Visual C++ 2010. AutoItX provides a DLL, but for some reason not a LIB, so I generated one with Visual Studio.
The problem is that the linker seems to have trouble linking against the library. I added AutoItX3.lib as an additional dependency under Properties->Linker -> Inputs, and added the directory to Properties -> Linker -> General -> Additional Library Directories. No matter what I do, I still get these errors:
1>main.obj : error LNK2019: unresolved external symbol _AU3_Send#8 referenced in function _WinMain#16
1>main.obj : error LNK2019: unresolved external symbol _AU3_WinWaitActive#12 referenced in function _WinMain#16
1>main.obj : error LNK2019: unresolved external symbol _AU3_Run#12 referenced in function _WinMain#16
1>main.obj : error LNK2019: unresolved external symbol _AU3_Sleep#4 referenced in function _WinMain#16
AU3_Send, AU3_WinWaitActive, AU3_Run, and AU3_Sleep are functions called by the program, main.cpp. I'm really out of ideas, because these functions clearly exist in the DLL. Any help would be appreciated.
It is very common to provide only DLLs as a mean of interfaces. Many software providers do that. Doing this has following impacts (consequences):
the client applications can only dynamically link to the library provided (hence the name Dynamic-Link Library). The binding between the provider (the library) and the consumer (the App or any other Library) is made dynamically.
the client must use LoadLibray and GetProcAddress in order to bind the library and retrieve the Symbols (functions) desired
the interface (contract) between the Library and the consumer should be documented via a Header file - see AutoIt3.h for example - (or any other documentation like a help file, ..)
No LIB is provided (since it is not needed), since the Linking takes place at runtime, not at compiler/linker time
To resolve your problem you just need to remove the static dependency (the LIB) you put in the Visual Studio configuration and set the dependency at runtime using LoadLibrary and GetProcAddress