I have a Fortran program that needs to parse XML. I wrote a thin C wrapper around the MSXML api that takes care of converting the BSTRs. I call the C routines from the Fortran code. I did not create a lib. The C is compiled to an OBJ and then linked with the Fortran OBJs at link time. It all works well when I use the 32 bit version of the PGI compilers.
When I try the 64 bit PGI compilers I get a link error. I am linking with ole32.lib and oleaut32.lib that are provided with PGI in the Microsoft SDKs.
Here is the link error:
araXML.obj : error LNK2019: unresolved external symbol _imp_SysAllocStringLen referenced in function convertStringToBSTR
araXML.obj : error LNK2019: unresolved external symbol imp_CoInitialize referenced in function xmldomdocinitialize
araXML.obj : error LNK2019: unresolved external symbol CLSID_DOMDocument30 referenced in function xmldomdocinitialize
araXML.obj : error LNK2019: unresolved external symbol IID_IXMLDOMDocument referenced in function xmldomdocinitialize
araXML.obj : error LNK2019: unresolved external symbol _imp_CoCreateInstance referenced in function xmldomdocinitialize
araXML.obj : error LNK2019: unresolved external symbol _imp_CoUninitialize referenced in function xmldomdocrelease
araXML.obj : error LNK2019: unresolved external symbol _imp_VariantInit referenced in function xmldomdocloadfile
araXML.obj : error LNK2019: unresolved external symbol _imp_SysFreeString referenced in function xmldomdocloadfile
araXML.obj : error LNK2019: unresolved external symbol _imp_SysStringLen referenced in function xmldomnodegetnodename
test.exe : fatal error LNK1120: 9 unresolved externals
UPDATE:
If I link with the ole.lib and oleAut32.lib from C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64 instead of the ones that shipped with PGI then I reduce the link errors down to the following:
araXML.obj : error LNK2019: unresolved external symbol CLSID_DOMDocument30 referenced in function xmldomdocinitialize_
araXML.obj : error LNK2019: unresolved external symbol IID_IXMLDOMDocument referenced in function xmldomdocinitialize_
test.exe : fatal error LNK1120: 2 unresolved externals
UPDATE2:
If I link with msxml6.lib from C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64 instead of the one that shipped with PGI (C:\Program Files\PGI\Microsoft Open Tools 10\PlatformSDK\lib\AMD64) then it resolves the last two link errors.
Summary: If I try to use the Microsoft SDK libraries that were installed with PGI then I get some link errors. If I use the ones that were already on my Windows 7 64 bit machine then everything links and runs fine.
Open Tools 10’s Platform SDK and the Microsoft SDK v6.0A are different version of the libraries. Open Tools 10 is from VS2010 and I beleive v6.0A is from VS2008. Though, I’m not possitive this is the cause of your issue. More likely how you compiled your C object caused the symbol names to change (i.e. did you use /MD?). The symbols you list all have the “__imp” prefix meaning these are the “_DLL” symbols.
Mat,
I don’t understand your suggestion. According to the -help documentation, --MD causes the compiler to “Print makefile dependencies to .d file”. How would that cause symbol names to change?
I added the -MD and then looked at the generated .d file. It contains a lot of references to .h files in the PGI/Microsoft Open Tools/10/PlatformSDK/include directory. However, I still have to link with the libraries from C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64 instead of the ones that shipped with PGI.
I am using a .bat file to compile. Here is the line that calls the C compiler:
pgcc -w -pc 64 -c -MD -g %%f
I don’t understand your suggestion. According to the -help documentation, --MD causes the compiler to “Print makefile dependencies to .d file”. How would that cause symbol names to change?
Sorry, I had assumed you we’re using Microsoft’s CL compiler to compile the C source. /MD is a CL option that uses DLLs.