I am building release version of OpenMP C++ codes with Visual Studio 2019. The debug version ran pretty well but the release version ended up with some strange linker error: "1>lld-link: : error : undefined symbol: __declspec(dllimport) public: static void __cdecl ATL::CSimpleStringT<wchar_t, 1>::CopyChars(wchar_t *, unsigned __int64, wchar_t const *, int)" I am using Intel one API DPC C++/C++ Compiler with support of OpenMP 5.x. I use some CString, TCHAR inside the codes but I do not think those caused the problem as I did a simple mockup OpenMP program with CString and TCHAR under same project configuration properties setting. The compilation and link were fine. I really don't know what caused this link error. My old program without OpenMP was built perfectly without problem. The mock up program I ran with successful built-up is as follows: Can someone give me a hint on how to resolve this linker error? Thanks.

@Sheng Jiang 蒋晟 had the following observation about a similar issue at https://learn.microsoft.com/en-us/answers/questions/1113788/unresolved-external-symbol "MFC's CString became a template in VC7 so there is nothing to link to. You have some old libs that need to recompiled using the same MFC version you are using." ATL and MFC share the CString class so this might also be applicable here.

Sorry for missing my code snippets. I did the following mockup codes with some simple OpenMP and CString as well as conversion among TCHAR, wstring, and CString. It was built pretty well under release version but my targeted project is not working. It is quite strange.

#include <iostream> #include <vector> #include <omp.h> #include <atlstr.h> #include <fstream> using namespace std; vector<int> test; void func(int i) int tmp = i; #pragma omp for for (int k = 0; k < 10; k++) #pragma omp atomic update test[k] += (tmp + k); int main() int sum = 0; int i = 0; CString fileName; fileName = _T("Shapedis.dxf"); const TCHAR* NameFile = (LPCTSTR)fileName; wstring namestr(NameFile); wofstream FShapeDis(namestr, ios::out); FShapeDis << L"0" << endl; FShapeDis.close(); test.resize(10); for (int n = 0; n < 10; n++) test[n] = 0; #pragma omp parallel shared(sum, test) firstprivate(i) num_threads(2) #pragma omp atomic update sum += 1; func(i); cout << "test[0] is " << test[0] << endl; i += 1; } while (i < 10); cout << "Sum = " << sum << endl; cout << "Test array values are \n"; for (int j = 0; j < 10; j++) cout << test[j] << " "; cout << "Hello World!\n";

Hi @hyperandey ,

Thanks for sharing the code snippets.

I agree with @RLWA32 , have you considered the suggestion shared by @RLWA32 ?

Besides, are you using the latest version of VS 2019? Is it possible for you to try to test this on VS 2022?

Regards,

Tianyu