| Ver tema anterior :: Ver siguiente tema | | Autor | Mensaje |
|---|
chelocastillo1
Registrado: 27 Ago 2011 Mensajes: 5
| Publicado: 29/08/2011 1:00 pm | | | Título: [Linker error] undefined reference to '...' |
| Estoy teniendo un problema al compilar con el Dev-C++ 4.9.9.2, lo siguiente son los mensajes de error de enlace:
| Cita: | [Linker error] undefined reference to `IID_IUnknown' [Linker error] undefined reference to `IID_IClassFactory' [Linker error] undefined reference to `IID_IUnknown' [Linker error] undefined reference to `__cxa_pure_virtual' [Linker error] undefined reference to `__cxa_pure_virtual' [Linker error] undefined reference to `__cxa_pure_virtual' [Linker error] undefined reference to `__cxa_pure_virtual' [Linker error] undefined reference to `__cxa_pure_virtual' more undefined references to `__cxa_pure_virtual' follow [Linker error] undefined reference to `vtable for __cxxabiv1::__class_type_info' [Linker error] undefined reference to `vtable for __cxxabiv1::__si_class_type_info' [Linker error] undefined reference to `vtable for __cxxabiv1::__si_class_type_info' [Linker error] undefined reference to `vtable for __cxxabiv1::__si_class_type_info' [Linker error] undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info' [Linker error] undefined reference to `vtable for __cxxabiv1::__si_class_type_info' ld returned 1 exit status |
El unico archivo que utiliza IID_IUnknown e IID_IClassFactory es el main.cpp y en él tengo declarado al principio "#include <unknwn.h>" que es donde están definidos IID_IUnknown e IID_IClassFactory.
¿Qué es lo que me está faltando?
P/D: Ya utilicé el buscador pero no encontré tema con un problema como el que tengo. )-: |
| | Volver arriba | |  | rir3760

