سؤال

I'm attempting to get a toy program running with AVT's VIMBA SDK. At the moment, it is going well save for one caveat. When I attempt to compile, I get a series of errors (14 of them) that all are marked same thing:

function *insert call here* definition is marked dllimport

The file itself is below- the curious thing is that in in this file, only ~IFeatureObserver(), IFeatureObserver(), and IFeatureObserver( const IFeatureObserver& ) are triggering the error; FeatureChanged() does not error out during a compile.

#ifndef AVT_VMBAPI_IFEATUREOBSERVER_H
#define AVT_VMBAPI_IFEATUREOBSERVER_H

#include <VimbaCPP/Include/VimbaCPPCommon.h>
#include <VimbaCPP/Include/SharedPointerDefines.h>
#include <VimbaCPP/Include/Feature.h>
#include <vector>

namespace AVT {
namespace VmbAPI {

class IFeatureObserver 
{
  public:

    IMEXPORT virtual void FeatureChanged( const FeaturePtr &pFeature ) = 0;

    IMEXPORT virtual ~IFeatureObserver() {}

  protected:
    IMEXPORT IFeatureObserver() {}
    IMEXPORT IFeatureObserver( const IFeatureObserver& ) { /* No copy ctor */ }
};
typedef std::vector<IFeatureObserverPtr> IFeatureObserverPtrVector;

}} // namespace AVT::VmbAPI

#endif

After tracking down source of IMEXPORT, I found it in a .h file.

#if defined (_WIN32)
    #if defined AVT_VMBAPI_CPP_EXPORTS          // DLL exports
        #define IMEXPORT __declspec(dllexport)
    #elif defined AVT_VMBAPI_CPP_LIB            // static LIB
        #define IMEXPORT
    #else                                       // import
        #define IMEXPORT __declspec(dllimport)
    #endif
#elif defined (__GNUC__) && (__GNUC__ >= 4) && defined (__ELF__)
    #define IMEXPORT
#elif defined (__APPLE__)
    #define IMEXPORT
#else
    #error Unknown platform, file needs adaption
#endif

I am currently programming in Qt on a Win7-32 bit machine, and as far as I can tell IMEXPORT is being defined as __declspec(dllimport).

Thoughts? Thanks in advance!

هل كانت مفيدة؟

المحلول

You should define the macro AVT_VMBAPI_CPP_EXPORTS in your makefile or VS project. This way IMEXPORT is defined as dllexport for this library and dll import when other libraries/app use it.

BTW it's cleaner to add this attribute to the class itself, not every function.

class IMEXPORT IFeatureObserver {
public:
    virtual void FeatureChanged( const FeaturePtr &pFeature ) = 0;
};
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top