Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Profile Guided Optimizations - Phase3 : Optimize With Profile Data .. LNK2019 error

judd_pearsonronin-ca
257 Views
When I run phase 3 of Profile Guided Optimizations through the Intel Compiler, I get The following Linker Error .... ( Using Intel Compiler Version 11.1.060 [IA-32] inside visual studio 2005 professional. )

LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl ATL::CSimpleStringT::CopyChars(char *,unsigned int,char const *,int)

I dont get this error when I run step 1 which instruments and runs the code initially to generate the profile data to begin with.

Also if I run PGO through Visual Studio 2005 Professional. I can complete all the steps and generate a pgo optimized executable without any problems.

Anyone have any ideas ?

Judd.
0 Kudos
1 Reply
Quoc-An_L_Intel
Moderator
257 Views
One possible reason... there is acase for Windows, where the inline keyword means that it doesnt need to have a body in the .obj. It might work if the compiler happens to not inline it or leave the body around, but if the user specifies it as inline, he shouldnt expect it to be accessible elsewhere.


>>> I dont get this error when I run step 1

In step 1 (Qprof-gen) optimization is minimal. In this case iclmight not inline the functionand therefore must emit a body for it.

>>> When I run phase 3 of Profile Guided Optimizations through the Intel Compiler

In step 3 (Qprof-use) optimization is enable. Most likely you have an application that was using the non-inlined version of the function to resolve an unresolved reference in another file at link time. I would go back and look at the application and see if this is the case. One quick check is to see if /Qip or /Qipo is enable for the file where the function is defined. If it is, disable /Qip or /Qipo to see if you still get the unresolved error.


Disabling /Qip or /Qipo for that file is a quick workaround, but you will lose the benefits of inlining. The correct solutionis to find the file that is emitting an external unresolved call to this function, then fix the includes for the file so that you include the header file with the definition of this function.


I recently ran into this problem:

It turns out that:

1) test1.cpp has the definition of the function xxxyyy
2) mytest.h has the declaration for this function
3) test2.cpp reference the function xxxyyy.
4) both test1.cpp and test2.cppincludes myheader.h which has the function declaration.

With /Qip enable, function xxxyyy was inlined, and no function body was emitted. To resolve this problem, I move the definition of xxxyyy from test1.cpp to myheader.h.

Hope this helps.

0 Kudos
Reply