DllCanUnloadNow linking error?

S

Saurabh Aggrawal

Hi,

I am porting an application for 64-bit AMD processor and while linking
the application i am getting the following errors:

Processing directory uidll...
Linking DLL G:\NewUIPackers1\drivers\Unser\bin\WIN32\DEBUG\PPKAW1UI.dll
....
LINK : warning LNK4224: /PDBTYPE is no longer supported; ignored
UIDLL.def : error LNK2001: unresolved external symbol DllCanUnloadNow
UIDLL.def : error LNK2001: unresolved external symbol DllGetClassObject
UIDLL.def : error LNK2001: unresolved external symbol DllRegisterServer
UIDLL.def : error LNK2001: unresolved external symbol
DllUnregisterServer
UIDLL.def : error LNK2001: unresolved external symbol getDevIC
G:\NewUIPackers1\drivers\Unser\bin\WIN32\DEBUG\PPKAW1UI.lib : fatal
error LNK1120: 5 unresolved externals
LINK : fatal error LNK1141: failure during build of exports file
NMAKE : fatal error U1077: 'link' : return code '0x475'
Stop.
NMAKE : fatal error U1077: 'for' : return code '0x2'
Stop.


I have included the all the paths correctly.
Below is the declarations for the functions the error is in:



//STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
extern "C" HRESULT __stdcall DllGetClassObject(REFCLSID rclsid, REFIID
riid, LPVOID* ppv)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

// see if somebody is trying to get one of our published classes
if (SUCCEEDED(_Module.GetClassObject(rclsid, riid, ppv)))
return S_OK;

// this may be an MFC request
return AfxDllGetClassObject(rclsid, riid, ppv);
}

//STDAPI DllCanUnloadNow(void)
extern "C" HRESULT __stdcall DllCanUnloadNow(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

// see if CComModule's instance can unload
if ( _Module.GetLockCount() == 0 )
return S_FALSE;

// see if MFC's COM can unload
if ( SUCCEEDED(AfxDllCanUnloadNow()) )
return S_FALSE;

return S_OK;
}

// by exporting DllRegisterServer, you can use regsvr.exe
//STDAPI DllRegisterServer(void)
extern "C" HRESULT __stdcall DllRegisterServer(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
return ResultFromScode(SELFREG_E_CLASS);

return _Module.RegisterTypeLib();

}


I have tried the return types for the functions both STDAPI and extern
"C" HRESULT __stdcall but still the error is there. What further
changes i am should do to remove these linking errors.
 
S

Stephen Howe

I have tried the return types for the functions both STDAPI and extern
"C" HRESULT __stdcall but still the error is there. What further
changes i am should do to remove these linking errors.

Linking is off-topic in comp.lang.c++ . Just C++ is discussed here.
I would suggest reposting in a Microsoft VC newsgroups.

SH
 
K

Kurt Krueckeberg

I am porting an application for 64-bit AMD processor and while linking
the application i am getting the following errors:

Processing directory uidll...
Linking DLL G:\NewUIPackers1\drivers\Unser\bin\WIN32\DEBUG\PPKAW1UI.dll
...
LINK : warning LNK4224: /PDBTYPE is no longer supported; ignored
UIDLL.def : error LNK2001: unresolved external symbol DllCanUnloadNow
UIDLL.def : error LNK2001: unresolved external symbol DllGetClassObject
UIDLL.def : error LNK2001: unresolved external symbol DllRegisterServer
UIDLL.def : error LNK2001: unresolved external symbol
DllUnregisterServer
UIDLL.def : error LNK2001: unresolved external symbol getDevIC
G:\NewUIPackers1\drivers\Unser\bin\WIN32\DEBUG\PPKAW1UI.lib : fatal
error LNK1120: 5 unresolved externals
LINK : fatal error LNK1141: failure during build of exports file
NMAKE : fatal error U1077: 'link' : return code '0x475'
Stop.
NMAKE : fatal error U1077: 'for' : return code '0x2'
Stop.


I have included the all the paths correctly.
Below is the declarations for the functions the error is in:



//STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
extern "C" HRESULT __stdcall DllGetClassObject(REFCLSID rclsid, REFIID
riid, LPVOID* ppv)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

// see if somebody is trying to get one of our published classes
if (SUCCEEDED(_Module.GetClassObject(rclsid, riid, ppv)))
return S_OK;

// this may be an MFC request
return AfxDllGetClassObject(rclsid, riid, ppv);
}

//STDAPI DllCanUnloadNow(void)
extern "C" HRESULT __stdcall DllCanUnloadNow(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

// see if CComModule's instance can unload
if ( _Module.GetLockCount() == 0 )
return S_FALSE;

// see if MFC's COM can unload
if ( SUCCEEDED(AfxDllCanUnloadNow()) )
return S_FALSE;

return S_OK;
}

// by exporting DllRegisterServer, you can use regsvr.exe
//STDAPI DllRegisterServer(void)
extern "C" HRESULT __stdcall DllRegisterServer(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
return ResultFromScode(SELFREG_E_CLASS);

return _Module.RegisterTypeLib();

}


I have tried the return types for the functions both STDAPI and extern
"C" HRESULT __stdcall but still the error is there. What further
changes i am should do to remove these linking errors.

You need to change the LINKER settings. The linker cannot find the import
library for these functions. That is what it "unresolved external" means.
 
S

Saurabh Aggrawal

Hi,

If you use uuid.lib in combination with other .lib files that define
GUIDs (for example, oledb.lib and adsiid.lib). For example:
oledb.lib(oledb_i.obj) : error LNK2005: _IID_ITransactionObject
already defined in uuid.lib(go7.obj)
To fix, add /FORCE:MULTIPLE to the linker command line options, and
make sure that uuid.lib is the first library referenced.
Saurabh Aggrawal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top