Registrado: 01 Oct 2004 Mensajes: 7517 Ubicación: Mexico
| Publicado: 29/08/2011 5:45 pm | | | Título: |
| El error no es generado por el compilador, ello indica que no hay problema con ese encabezado ni sus componentes.
Quien se queja es es linker, eso sugiere un problema con el código objeto, ¿Puedes publicar el código fuente del programa?
Un saludo _________________ C retains the basic philosophy that programmers know what they are doing; it only requires that they state their intentions explicitly. -- Kernighan & Ritchie, The C programming language |
| | Volver arriba | |  | chelocastillo1
Registrado: 27 Ago 2011 Mensajes: 5
| Publicado: 29/08/2011 7:00 pm | | | Título: |
| dllmain.cpp
| Código: | #include "resource.h" #include <initguid.h> #include "cntxtmnu.h" #include "dll.h"
UINT g_cRefThisDll = 0; HINSTANCE g_hmodThisDll = NULL;
//--------------------------------------------------------------------------- // DllMain //---------------------------------------------------------------------------
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { if (dwReason == DLL_PROCESS_ATTACH) g_hmodThisDll = hInstance; else if (dwReason == DLL_PROCESS_DETACH) //_Module.Term();
return TRUE; }
//--------------------------------------------------------------------------- // DllCanUnloadNow //---------------------------------------------------------------------------
STDAPI DllCanUnloadNow(void) { return (g_cRefThisDll == 0 ? S_OK : S_FALSE); }
//--------------------------------------------------------------------------- // DllGetClassObject //---------------------------------------------------------------------------
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppvOut) { *ppvOut = NULL;
if(IsEqualIID(rclsid, CLSID_ShellExtension)) { CShellExtClassFactory *pcf = new CShellExtClassFactory; /*CShellExtClassFactory *pcf; pcf = ((CShellExtClassFactory*)malloc((g_cRefThisDll)*sizeof(CShellExtClassFactory)));*/
return pcf->QueryInterface(riid, ppvOut); }
return CLASS_E_CLASSNOTAVAILABLE; }
//--------------------------------------------------------------------------- // DllRegisterServer //---------------------------------------------------------------------------
STDAPI DllRegisterServer(void) { if((GetVersion() & 0x80000000UL) == 0) { HKEY hKey ; LONG lRet;
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegKeyApproved, 0, KEY_SET_VALUE, &hKey);
if(lRet == ERROR_SUCCESS) { lRet = RegSetValueEx(hKey, szShellExtGUID, 0, REG_SZ, (BYTE *)szShellExtTitle, strlen(szShellExtTitle));
RegCloseKey(hKey);
if(lRet == ERROR_SUCCESS) return S_OK; } } return S_FALSE; }
//--------------------------------------------------------------------------- // DllUnregisterServer //---------------------------------------------------------------------------
STDAPI DllUnregisterServer(void) { if ((GetVersion() & 0x80000000UL) == 0) { HKEY hKey; LONG lRet;
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegKeyApproved, 0, KEY_SET_VALUE, &hKey);
if(lRet == ERROR_SUCCESS) { lRet = RegDeleteValue(hKey, szShellExtTitle); RegCloseKey(hKey); if(lRet == ERROR_SUCCESS) return S_OK; } } return S_FALSE; }
//--------------------------------------------------------------------------- // CShellExtClassFactory //---------------------------------------------------------------------------
CShellExtClassFactory::CShellExtClassFactory() { m_cRef = 0L; g_cRefThisDll++; } CShellExtClassFactory::~CShellExtClassFactory() { g_cRefThisDll--; }
STDMETHODIMP CShellExtClassFactory::QueryInterface(REFIID riid, LPVOID FAR *ppv) { *ppv = NULL; if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) { *ppv = (LPCLASSFACTORY)this; AddRef(); return NOERROR; } return E_NOINTERFACE; }
STDMETHODIMP_(ULONG) CShellExtClassFactory::AddRef() { return ++m_cRef; }
STDMETHODIMP_(ULONG) CShellExtClassFactory::Release() { if (--m_cRef) return m_cRef;
delete this;
return 0L; }
STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) { *ppvObj = NULL;
if(pUnkOuter) return CLASS_E_NOAGGREGATION;
LPCSHELLEXT pShellExt = new CShellExt(); /*LPCSHELLEXT pShellExt; pShellExt = ((CShellExt*)malloc((g_cRefThisDll)*sizeof(CShellExt)));*/
if(pShellExt == NULL) return E_OUTOFMEMORY;
return pShellExt->QueryInterface(riid, ppvObj); }
STDMETHODIMP CShellExtClassFactory::LockServer(BOOL fLock) { return NOERROR; }
//--------------------------------------------------------------------------- // CShellExt //---------------------------------------------------------------------------
CShellExt::CShellExt() { m_cRef = 0L; m_pDataObj = NULL;
g_cRefThisDll++; }
CShellExt::~CShellExt() { if (m_pDataObj) m_pDataObj->Release();
g_cRefThisDll--; }
HRESULT CShellExt::InvokeCommand (LPCMINVOKECOMMANDINFO pCmdInfo) { if(HIWORD(pCmdInfo->lpVerb) != 0) return E_INVALIDARG;
switch( LOWORD( pCmdInfo->lpVerb)) { case 0: { MessageBox(pCmdInfo->hwnd, file, szShellExtTitle, MB_ICONINFORMATION);
return S_OK; break; } default: break; }
return E_INVALIDARG; }
HRESULT CShellExt::GetCommandString(UINT idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax) { pwReserved; // Warning C4100 suppression
if(idCmd != 0) return E_INVALIDARG;
if(uFlags & GCS_HELPTEXT) { if(uFlags & GCS_UNICODE) { LPWSTR szText = "Texto1";
lstrcpynW(reinterpret_cast<LPWSTR>(pszName), szText, cchMax); } else { LPSTR szText = "Texto2"; lstrcpynA (pszName, szText, cchMax); } return S_OK; } return E_INVALIDARG; }
HRESULT CShellExt::QueryContextMenu(HMENU hMenu, UINT uMenuIndex, UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags) { uidFirstCmd; // Suppression Warning C4100 uidLastCmd; // Suppression Warning C4100
if(uFlags & CMF_DEFAULTONLY) return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);
InsertMenu(hMenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, szRWPARAMTEXT);
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 1); }
STDMETHODIMP CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv) { *ppv = NULL;
if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown)) *ppv = (LPSHELLEXTINIT)this; else if (IsEqualIID(riid, IID_IContextMenu)) *ppv = (LPCONTEXTMENU)this;
if (*ppv) { AddRef(); return S_OK; }
return E_NOINTERFACE; }
/*STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hProgID) { if (m_pDataObj) m_pDataObj->Release();
if (pDataObj) { m_pDataObj = pDataObj; pDataObj->AddRef(); }
return S_OK; }*/ |
dll.h
| Código: | #include "resource.h"
#include <shlobj.h> /*#include <comdef.h>*/
/*#include <string>*/
//--------------------------------------------------------------------------- // CShellExtClassFactory //---------------------------------------------------------------------------
class CShellExtClassFactory : public IClassFactory { protected: ULONG m_cRef;
public: CShellExtClassFactory(); ~CShellExtClassFactory();
//IUnknown members STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *); STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release();
//IClassFactory members STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *); STDMETHODIMP LockServer(BOOL);
}; typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
//--------------------------------------------------------------------------- // CShellExt //---------------------------------------------------------------------------
class CShellExt : /*public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CMenuItem, &CLSID_MenuItem>,*/ // public IMenuItem public IShellExtInit, public IContextMenu { public: CShellExt(); ~CShellExt();
protected: char file[MAX_PATH]; ULONG m_cRef; LPDATAOBJECT m_pDataObj;
public: STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO); STDMETHODIMP GetCommandString(UINT, UINT, UINT*, LPSTR, UINT); STDMETHODIMP QueryContextMenu(HMENU, UINT, UINT, UINT, UINT); STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release(); };
typedef CShellExt *LPCSHELLEXT; |
cntxtmnu.h
| Código: | #include "resource.h"
#include <shlobj.h>
//--------------------------------------------------------------------------- // CShellExtClassFactory //---------------------------------------------------------------------------
class CShellExtClassFactory : public IClassFactory { protected: ULONG m_cRef;
public: CShellExtClassFactory(); ~CShellExtClassFactory();
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *); STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release(); STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *); STDMETHODIMP LockServer(BOOL);
}; typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
//--------------------------------------------------------------------------- // CShellExt //---------------------------------------------------------------------------
class CShellExt : public IShellExtInit, public IContextMenu { public: CShellExt(); ~CShellExt();
protected: char file[MAX_PATH]; ULONG m_cRef; LPDATAOBJECT m_pDataObj;
public: STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO); STDMETHODIMP GetCommandString(UINT, UINT, UINT*, LPSTR, UINT); STDMETHODIMP QueryContextMenu(HMENU, UINT, UINT, UINT, UINT); STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release(); };
typedef CShellExt *LPCSHELLEXT; |
Ahora el resultado del linker es otro pues estuve retocando...
| Cita: | [Linker error] undefined reference to `CLSID_ShellExtension' [Linker error] undefined reference to `IID_IUnknown' [Linker error] undefined reference to `IID_IClassFactory' [Linker error] undefined reference to `IID_IUnknown' [Linker error] undefined reference to `_ZN9CShellExt6AddRefEv@4' [Linker error] undefined reference to `_ZN9CShellExt7ReleaseEv@4' [Linker error] undefined reference to `_ZThn4_N9CShellExt6AddRefEv@4' [Linker error] undefined reference to `_ZThn4_N9CShellExt6AddRefEv@4' [Linker error] undefined reference to `_ZThn4_N9CShellExt7ReleaseEv@4' ld returned 1 exit status D:\...\Makefile.win [Build Error] [rwp.dll] Error 1 |
La verdad, no comprendo bien para qué se utiliza cada función pues lo que estoy haciendo es un copy&paste de otro codigo fuente y modificar algo de código para probar algo que posiblemente lo desarrolle bien más adelante si esto me sale.
Desde ya, gracias por tu atención rir3760. |
| | Volver arriba | |  | | untio

