Unresolved external symbol globalThreadCount when trying to compile a project including openexr - c++

I've cloned the pbrt-v3 repository using Visual Studio 2017. I've tried to compile a project where I included the Transform.h, but I'm getting the following error from the linker:
LNK2019 unresolved external symbol "int __cdecl Imf::globalThreadCount(void)" (?globalThreadCount#Imf##YAHXZ) referenced in function "class pbrt::RGBSpectrum * __cdecl pbrt::ReadImageEXR(class std::basic_string,class std::allocator > const &,int *,int *,class pbrt::Bounds2 *,class pbrt::Bounds2 *)" (?ReadImageEXR#pbrt##YAPEAVRGBSpectrum#1#AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PEAH1PEAV?$Bounds2#H#1#2#Z)
I've compiled and installed openexr using CMake for Visual Studio. I've added
libpbrt.lib
libglog_static.lib
IlmThread-2_2.lib
Half.lib
Iex-2_2.lib
IexMath-2_2.lib
Imath-2_2.lib
as additional dependencies in the project settings. I wasn't able to figure out in which library globalThreadCount is defined. So, which library am I missing?

Related

Error building c++ project with ppconsul(Consul client for c++)

I'm a beginner to cpp and trying to use a cpp library called ppconsul(https://github.com/oliora/ppconsul ). This library has dependency to some of other libraries like (boost and curl). I have build ppconsul with all its dependencies and trying to use ppconsul executable in a new project. When I try to build the new project, I'm getting some linker issue like below.
error LNK2001: unresolved external symbol "public: virtual char const * thiscall ppconsul::BadStatus::what(void)const " (?what#BadStatus#ppconsul##UBEPBDXZ)
1>ConsulApp.obj : error LNK2019: unresolved external symbol "class std::basic_string,class std::allocator > __cdecl ppconsul::helpers::encodeUrl(class std::basic_string,class std::allocator > const &)" (?encodeUrl#helpers#ppconsul##YA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABV34##Z) referenced in function "void __cdecl ppconsul::parameters::detail::printParameter(class std::basic_ostream > &,class std::basic_string,class std::allocator > const &,struct ppconsul::kw::dc_keyword)" (??$printParameter#Udc_keyword__#kw#ppconsul###detail#parameters#ppconsul##YAXAAV?$basic_ostream#DU?$char_traits#D#std###std##ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##4#Udc_keyword__#kw#2##Z)
I tried to link the project and change the visual studio but nothing worked. Anybody has any idea about this linker issue?
TIA,
Prassi
Issue resolved- Refer this thread github.com/oliora/ppconsul/issues/24
build ppconsul as a static library by passing -DBUILD_STATIC_LIB=ON to CMake.

OpenCV via NuGet packages with Visual Studio 2015, how to configure?

I'm trying to use OpenCV via NuGet packages with Visual Studio 2015 and I can't seem to get everything configured. I'm not sure if I'm making a mistake somewhere or what I'm trying is not supported.
A little background, I made this tutorial a while back:
https://www.youtube.com/watch?v=7SM5OD2pZKY
https://github.com/MicrocontrollersAndMore/OpenCV_3_Windows_10_Installation_Tutorial
And I'd like to update this to use NuGets if possible. I use NuGets on the job every day so I'm familiar with the concept, but I've only previously used NuGets with .Net (Visual Basic or C#) applications.
I'm trying to make this work with plane jane C++ OpenCV, not within a .NET or UWP app.
For the record, in a separate .Net test project, I tried the EmguCV NuGet package:
With Visual Studio 2015 and everything worked as expected (for those not familiar, Emgu CV is probably the oldest/best known/most stable .Net wrapper for OpenCV)
Here are the steps I tried to get regular C++ OpenCV to work within Visual Studio 2015 using NuGets:
Start Visual Studio 2015, make an Empty Project:
Bring up the NuGet package manager:
I choose OpenCV.Win.ImgProc as that seemed to be the only OpenCV 3.x NuGet available, this also auto imported Core as expected:
Then I added a .cpp file and copied/pasted in known-good OpenCV code, the OpenCV libraries are not recognized:
I tried Build -> Clean, Build -> Build, same concern. I also tried "Solution Configurations" and "Solution Platforms" set to Debug / Release / x86 / x64, same concern.
Am I missing a step here? Do NuGets only work within a managed environment such as .Net or UWP, or can they work with regular C++ as well? I did notice the mention in the Description about UWP:
But I'm not using VideoIO, so I'm not sure that should matter.
Has anybody had any success with this? I can always go back to the "old school" way of directly referencing libraries in Project -> (project name) Properties as shown in my tutorial linked to above, but I'd like to use NuGets if possible.
----------- Edit ---------------
I had to place my response to Leo-MSFT here to allow for enough characters and screenshots. Thanks for the suggestion Leo-MSFT, but two problems with that. For one, that package is OpenCV 2.4.10, very outdated by now:
2nd, if I use that package the red underlines are gone, but I get the following linker errors when I try to build and run:
1>------ Build started: Project: Test2, Configuration: Debug x64 ------
1> test.cpp
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree#cv##YAXPEAX#Z) referenced in function "public: __cdecl cv::Mat::~Mat(void)" (??1Mat#cv##QEAA#XZ)
1>test.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray#cv##QEAA#AEBVMat#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::_OutputArray::_OutputArray(class cv::Mat &)" (??0_OutputArray#cv##QEAA#AEAVMat#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QEAAXXZ) referenced in function "public: void __cdecl cv::Mat::release(void)" (?release#Mat#cv##QEAAXXZ)
1>test.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::copySize(class cv::Mat const &)" (?copySize#Mat#cv##QEAAXAEBV12##Z) referenced in function "public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Mat const &)" (??4Mat#cv##QEAAAEAV01#AEBV01##Z)
1>test.obj : error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd#cv##YAHPEAHH#Z) referenced in function "public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Mat const &)" (??4Mat#cv##QEAAAEAV01#AEBV01##Z)
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class std::basic_string,class std::allocator > const &,int)" (?namedWindow#cv##YAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey#cv##YAHH#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string,class std::allocator > const &,class cv::_InputArray const &)" (?imshow#cv##YAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEBV_InputArray#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string,class std::allocator > const &,int)" (?imread#cv##YA?AVMat#1#AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::GaussianBlur(class cv::_InputArray const &,class cv::OutputArray const &,class cv::Size,double,double,int)" (?GaussianBlur#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#V?$Size_#H#1#NNH#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::Canny(class cv::_InputArray const &,class cv::_OutputArray const &,double,double,int,bool)" (?Canny#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#NNH_N#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cvtColor(class cv::_InputArray const &,class cv::_OutputArray const &,int,int)" (?cvtColor#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#HH#Z) referenced in function main
1>C:\Users\cdahms\Documents\Test2\x64\Debug\Test2.exe : fatal error LNK1120: 13 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
After trying various options, I've settled on this package:
Which seems to work, although it's not very confidence inspiring that it is clearly labeled "not an official package" and also that it's slightly out of date (not many changes from OpenCV 3.1.0 to 3.2.0 however). I suppose I'll use this until a proper updated package is released.
The OpenCV libraries package is OpenCV3.1 rather than OpenCV.Win.ImgProc for your test OpenCV code.
Below is my test result, so you just need to install the OpenCV3.1 NuGet package instead of OpenCV.Win.ImgProc for that OpenCV code.
Note that: OpenCV3.1 is not an official package.

libpng function calls are all unresolved external symbols

I am trying to link my project against the libpng version 1.6.23 dll library, but my linker only sees all function calls that I make to it as unresolved external symbols. I am using Visual Studio Express 2013. Here is a snippet of the linker's output.
1>PNGUtils.obj : error LNK2019: unresolved external symbol png_set_sig_bytes referenced in function "public: static void * __cdecl PNGUtils::Read(char const *,unsigned int &,unsigned int &,int &)" (?Read#PNGUtils##SAPEAXPEBDAEAI1AEAH#Z)
1>PNGUtils.obj : error LNK2019: unresolved external symbol png_sig_cmp referenced in function "private: static bool __cdecl PNGUtils::Validate(struct _iobuf *)" (?Validate#PNGUtils##CA_NPEAU_iobuf###Z)
1>PNGUtils.obj : error LNK2019: unresolved external symbol png_create_read_struct referenced in function "public: static void * __cdecl PNGUtils::Read(char const *,unsigned int &,unsigned int &,int &)" (?Read#PNGUtils##SAPEAXPEBDAEAI1AEAH#Z)
1>PNGUtils.obj : error LNK2019: unresolved external symbol png_set_longjmp_fn referenced in function "public: static void * __cdecl PNGUtils::Read(char const *,unsigned int &,unsigned int &,int &)" (?Read#PNGUtils##SAPEAXPEBDAEAI1AEAH#Z)
1>PNGUtils.obj : error LNK2019: unresolved external symbol png_create_info_struct referenced in function "public: static void * __cdecl PNGUtils::Read(char const *,unsigned int &,unsigned int &,int &)" (?Read#PNGUtils##SAPEAXPEBDAEAI1AEAH#Z)
1>PNGUtils.obj : error LNK2019: unresolved external symbol png_read_info referenced in function "public: static void * __cdecl PNGUtils::Read(char const *,unsigned int &,unsigned int &,int &)" (?Read#PNGUtils##SAPEAXPEBDAEAI1AEAH#Z)
1>PNGUtils.obj : error LNK2019: unresolved external symbol png_set_expand_gray_1_2_4_to_8 referenced in function "public: static void * __cdecl PNGUtils::Read(char const *,unsigned int &,unsigned int &,int &)" (?Read#PNGUtils##SAPEAXPEBDAEAI1AEAH#Z)
I am linking successfully with other libraries such as lua and glew, and I am to my knowledge doing nothing different when trying to link to libpng.
Strangely, when I put the linker into verbose mode. It states...
1> Finished searching libraries
1>
1> Unused libraries:
1> libs\png\libpng16.lib
The linker seems to claim that I am not using the libpng library even though I am clearly calling its functions such as in my code segment here in PNGUtils.cpp Read method.
png_structp pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pngPtr)
{
LOG(LOG_CHANNEL_ERROR, "PNGUtils: Couldn't initialize png read struct");
fclose(fp);
return NULL;
}
png_infop infoPtr = png_create_info_struct(pngPtr);
if (!infoPtr)
{
LOG(LOG_CHANNEL_ERROR, "PNGUtils: Couldn't initialize png info struct");
png_destroy_read_struct(&pngPtr, (png_infopp)0, (png_infopp)0);
fclose(fp);
return NULL;
}
I feel lost on why the linker seems to be ignoring the function calls to libpng. I would be happy to hear any thoughts or answers and am of course more than willing to provide any more information on request.
Be sure that your project and your libpng.dll were built with
the same settings, as explained in the projects/vstudio/README.txt that comes with libpng:
WARNING
======= Libpng 1.6.x does not use the default run-time library when
building static library builds of libpng; instead of the shared DLL
runtime it uses a static runtime. If you need to change this make
sure to change the setting on all the relevant projects:
libpng
zlib
all the test programs
The runtime library settings for each build are as follows:
Release Debug
DLL /MD /MDd
Library /MT /MTd
NOTICE that libpng 1.5.x erroneously used /MD for Debug DLL builds; if
you used the debug builds in your app and you changed your app to use
/MD you will need to change it back to /MDd for libpng 1.6.0 and
later.
The Visual Studio 2010 defaults for a Win32 DLL or Static Library
project are as follows:
Release Debug
DLL /MD /MDd
Static Library /MD /MDd
Also, be sure to build libpng, zlib, and your project all for the same
platform (e.g., 32-bit or 64-bit).
cI know the question is a bit old, but maybe there are people having same difficulties.
In my case 2 steps to solve "unresolved link" (with Visual Studio 16.4.6 2019) issue were:
to compile my project as x86 (as the libraries I was using were built under this architecture) and use 32 bits version of libpng .dll
add zlib (including zlib.h in the code and linking with the corresponding .dll and .lib)
After doing this, it compiled sucessfully.

linking error with CMake and Visual Studio 2010

I'm trying to compile osgearth library with VS2010. The library uses CMake, so after setting all dependencies it generates a VS2010 solution file. However when running build in VS I get this linker error (and 200 similar ones)
Error 7 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_ofstream >::`vbase destructor'(void)" (_imp??_D?$basic_ofstream#DU?$char_traits#D#std###std##QAEXXZ) referenced in function "public: virtual void __thiscall osgEarth::DiskCache::setImage(class osgEarth::TileKey const &,struct osgEarth::CacheSpec const &,class osg::Image const *)" (?setImage#DiskCache#osgEarth##UAEXABVTileKey#2#ABUCacheSpec#2#PBVImage#osg###Z) C:\swproj\osgearth-src\src\osgEarth\Caching.obj osgEarth
I'm not very familiar with C++, is there anything else I have to set up?
You're missing a reference to std::ofstream. You either need an #include in one of your files or a reference to the standard library dll in your project.

Linking error while using Visual Studio 2005(VC8)

I am getting a bunch of linking errors while trying to link the release version of an executable(debug version does not have the same issue). Comparing the command line for the link does not reveal any issues.
there are broadly 2 types of errors neither of which I can get a handle on.
The first kind complains about a unresolved external symbol _declspec(dllimport)
As an example:
error LNK2019: unresolved external symbol
"_declspec(dllimport)
public: __thiscall
stlpd_std::basic_string,class stlpd_std::allocator >::basic_string,class stlpd_std::allocator >(class stlpd_std::basic_string,class stlpd_std::allocator > const &)" (_imp??0?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std##QAE#ABV01##Z) referenced in function "public: __thiscall Springfield::generic::runtime_error::runtime_error(class stlpd_std::basic_string,class stlpd_std::allocator > const &)" (??0runtime_error#generic#Springfield##QAE#ABV?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std###Z)
for a more human readable version(replacing all the strings):
error LNK2019: unresolved external symbol
"__declspec(dllimport)
public: __thiscall
string::basic_string,class stlpd_std::allocator >(class string const &)" (_imp??0?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std##QAE#ABV01##Z) referenced in function "public: __thiscall Springfield::generic::runtime_error::runtime_error(class string const &)" (??0runtime_error#generic#Springfield##QAE#ABV?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std###Z
The sceond class of errors complains about
unresolved external symbol __CrtDbgReportW
I hope I can get some kind of insight in dealing with this.
From the errors it looks like you are not including the CRT as one of your linked libraries. Here is a link to the different CRT lib's offered in Visual Studio 2005. Choose the one which is most appropriate and make sure it's in the list of lib's to link against
http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.80).aspx
It looks like you're either including a file that's been built using the debug settings or you're mixing runtime libraries (DLL and static).