Unresolved external between several projects in VS2010 C++ - c++

I have two C++ projects which each form a library to be referenced by a third project all as part of a Visual Studio solution.
The two libraries were written by someone else who also provided his own VS solution which included a project which acts as a demo for some of the library functions. I have successfully gotten these to compile and run. I am trying to develop a Windows application using Windows Forms which will make use of the libraries. Upon including the two necessary headers,
#include "corelib.h"
#include "corbit.h"
and trying to build the code, I receive 2 link errors:
SatTrack_v0.1.obj : error LNK2028: unresolved token (0A000010) "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __clrcall Zeptomoby::OrbitTools::cGeo::ToString(void)const " (?ToString#cGeo#OrbitTools#Zeptomoby##$$FUBM?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##XZ) referenced in function "void __clrcall `dynamic initializer for 'const Zeptomoby::OrbitTools::cGeo::`vftable'''(void)" (???__E??_7cGeo#OrbitTools#Zeptomoby##6B###YMXXZ#?A0xc222cabd##$$FYMXXZ)
SatTrack_v0.1.obj : error LNK2019: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __clrcall Zeptomoby::OrbitTools::cGeo::ToString(void)const " (?ToString#cGeo#OrbitTools#Zeptomoby##$$FUBM?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##XZ) referenced in function "void __clrcall `dynamic initializerfor 'const Zeptomoby::OrbitTools::cGeo::`vftable'''(void)" (???__E??_7cGeo#OrbitTools#Zeptomoby##6B###YMXXZ#?A0xc222cabd##$$FYMXXZ)
C:\Users\Satellite Tracking\Software\SatTrack_v0.1\Win32\(Configuration)\SatTrack_v0.1.exe : fatal error LNK1120: 2 unresolved externals
I've read through What is an undefined reference/unresolved external symbol error and how do I fix it? and I thought I linked the necessary libraries. I've gone to the project Properties | Framework and References and added the libraries. I've also added the Additional Include Directories under Properties | Configuration Properties | C/C++ | General. Also, under Linker | General I've included the proper location in Additional Library Directories and I think I have the proper Additional Dependencies under Linker | Input. In general, I've gone through many of the project properties and tried to match them to the property settings of the working demo project, but the linker problem remains.
Am I simply still missing a link somewhere or is the problem more complicated than that? Because I do have the the demo solution compiling, is there a better way to take the link settings than manually going through all of them and trying to match those which are appropriate? I've been stuck on this problem for a couple days and can't figure out what I'm missing. Where should I go from here?

Related

I can't get my own static library to work in my project

I've made a static library project and I added it to the solution that has a project which uses the library.
I included the class I needed from it in the main project like I would with another static library but it throws these errors:
error LNK2019: unresolved external symbol "public: __thiscall NetworkingLib::Base::Base(void)" (??0Base#NetworkingLib##QAE#XZ) referenced in function _SDL_main
error LNK2019: unresolved external symbol "public: void __thiscall NetworkingLib::Base::Connect(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?Connect#Base#NetworkingLib##QAEXV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##0#Z) referenced in function _SDL_main
I have no idea what is going wrong. I checked with another project that uses a library in the same way and I can't find any differences. Any help detecting the problem?
The class NetworkingLib::Base has a method I want to use. So what I did in the main project is:
#include "../NetworkLibrary/Base.h"
NetworkingLib::Base *m_pNetworkObj;
m_pNetworkObj = new NetworkingLib::Base();
m_pNetworkObj->Connect("localhost", "80");
I don't think there's anything wrong with this so the problem must be elsewhere.
It's not enough to have the static library in the same solution. You have to pass it to the linker of the project that uses it.
In Visual Studio, the best way to do this is by adding a "Project Reference". This sets up the dependency so that the projects build in the correct order, and also picks the version of the static library matching the consuming project, be that Debug vs Release, x86 vs x64, etc.

I have a third party lib, I have error LNK2019: unresolved external ... How to investigate to fix it

I have a third party libs. (msvc10) a MT/MD (Static cfgs's) and dynamic DLL cfg.
I have qt + msvc10 express + win sdk.7
Ok , I use the existing examples offered, (using the libs) I can't compile ..... I have 4 unresolved external errors of the same lib.
(But I have zero errors for the others)
I have not support for these lib...... (but they are legal, I am a member without rights)
Which are the steps to investigate a possible fix? Where I have to look ?
Thanks.
Edit 1:
The errors was:
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegEnumValueW#32 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey#4 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExW#24 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExW#20 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
..\exe\OdaQtApp.exe : fatal error LNK1120: 13 unresolved externals
During this post I have received a solution: I have to link with Advapi32.lib...
My question is : how can I know this ?
I have tried the dependencyywalker, but it cant use the .lib's....
During this post I have received a solution: I have to link with Advapi32.lib... My question is : how can I know this?
When you get an "unresolved external" error from the linker, that means that it was looking for a match for a function or variable name that some object file needs and the linker was unable to find that name defined in one of the object files or libraries.
Start by looking at the first of these errors (I've reformatted it a bit to make it slightly more readable - I encourage yo to do the same next time you come across one of these):
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol
__imp__RegEnumValueW#32 referenced in function
"public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(
class OdTtfDescriptor const &,class OdString &)"
(?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
There's a lot of stuff in that error message (much of it may look like garbage). Fortunately, much of it can be ignored in most cases. The most important item is that the linker is looking for the symbol __imp__RegEnumValueW#32 The name has some gunk on it, but fortunately it's pretty recognizable anyway.
the __imp__ prefix indicates it's looking for a DLL import. In nearly all cases that can be ignored for your purposes.
the #32 suffix is something the Microsoft compiler adds to function names for certain calling conventions. It's also generally not important for your purposes (for the record it indicates that the function expects 32 bytes of argument data)
So we're left with the fact that the linker is looking for RegEnumValueW. That looks a lot like the name of a Win32 API.
If you look at the docs for RegEnumValueW (or RegEnumValue, since many Win32 APIs have both an A and a W variant to handle ANSI/UNICODE builds) we'll find in the documentation this bit of information:
Requirements
Minimum supported client Windows 2000 Professional
Minimum supported server Windows 2000 Server
Header Winreg.h (include Windows.h)
>> Library Advapi32.lib
DLL Advapi32.dll
Unicode and ANSI names RegEnumValueW (Unicode) and
RegEnumValueA (ANSI)
That's how you know you need advapi32.lib.
So in the future, when you get an "unresolved external" error from the linker, just ignore most of the gunk in the error message and concentrate on the symbol it says it can't find - that should lead you to the library, object file or other item you might be missing.
Just for the record, advapi32.lib will be needed by most Windows applications of any complexity.
you can try to use dependencywalker to see the list of dependencies for your dlls and see what it's missing.
have you entered the *.lib file in the linker options? (input --> additional dependencies"), and in addition the path to the .lib in libraries directories option?

unresolved external symbol __imp__Inf and __imp__Nan

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.

Need help with my face recognition

I need help with my face recognition program.
I got these errors when I build my program:
error LNK2019: unresolved external symbol "public: virtual void __thiscall cv::HOGDescriptor::setSVMDetector(class std::vector<float,class std::allocator<float> > const &)" (?setSVMDetector#HOGDescriptor#cv##UAEXABV?$vector#MV?$allocator#M#std###std###Z) referenced in function "int __cdecl ppledetect(void)" (?ppledetect##YAHXZ)
error LNK2001: unresolved external symbol "public: virtual void __thiscall cv::HOGDescriptor::write(class cv::FileStorage &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?write#HOGDescriptor#cv##UBEXAAVFileStorage#2#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
error LNK1120: 11 unresolved externals
I got 11 these kinds of errors.
3 of error LNK2019 while 8 of error LNK2001 and 1 of error LNK1120.
Why is this happening?
HOGDescriptor is in opencv_objdetect.
This usually means you are missing linker dependencies (lib files)
A search shows these files you will need to add in debug:
opencv_core220d.lib
opencv_highgui220d.lib
opencv_video220d.lib
opencv_ml220d.lib
opencv_legacy220d.lib
opencv_imgproc220d.lib
If you're using Visual Studio, you can go to :
project properties -> Configuration properties -> Linker -> General
From there, set the "Additional Library Directories". This is where you enter the root directory where the lib files are located. eg: C:\program files\opencv22\lib\
You then need to go to project properties -> Configuration properties -> Linker -> Input
Under Additional Dependencies, you need to add those lib files there.
The errors mean that OpenCV is not linked correctly. Make sure you follow the instructions at http://opencv.willowgarage.com/wiki/VisualC%2B%2B.
I got same error and I resolved by previous answers.
If you're using Visual Studio: go to Project properties -> Configuration properties -> Linker -> Input -> Additional Dependencies and edit it.
You need to add "opencv_objdetect249d.lib" (I am using opencv 2.4.9 but your file name can be different, 249 can change. Look your ..\opencv\build\x64\vc10\lib directory and write your file's name: opencv_objdetect???d.lib)

Trying to compile program that uses zlib. Link unresolved error

While trying to compile program, that uses zlib, i got following errors:
Error 1 error LNK2019: unresolved
external symbol _compress referenced
in function "void __cdecl
save_image_in_pakfile(class
std::basic_ofstream > &,struct
_IplImage *)" (?save_image_in_pakfile##YAXAAV?$basic_ofstream#DU?$char_traits#D#std###std##PAU_IplImage###Z) buffer_management.obj
Error 2 error LNK2001: unresolved
external symbol
_compress fern_based_point_classifier.obj
And two more same errors but related to uncompress function.
I use the vs2008 C++, and at the project properties I added in
C/C++ : Additional include directories the path to header files of zlib.
And at linker properties I added at additional dependencies:
zlibwapi.lib and zlibstat.lib files.
How to resolv the problem?
If I made some mistakes please show me them..