Using taglib with Visual Studio 2017
Harry Mannbacker
harrymannbacker at gmail.com
Sun Oct 14 01:25:03 BST 2018
I'm attempting to use TagLib with Visual Studio 2017, and I'm having some
difficulties getting the examples to work, specifically with respect to
linker errors. Here is a summary of what I've done so far:
The first course of action I took was to build TagLib using Visual Studio
2017 Community Edition. I followed the directions in the INSTALL file and
used CMake to create the appropriate Visual Studio .sln file. In Visual
Studio, I compiled the "tag" project and saw that a .lib static library was
created called tag.lib.
Next, I created a Windows console project called "retag4" within its own
solution; I culled together all the header files associated with TagLib,
and then I changed the properties of retag4 as follows:
- Under C/C++, I set "Additional Include Directories" to the location
where I kept all the TagLib header files (I did this for All Configurations)
- Under Linker -> General, I updated "Additional Library Directories" to
point to the location where my tag.lib file resides.
- Under Linker -> Input, I added "tag.lib" to "Additional Dependencies".
To test the tag.lib build, I pasted the code from examples/tagreader.cpp
into retag4.cpp. Specifically, I pasted in the #include directives and the
main() function. Initially, I don't see any compilation errors in Visual
Studio, however when I do a full build on retag4, I get two C4251 warnings
with the message:
'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'
'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'
There are also a series of LNK2019 errors with verbiage like this:
unresolved external symbol "__declspec(dllimport) public: virtual
__thiscall TagLib::String::~String(void)" (__imp_??1String at TagLib@@UAE at XZ)
referenced in function _main
Based on the first warning, it looks as though the _WIN32 macro is defined
upon compilation, but it's not clear to me why I'm getting a warning here.
I've even tried rebuilding the tag project within the TagLib library such
that it produces a .dll instead of a static .lib, but this results in MSVS
complaining about an invalid .dll file.
Apologies if this is a more basic question; I'm still fairly new to Windows
programming. Am I going down the correct path using Visual Studio to
compile my retag4 code? Should I be building a .lib file or a .dll file in
this instance?
Thanks for any assistance you can provide.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20181013/5b6bc553/attachment.html>
More information about the taglib-devel
mailing list