karastojko/mailio

LNK2001 Unresolved external symbol "public: __cdecl mailio::mime::content_type_t::content_type_t(enum mailio::mime::media_type_t,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"

Closed this issue · 2 comments

I wrote a function like that:

mailio::mime::content_type_t GetContentType(std::string ndext)
{
	mailio::mime::media_type_t mtt;
	if (CT_TEXT.find(ndext) != CT_TEXT.end())
		mtt = mailio::mime::media_type_t::TEXT;
	else if (CT_IMAGE.find(ndext) != CT_IMAGE.end())
		mtt = mailio::mime::media_type_t::IMAGE;
	else if (CT_AUDIO.find(ndext) != CT_AUDIO.end())
		mtt = mailio::mime::media_type_t::AUDIO;
	else if (CT_VIDEO.find(ndext) != CT_VIDEO.end())
		mtt = mailio::mime::media_type_t::VIDEO;
	else
		mtt = mailio::mime::media_type_t::APPLICATION;
	mailio::mime::content_type_t ctt(mtt, ndext);
	return ctt;
}

(CT_XXXXX are global variables, type: std::setstd::string)
Then I got LNK2001 error.

LNK2001 Unresolved external symbol "public: __cdecl mailio::mime::content_type_t::content_type_t(enum mailio::mime::media_type_t,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &) "  (??0content_type_t@mime@mailio@@QEAA@W4media_type_t@12@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@1@Z)

It seems this line

mailio::mime::content_type_t ctt(mtt, ndext);

is causing the error.
What happened and how to avoid this please?

Additional Information:
I also used other class like mailio::smtps and mailio::message, they didn't cause any LNK2001 or LNK2019 error.The only error is that LNK2001.
I installed mailio library using vcpkg,my IDE is Visual Studio 2022

Do you link the library? If I put the function GetContentType into the example smtp_utf8_qp_msg.cpp (which links mailio), then it compiles fine. Here are the linking parameters from my VS2019 setup:

..\Release\mailio.lib
C:\Install\boost_1_71_0\stage\lib\libboost_system-vc142-mt-x64-1_71.lib
C:\Install\boost_1_71_0\stage\lib\libboost_date_time-vc142-mt-x64-1_71.lib
C:\Install\boost_1_71_0\stage\lib\libboost_regex-vc142-mt-x64-1_71.lib
\Bin\OpenSSL-Win64\lib\VC\ssleay32MD.lib
\Bin\OpenSSL-Win64\lib\VC\libeay32MD.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib