Linking with ole32

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

Any ideas?

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.

Hi ed_k,

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

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

Here is what .d file contains:
araXML.obj : araXML.c
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/windows.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/sdkddkver.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/include/excpt.h
/C/Program\ Files/PGI/win64/12.9/include/crtdefs.h
/C/Program\ Files/PGI/win64/12.9/include/crtdefs10.h
/C/Program\ Files/PGI/win64/12.9/include/sal.h
/C/Program\ Files/PGI/win64/12.9/include/sal10.h
/C/Program\ Files/PGI/win64/12.9/include/vadefs.h
/C/Program\ Files/PGI/win64/12.9/include/vadefs10.h
/C/Program\ Files/PGI/win64/12.9/include/stdarg.h
/C/Program\ Files/PGI/win64/12.9/include/windef.h
/C/Program\ Files/PGI/win64/12.9/include/WinDef10.h
/C/Program\ Files/PGI/win64/12.9/include/winnt.h
/C/Program\ Files/PGI/win64/12.9/include/WinNT10.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/include/ctype.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/specstrings.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/sal_supp.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/specstrings_supp.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/specstrings_strict.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/driverspecs.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/sdv_driverspecs.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/kernelspecs.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/DriverSpecs.h
/C/Program\ Files/PGI/win64/12.9/include/basetsd.h
/C/Program\ Files/PGI/win64/12.9/include/BaseTsd10.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/guiddef.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/include/string.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/pshpack4.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/poppack.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/pshpack2.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/pshpack8.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/ktmtypes.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winbase.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winerror.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/wingdi.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/pshpack1.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winuser.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/tvout.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winnls.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/wincon.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winver.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/SpecStrings.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/verrsrc.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winreg.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/reason.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winnetwk.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/wnnc.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/cderr.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/dde.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/ddeml.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/dlgs.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/lzexpand.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/mmsystem.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/nb30.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpc.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpcdce.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpcdcep.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpcnsi.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpcnterr.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpcasync.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/shellapi.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winperf.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winsock.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/inaddr.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/wincrypt.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/bcrypt.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/ncrypt.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winefs.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winscard.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/wtypes.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpcndr.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpcnsip.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/rpcsal.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/basetsd.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winioctl.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winsmcrd.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winspool.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/prsht.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/ole2.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/objbase.h
/C/Program\ Files/PGI/win64/12.9/include/stdlib.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/include/stdlib.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/include/limits.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/unknwn.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/objidl.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/cguid.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/urlmon.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/oleidl.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/servprov.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/msxml.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/oaidl.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/propidl.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/oleauto.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/commdlg.h
/C/Program\ Files/PGI/win64/12.9/include/stralign.h
/C/Program\ Files/PGI/win64/12.9/include/StrAlign10.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/winsvc.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/mcx.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/imm.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/ime_cmodes.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/OAIdl.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/PlatformSDK/include/msxml6.h
/C/Program\ Files/PGI/Microsoft\ Open\ Tools\ 10/include/stdio.h
/C/Program\ Files/PGI/win64/12.9/include/swprintf.inl

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.

  • Mat