7

I'm using autotools as build system for a library of mine. Recently library is ported to Windows. Library compiles and links successfully though I encountered a strange error. There is only static libraries after configure and make. Evertything looks OK except a warning from libtool:

libtool: undefined symbols not allowed in i686-pc-mingw32 shared

I have exported all symbols for Windows machines by this code:

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

And in every single definition I have:

class LIBRARY_API myClass {
// ...

Notes:
Operating System: Windows 8 x86_64
Compiler suite: MinGW x86_64, MSYS x86

4

1 回答 1

14

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

LT_INIT([win32-dll])

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

libexample_la_LDFLAGS = -no-undefined

LT_INIT 文档中有关此的更多详细信息。

于 2014-04-05T18:13:20.750 回答