1
votes

I have one C++ project with settings of Unicode as character set and /clr option for common language run time support. I am calling some function of MFC dll (with setting of MultiByte character set) and I am getting some liking error on those functions which are using wchar_t. Same dll is working file for those unicode c++ projects where /clr option is not set (i.e. no common language run time support). I have done the google and tried some thing like:--

  1. Replace Cstring with std:string but both are giving same error.

Example for std: string:--

error LNK2001: unresolved external symbol "public: __thiscall CEventLog::CEventLog(wchar_t const *)" (??0CEventLog@@QAE@PB_W@Z)

for Cstring:--

error LNK2019: unresolved external symbol "public: bool __thiscall CIITAdoField::GetValue(class ATL::CStringT > > &)" (?GetValue@CIITAdoField@@QAE_NAAV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z) referenced in function "public: bool __thiscall Iit::DataFeedSvr::SpeedCache::CacheLoader > >,class Iit::DataFeedSvr::SpeedCache::HolidayScheduleInfo,struct Iit::DataFeedSvr::SpeedCache::HolidayScheduleSpeedCacheParam>

::Reload(class Iit::DataFeedSvr::SpeedCache::DoubleKeyCacheInstance > >,class Iit::DataFeedSvr::SpeedCache::HolidayScheduleInfo,struct Iit::DataFeedSvr::SpeedCache::HolidayScheduleSpeedCacheParam> &,class CIITAdoRecordset &,enum Iit::DataFeedSvr::SpeedCache::ERefreshType,class Iit::DataFeedSvr::SpeedCache::CacheObserver const *)" (?Reload@?$CacheLoader@V?$DoubleKeyCacheInstance@JV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@VHolidayScheduleInfo@SpeedCache@DataFeedSvr@Iit@@UHolidayScheduleSpeedCacheParam@456@@SpeedCache@DataFeedSvr@Iit@@@SpeedCache@DataFeedSvr@Iit@@QAE_NAAV?$DoubleKeyCacheInstance@JV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@VHolidayScheduleInfo@SpeedCache@DataFeedSvr@Iit@@UHolidayScheduleSpeedCacheParam@456@@234@AAVCIITAdoRecordset@@W4ERefreshType@234@PBVCacheObserver@234@@Z)

  1. I have checked the setting like "Treat Wchar_t as Built in type" and it is file.
  2. I have tried to explicitly export function and class using __declspec(dllexport) but no luck.
  3. I can not change my project from unicode to multibyte or can not change the setting of /clr option as it starts giving other error.

Please suggest the solution. Thanks in advance.

1
What all I can see from you error, ErrorLog constuctor defintion can not be find from client. Have you given the reference of your import library in project settings? - MarsRover
Yes..I have explictly added all libraries in project setting. - user1677408

1 Answers

-1
votes

Do a 'dumpbin' on the external DLL to see what's exported. If your CEventLog::CEventLog is not exporting a char based constructor you won't be able to import it, simple as that.

It doesn't look from your example that the /clr switch is causing the problem. Try creating a brand new Unicode project (without the CLR) just to check you really can link to the external DLL.