Registrado: 17 Sep 2008 Mensajes: 380 Ubicación: MICA S.A.
| Publicado: 30/08/2011 3:40 am | | | Título: |
| Hola,
Sí, yo de nuevo.
Parece que el código define un objeto OLE. No me voy a mirar un montón de documentación sobre OLE, pero intuyo que es una clase para un menú contextual. Esos que aparecen cuando haces click con el botón derecho en un elemento del explorer en Windows. Supongo que muestra un submenú propio. Para ello ha de implementar los métodos del objeto IUnknown y las que le exija la api.
Corregir este código tiene tela marinera, pero si he de dar un consejo, yo no lo haría con el compilador de MingW, porque no tiene todas las librerías y ficheros de cabecera necesarios. Me cambiaría a Visual C++ aunque fuese en su versión express.
Sobre OLE se pueden escribir enciclopedias. Sólo deciros que no me gusta mucho el código, pero no es asunto mío.
Si realmente estás empezando, no te obsesiones con acabarlo porque tiene mucha tela.
Espero que aclare algo. _________________ Hago algo muy raro: primero leo las instrucciones. |
| | Volver arriba | |  | chelocastillo1
Registrado: 27 Ago 2011 Mensajes: 5
| Publicado: 31/08/2011 6:38 am | | | Título: |
| Justamente lo que no queria era hacerlo con el VC++ por un tema de compatibilidad, ya que el código fuente hecho en Dev-C++ o MinGW es más... genérico (por decirlo de alguna forma), en cambio, el código fuente que escriba con VC++ (dependiendo de las librerías que utilice) no puede ser compilado con otros compiladores.
En fín, si no queda otra que utilizar el VC++...
Bueno, muchas gracias por tu respuesta untio. |
| | Volver arriba | |  | untio

Registrado: 17 Sep 2008 Mensajes: 380 Ubicación: MICA S.A.
| Publicado: 31/08/2011 9:54 am | | | Título: |
| Hola de nuevo,
Si deseas hacer un programa que trabaje a fondo con OLE, con Direct show, DirectX y supongo que algunas cosas más, debes hacerlo con Visual C++.
Yo uso la versión 2005 express y además tiene un depurador que es una maravilla.
Tiene narices que un desarrollador de programas GPL como yo acabe usando Visual C++, pero la vida es así.
Yo también empecé en la programación windows con Dev-C++, pero al final me tuve que rendir a la evidencia.
En fin, espero que sea útil. _________________ Hago algo muy raro: primero leo las instrucciones. |
| | Volver arriba | |  | | |
| No puede crear mensajes No puede responder temas No puede editar sus mensajes No puede borrar sus mensajes No puede votar en encuestas
|
|
| |