Unresolved external symbols using tag.lib on Windows 10

Luca Spiridigliozzi spiri.luca96 at gmail.com
Sat Oct 10 10:21:20 BST 2020


I already found a solution for this. TAGLIB_STATIC macro needs to be
defined when using the static library.

On Sat, Oct 10, 2020 at 8:31 AM Luca Spiridigliozzi <spiri.luca96 at gmail.com>
wrote:

> I've tested this using two different PC's getting the same results.
>
> On Sat, Oct 10, 2020 at 8:28 AM Luca Spiridigliozzi <
> spiri.luca96 at gmail.com> wrote:
>
>> Hello,
>>
>> I have troubles getting an example work on Windows 10.
>>
>> I built the library with `cmake CMakeLists.txt` + `msbuild
>> INSTALL.vcxproj` with x86_64 command prompt of Visual Studio.
>>
>> Build files got installed under `C:\Program Files (x86)` although I
>> examined the lib using dumpbin.exe and found it's 64-bit.
>>
>> Also I know there shouldn't be any space in the library path, but this
>> does not seem to be the problem when building with Visual Studio.
>>
>> So I setup a project in Visual Studio, added all the necessary
>> information to the project (Include-Dir, Lib-Dir + Lib) and then I build
>> the project without success.
>>
>> I'm getting unresolved external symbol errors as if the Lib got not
>> linked. But it is:
>>
>> 1>    C:\Program Files (x86)\Microsoft Visual
>> Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX86\x64\link.exe
>> /ERRORREPORT:PROMPT
>> /OUT:"C:\Users\\eigenartig\source\repos\exercise\x64\Debug\exercise.exe"
>> /INCREMENTAL /NOLOGO tag.lib kernel32.lib user32.lib gdi32.lib winspool.lib
>> comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
>> odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker'
>> uiAccess='false'" /manifest:embed /DEBUG:FASTLINK
>> /PDB:"C:\Users\\eigenartig\source\repos\exercise\x64\Debug\exercise.pdb"
>> /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT
>> /IMPLIB:"C:\Users\\eigenartig\source\repos\exercise\x64\Debug\exercise.lib"
>> /MACHINE:X64 x64\Debug\main.obj
>>
>> Building with 32-bit gives me architecture mismatch warnings.
>>
>> I found this behavior on both TagLib 1.11 and TagLib 1.11.1 releases and
>> I'm getting unresolved external symbols for everything, not just for
>> TagLib::String.
>>
>> I tried two build systems, MSVC and Qt.
>>
>> Can you help me making this work?
>>
>> 1>------ Build started: Project: exercise, Configuration: Debug x64 ------
>> 1>main.cpp
>> 1>C:\Program Files (x86)\taglib\include\taglib\tiostream.h(53,30):
>> warning C4251: 'TagLib::FileName::m_name': class
>> 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs
>> to have dll-interface to be used by clients of class 'TagLib::FileName'
>> 1>D:\Program Files (x86)\Microsoft Visual
>> Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xstring(4564):
>> message : see declaration of
>> 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
>> 1>C:\Program Files (x86)\taglib\include\taglib\tiostream.h(54,31):
>> warning C4251: 'TagLib::FileName::m_wname': class
>> 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>'
>> needs to have dll-interface to be used by clients of class
>> 'TagLib::FileName'
>> 1>D:\Program Files (x86)\Microsoft Visual
>> Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xstring(4565):
>> message : see declaration of
>> 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>'
>> 1>main.obj : error LNK2019: unresolved external symbol
>> "__declspec(dllimport) public: __cdecl TagLib::String::String(char const
>> *,enum TagLib::String::Type)" (__imp_??0String at TagLib@@QEAA at PEBDW4Type
>> @01@@Z) referenced in function main
>> 1>main.obj : error LNK2019: unresolved external symbol
>> "__declspec(dllimport) public: virtual __cdecl
>> TagLib::String::~String(void)" (__imp_??1String at TagLib@@UEAA at XZ)
>> referenced in function main
>> 1>main.obj : error LNK2019: unresolved external symbol
>> "__declspec(dllimport) public: __cdecl TagLib::FileRef::FileRef(void)"
>> (__imp_??0FileRef at TagLib@@QEAA at XZ) referenced in function main
>> 1>main.obj : error LNK2019: unresolved external symbol
>> "__declspec(dllimport) public: virtual __cdecl
>> TagLib::FileRef::~FileRef(void)" (__imp_??1FileRef at TagLib@@UEAA at XZ)
>> referenced in function main
>> 1>C:\Users\eigenartig\source\repos\exercise\x64\Debug\exercise.exe :
>> fatal error LNK1120: 4 unresolved externals
>> 1>Done building project "exercise.vcxproj" -- FAILED.
>> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
>> ==========
>>
>> Trying to successfully compile the following code:
>>
>> #include <taglib/taglib.h>
>> #include <taglib/tstring.h>
>>
>> int main() {
>> TagLib::String string("hello");
>> }
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20201010/dfac1492/attachment-0001.htm>


More information about the taglib-devel mailing list