Using FDO in a Windows DLL causes unresolved symbol errors

classic Classic list List threaded Threaded
5 messages Options
nav
Reply | Threaded
Open this post in threaded view
|

Using FDO in a Windows DLL causes unresolved symbol errors

nav
I was trying to get the sample FDO code into a DLL, but ran into some unresolved symbol errors and had no way to resolve it. Could you help? Code below.

The error is:
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class IProviderRegistry * __cdecl FdoFeatureAccessManager::GetProviderRegistry(void)" (__imp_?GetProviderRegistry@FdoFeatureAccessManager@@SAPAVIProviderRegistry@@XZ) referenced in function "public: int __thiscall FDODataConnection::RegisterProvider(void)" (?RegisterProvider@FDODataConnection@@QAEHXZ) F:\Projects\DatabasePlugin\DatabasePlugin.obj DatabasePlugin


The header:
#ifndef _DATABASEPLUGIN_H_
#define _DATABASEPLUGIN_H_
#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

#include "Fdo\ClientServices\ProviderRegistry.h"
#include "Fdo\ClientServices\ConnectionManager.h"
#include "Fdo\Connections\IConnection.h"
#include "Fdo\Connections\IConnectionPropertyDictionary.h"
#include "Fdo\Connections\IConnectionInfo.h"
#include "Fdo\ClientServices\FeatureAccessManager.h"
#include <exception>
#include <iostream>
#include <Windows.h>

// Specify "C" linkage to get rid of C++ name mangling
extern "C"
{
class FDODataConnection
{
        FdoPtr<FdoProviderRegistry> m_pRegistry;
public:
    FDODataConnection() {}
    ~FDODataConnection() {}
        int RegisterProvider();strPassword,std::string strService,std::string strDataStore);
};

FDODataConnection* objConnection;
       
DECLDIR int Connect();
}//extern "C"

#endif // End the inclusion guard

The cpp:
#define DLL_EXPORT// DECLDIR will perform an export for us
#include "DatabasePlugin.hpp"// Include our header, must come after #define DLL_EXPORT

extern "C" // Get rid of name mangling
{

//==============================================================================
//============================ FDO functions below =============================
//==============================================================================
int FDODataConnection::RegisterProvider()
{
        FdoPtr<FdoProviderRegistry> m_pRegistry = (FdoProviderRegistry*)FdoFeatureAccessManager::GetProviderRegistry();

    return 1;
}//RegisterProvider

    DECLDIR int Connect()
    {
        objConnection = new FDODataConnection();
        int nProviders = objConnection->RegisterProvider();
        return 0;
    }//Connect

}//extern

I can't keep the FDO include's within extern "C" because the templates in the headers can't be C based.
nav
Reply | Threaded
Open this post in threaded view
|

Re: Using FDO in a Windows DLL causes unresolved symbol errors

nav
Correction:
The line "int RegisterProvider();strPassword,std::string strService,std::string strDataStore); "
should actually just be "int RegisterProvider();"
Reply | Threaded
Open this post in threaded view
|

Re: Using FDO in a Windows DLL causes unresolved symbol errors

Greg Boone
In reply to this post by nav
What are your linker settings? Do you link to fdo.lib and fdocommon.lib?

If that is not the issue, try and remove all use of DECLDIR and see if that resolves the linker issue.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of nav
Sent: Friday, April 12, 2013 2:45 AM
To: [hidden email]
Subject: [fdo-users] Using FDO in a Windows DLL causes unresolved symbol errors

*I was trying to get the sample FDO code into a DLL, but ran into some unresolved symbol errors and had no way to resolve it. Could you help? Code
below.*

*The error is: *
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport)
public: static class IProviderRegistry * __cdecl FdoFeatureAccessManager::GetProviderRegistry(void)"
(__imp_?GetProviderRegistry@FdoFeatureAccessManager@@SAPAVIProviderRegistry@@XZ)
referenced in function "public: int __thiscall FDODataConnection::RegisterProvider(void)"
(?RegisterProvider@FDODataConnection@@QAEHXZ)
F:\Projects\DatabasePlugin\DatabasePlugin.obj DatabasePlugin


*The header:*
#ifndef _DATABASEPLUGIN_H_
#define _DATABASEPLUGIN_H_
#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

#include "Fdo\ClientServices\ProviderRegistry.h"
#include "Fdo\ClientServices\ConnectionManager.h"
#include "Fdo\Connections\IConnection.h"
#include "Fdo\Connections\IConnectionPropertyDictionary.h"
#include "Fdo\Connections\IConnectionInfo.h"
#include "Fdo\ClientServices\FeatureAccessManager.h"
#include <exception>
#include <iostream>
#include <Windows.h>

// Specify "C" linkage to get rid of C++ name mangling extern "C"
{
class FDODataConnection
{
        FdoPtr<FdoProviderRegistry> m_pRegistry;
public:
    FDODataConnection() {}
    ~FDODataConnection() {}
        int RegisterProvider();strPassword,std::string strService,std::string strDataStore); };

FDODataConnection* objConnection;
       
DECLDIR int Connect();
}//extern "C"

#endif // End the inclusion guard

*The cpp:*
#define DLL_EXPORT// DECLDIR will perform an export for us #include "DatabasePlugin.hpp"// Include our header, must come after #define DLL_EXPORT

extern "C" // Get rid of name mangling
{

//==============================================================================
//============================ FDO functions below ============================= //==============================================================================
int FDODataConnection::RegisterProvider()
{
        FdoPtr<FdoProviderRegistry> m_pRegistry = (FdoProviderRegistry*)FdoFeatureAccessManager::GetProviderRegistry();

    return 1;
}//RegisterProvider

    DECLDIR int Connect()
    {
        objConnection = new FDODataConnection();
        int nProviders = objConnection->RegisterProvider();
        return 0;
    }//Connect

}//extern

*I can't keep the FDO include's within extern "C" because the templates in the headers can't be C based.*




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-FDO-in-a-Windows-DLL-causes-unresolved-symbol-errors-tp5046281.html
Sent from the FDO Users mailing list archive at Nabble.com.
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FDO in a Windows DLL causes unresolved symbol errors

Jackie Ng
In reply to this post by nav
It looks like you're leaking out FDO types in your extern "C" visible block.

Do you *have* to do this? Could you not use pimpl to hide this information away?

- Jackie
nav
Reply | Threaded
Open this post in threaded view
|

Re: Using FDO in a Windows DLL causes unresolved symbol errors

nav
In reply to this post by Greg Boone
Thank you so much! It turned out to be a lib file I didn't include.