티스토리 뷰

 
다음 에러가 나면...
error LNK2019: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)" (?ConvertBSTRToString@_com_util@@YGPADPA_W@Z) referenced in function "public: char const * __thiscall _bstr_t::Data_t::GetString(void)const " (?GetString@Data_t@_bstr_t@@QBEPBDXZ)
짜증부터 나는데, VC6 이나 VC2003 에서 포팅할 때에 주로 이런 경우가 나는 것 같다. 이 경우는... 일단, 유니코드를 안 쓰게 설정하고 컴파일 해도 된다. 하지만, 유니코드를 쓸 경우에는 comsuppw.lib(디거그일 때에는  comsuppwd.lib) 를 추가하자.
#ifdef _DEBUG
 # pragma comment(lib, "comsuppwd.lib")
#else
 # pragma comment(lib, "comsuppw.lib")
#endif

참고로 위 사이트를 보다 보니 MSDN 양이 설명하기를 프로젝트 셋팅을 유니코드를 쓰겠다고 설정할 경우, _UNICODE 전처리기가 붙는게 아니라 wchat_t 를 기본 자료형으로 다룬단다. 안 쓴다면, wchat_t 는 unsigned short 으로 다룬다.
When calling a function in a static library or DLL that takes a wchar_t type (note that BSTR and LPWSTR resolve to wchar_t*), you may get an LNK2001 unresolved external symbol error.

This error is caused by the /Zc:wchar_t compiler option, which is set to on by default in new MFC projects. This option causes the compiler to treat wchar_t as a native type. Before Visual C++ .NET, wchar_t was treated as an unsigned short.

If the main project and library do not use the same setting for /Zc:wchar_t, this will cause a mismatch of function signatures. To avoid this problem, rebuild the library with the /Zc:wchar_t compiler option, or turn it off in the main project using the Treat wchar_t as Built-in Type setting on the Language property page in the Property Pages dialog box.

그리고 VS9으로 포팅하다보니, rpcndr.lib 요런걸 찾을 때가 있는데 그냥 링크에서 제거하자. 그럼 컴파일 된다.
끝~
댓글