【发布时间】:2011-12-27 21:47:19
【问题描述】:
我有一个核心项目,我正在构建一个共享库。在其中一个标题中,我定义了一个简单的类,如下所示:
typedef pthread_mutex_t Mutex;
class CORE_API AutoLock
{
public:
AutoLock(Mutex& m);
~AutoLock();
private:
AutoLock();
AutoLock(const AutoLock&);
AutoLock& operator=(const AutoLock&);
Mutex m_Mutex;
};
其中 CORE_API 定义为:
#ifdef CORE_DLL
#define CORE_API __attribute__ ((dllexport))
#else
#define CORE_API __attribute__ ((dllimport))
#endif
在内核的 Android.mk 中,我在 LOCAL_CFLAGS 下定义了 CORE_DLL。但是,在构建时,我收到警告:
warning: 'dllimporot' attribute directive ignored
当 ndk-build 到达我想使用 AutoLock 类的另一个项目时,我收到错误:
error: 'AutoLock::AutoLock()' is private
error: within this context
为什么编译器会忽略 dllexport 属性?我希望一旦解决了这个问题,我的另一个项目应该能够构建并能够毫无问题地使用 AutoLock 类。
【问题讨论】: