libtool:i686-pc-mingw32共享中不允许使用未定义的符号

时间:2013-07-05 11:31:49

标签: c++ mingw libtool mingw-w64

我正在使用autotools作为我的库的构建系统。最近,库被移植到Windows。虽然我遇到了一个奇怪的错误,但库成功编译并成功链接。配置和make后只有静态库。除了来自libtool的警告:

之外,Evertything看起来还不错
libtool: undefined symbols not allowed in i686-pc-mingw32 shared

我已通过以下代码导出了Windows机器的所有符号:

#ifdef _WIN32
#    ifdef DLL_EXPORT
#        define LIBRARY_API __declspec(dllexport)
#    else
#        define LIBRARY_API __declspec(dllimport)
#    endif
#endif
#ifndef _WIN32
#    define LIBRARY_API
#endif

在每个定义中我都有:

class LIBRARY_API myClass {
// ...

备注
操作系统:Windows 8 x86_64
编译器套件:MinGW x86_64,MSYS x86

1 个答案:

答案 0 :(得分:12)

configure.ac中,确保您的libtool初始化如下:

LT_INIT([win32-dll])

此外,您需要将-no-undefined标记传递到Makefile.am中的libtool。此标志禁用您收到的警告:

libexample_la_LDFLAGS = -no-undefined

LT_INIT documentation中有关此内容的详细信息。