unresolved external symbol is due to .lib or .dll? - c++

I'm struggling to try to use OpenEXR in my Visual Studio 2015 project.
The OpenEXR library is successfully built. But when I build my project, I got unresolved symbol error.
I suppose the error is due to the linker failing to find the library. But I don't know if it's in .lib or .dll?
I've googled for this and it is said that for static libraries, the implementation is all in .lib file.
But for dynamically linked libraries, the implementation is in .dll file. So which caused the unresolved symbol error? .lib or .dll?
Error:
7>core.lib(ImageIO.obj) : error LNK2019: unresolved external symbol "private: static unsigned short const * const half::_eLut" (?_eLut#half##0QBGB) referenced in function "bool __cdecl Tungsten::ImageIO::saveExr(class Tungsten::Path const &,float const *,int,int,int)" (?saveExr#ImageIO#Tungsten##YA_NAEBVPath#2#PEBMHHH#Z)

Related

FLAC++ Unresolved external symbols (FLAC::Encoder::Stream::State::resolved_as_cstring and FLAC::Encoder::Stream::operator bool(void) const)

I am trying to set up the FLAC++ to allow me to encode/decode audio data, but when I attempt to compile I get 2 unresolved external errors:
LNK2019 unresolved external symbol "__declspec(dllimport) public: char const * __cdecl FLAC::Encoder::Stream::State::resolved_as_cstring(class FLAC::Encoder::Stream const &)const " (_imp?resolved_as_cstring#State#Stream#Encoder#FLAC##QEBAPEBDAEBV234##Z) referenced in function "public: int __cdecl"
LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl FLAC::Encoder::Stream::operator bool(void)const " (_imp??BStream#Encoder#FLAC##QEBA_NXZ) referenced in function "public: int __cdecl"
I am linking both the FLAC.lib and FLAC++.lib files from program files (C:\Program Files (x86)\FLAC\lib).
I have tried installing 4 different versions of FLAC (1.3.3, 1.3.4, 1.4.0 and 1.4.1) but the linking errors still persist.
Does anyone have any suggestion to why this might be happening or what I might be missing here?
Thanks!
Edit: I am using Visual Studio 2022. I have ensured that CMake is configured to generate for Visual Studio 2022, and am compiling FLAC from the same version.
Edit 2: I have solved this by downloading the library from the latest GitHub commit from (https://github.com/xiph/flac). I am unsure why, but all stable releases seem to result in the same linking errors.

How to build a static Clucene library to avoid any linker errors

I work with Windovs and I need to build a static CLucene library. I downloaded the latest source code and build them into Visual Studio 2010 Project through CMake-gui 3.4.3. When building I used a flag BUILD_STATIC_LIBRARIES = true. I successfully built two libraries: clucene-core-statics and clucene-shared-static. However, when I run the test project cl-test-static occurs a lot of linker errors. The same thing happens when I add these libraries in another test project.
Error Example:
Error 1 error LNK2019: unresolved external symbol
"__declspec(dllimport) public: static wchar_t * __cdecl
lucene::queryParser::QueryParser::escape(wchar_t const *)"
(__imp_?escape#QueryParser#queryParser#lucene##SAPA_WPB_W#Z)
referenced in function "public: void __thiscall Main::Start(void)"
(?Start#Main##QAEXXZ) c:\Users\user\documents\visual studio
2010\Projects\TestClucene\TestClucene\Main.obj TestClucene
Does anyone have any experience in building static CLucene libraries?

unresolved external symbol _gluLookAt#72 referenced in function

I'm making a program using the glu library but when i compile i got this error:
1>opengl_3.obj : error LNK2019: unresolved external symbol _gluLookAt#72 referenced in function "public: void __thiscall OpenGLContext::setupScene(void)" (?setupScene#OpenGLContext##QAEXXZ)
I included GL/glu.h and checked if the lib and dll were present. (they are by default)
I'm using visual studio 2012.
Any idea where this error is coming from?
You are not linking to glu. Add glu to the libraries against which your program should be linked. A more detailed description can be found here.

Linking with glog library

I'm trying to use the glog logging library (LINK).
In VS2012 (I'm on Windows 8 Professional 64-bit (Japanese)), I create an empty solution with a single main.cpp file like the one in the documentation (LINK).
Also I import the glog project inside the solution (either the dll one or the static library one) and set the project dependency.
To avoid some errors I have to comment out line 97 from port.h:
/* In windows-land, hash<> is called hash_compare<> (from xhash.h) */
#define hash hash_compare
While glog compiles, the main application gives me unresolved external symbol erros (with both dll and static version).
1>main.obj : error LNK2019: 未解決の外部シンボル "void __cdecl google::InitGoogleLogging(char const *)" (?InitGoogleLogging#google##YAXPBD#Z) が関数 _main で参照されました。
1>main.obj : error LNK2019: 未解決の外部シンボル "public: __thiscall google::LogMessage::LogMessage(char const *,int)" (??0LogMessage#google##QAE#PBDH#Z) が関数 _main で参照されました。
1>main.obj : error LNK2019: 未解決の外部シンボル "public: __thiscall google::LogMessage::~LogMessage(void)" (??1LogMessage#google##QAE#XZ) が関数 _main で参照されました。
I'm compiling as Win32.
If I check the debug folder it actually contains the dll+lib or static lib file.
I also tried linking to the library manually without using the visual studio dependency system, but it's the same.
I've built glog for MSVS2012 from trunk (little patch mentioned in header already presented here, as i know), so it works for me.
Looks like your dependency description of glog library is missing.
Can you add windows-specific
#pragma comment(lib, "path_to_glog_from_project_dir.lib")
to one of your project files, for example, directly into main.cpp and test it.

Using a DLL that links to a static lib

I'm trying to build a solution in Visual C++ where I have a front-end project that references a DLL project that I created. In the DLL project I link to a static library (that I have not written) that has static objects and definitions. Everything builds fine but I have linking problems.
I have a couple of questions. First, I should only get unresolved symbols for objects that I reference in the front-end that are not exported, right? I want the DLL to be the only interface to the static library and do not directly reference any part of it in the front-end, and yet I get a number of unresolved symbols from this library. There symbols seem to be #included and at least some not directly linked by the DLL project. I suspect it has to do with the static declarations in the static lib but how can I deal with these?
Some of the unresolved symbol errors:
2>AnalysisVis.obj : error LNK2001: unresolved external symbol "public: __thiscall SharkException::SharkException(char const *,int,char const *)" (??0SharkException##$$FQAE#PBDH0#Z)
2>AnalysisVis.obj : error LNK2001: unresolved external symbol "public: static class Bernoulli Rng::coinToss" (?coinToss#Rng##2VBernoulli##A)
2>AnalysisVis.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall ChromosomeT<bool>::operator<(class Chromosome const &)const " (??M?$ChromosomeT#_N##$$FUBE_NABVChromosome###Z)
The exported symbols are mangled. If the static lib was compiled using a different compiler (or compiler version) than the one you are using, it is possible that the symbols your application is expecting to see were defined in the static lib using a different name mangling scheme. You can use the following command to get the name mangling used in the static lib and then compare it to the one in the error message:
>pushd <path_to_msvc_dir>\Microsoft Visual Studio X.0\VC\bin
>dumpbin /all [static_lib_path] > out.txt
>type out.txt | find /I "SharkException"
>type out.txt | find /I "coinToss"
>type out.txt | find /I "ChromosomeT"
BTW, does the DLL that uses the static lib compiles cleanly with the same compiler your application/solution does?