Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Kunal_Rao
Novice
182 Views

Linking problem (underscore prefix)

Hello
I am using Intel compilers on Windows through the cygwin environment. I am trying to link a library with my applicationbut while linking, I am getting unresolved external symbol errors similar to the following:
-----------
io_ncmpi_def_dims.o : error LNK2019: unresolved external symbol ncmpi_def_dim referenced in function io_ncmpi_def_dims_
-----------
There are 28 such unresolved external symbols. When I checked in the io_ncmpi_def_dim.o file for the symbol using : $ dumpbin.exe /SYMBOLS io_ncmpi_def_dim.o
I see this symbol as follows:
-----------
008 00000000 UNDEF notype () External | ncmpi_def_dim
-----------
When I check the same symbol in the library that I am trying to link, I see it as follows:
-----------
01B 00000000 UNDEF notype () External | _ncmpi_def_dim
-----------
So basically, there is an underscore prefix in the symbol in the library where as it is not there in the object file built by intel compilers.
Is there any compiler flags to add such underscore prefix to symbol names while building with intel C compiler ? Or any other alternative way to resolve this linking issue ?
Thanks & Regards,
Kunal
0 Kudos
3 Replies
mecej4
Black Belt
182 Views

Yes, there are flags to control underscores; they are well documented.

The two outputs from DUMPBIN that you showed both show unsatisfied references, one with an underscore and one without.

The question remains as to where the symbol is actually defined, and what decoration is used there. It is going to be a bit harder for you to make them all work together if you have an external reference and a definition in objects or libraries for which you have no source and they have different decorations as noted above. If you have sources for everything, all you have to do is to make sure that they are consistent as to names and compile all the sources with the appropriate underscore convention.
Kunal_Rao
Novice
182 Views

Can you please direct me to the appropriate flag with Intel C++ compiler (for Windows) to pre pend an underscore with the symbols ? I glanced through the document, but could not find it.
Thanks & Regards,
Kunal
JenniferJ
Moderator
182 Views

make sure the lib env-var containing the correct directories. For win32, make sure it contains the wn32 dirs, for x64, it should contain x64 dirs.

you can use "xilink /verbose:lib" to display the directories searched.

Jennifer
Reply