我在-v2模式下使用https://bitbucket.org/goshawk/gdc/downloads/gcc-4.5.2-tdm-1-gdc-r575-20110723.zip和TDM GCC 4.5.2来构建DLL。在其中一个模块中,我import std.stdint
。所以我认为我应该链接libgphobos2来修复它,但它给了我更多的错误:
c:/mingw32/bin/../lib/gcc/mingw32/4.5.2/../../../libgphobos2.a(thread.o): In function `D4core6thread6Thread6__ctorMFZC4core6thread6Thread':
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
c:/mingw32/bin/../lib/gcc/mingw32/4.5.2/../../../libgphobos2.a(thread.o): In function `thread_entryPoint@4':
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:173: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:173: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:173: undefined reference to `__emutls_v._tlsstart'
c:/mingw32/bin/../lib/gcc/mingw32/4.5.2/../../../libgphobos2.a(thread.o): In function `D4core6thread6Thread6__ctorMFZC4core6thread6Thread':
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
c:/mingw32/bin/../lib/gcc/mingw32/4.5.2/../../../libgphobos2.a(thread.o): In function `thread_attachThis':
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1957: undefined reference to `__emutls_v._tlsstart'
c:/mingw32/bin/../lib/gcc/mingw32/4.5.2/../../../libgphobos2.a(thread.o): In function `D4core6thread6Thread6__ctorMFZC4core6thread6Thread':
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
c:/mingw32/bin/../lib/gcc/mingw32/4.5.2/../../../libgphobos2.a(thread.o): In function `thread_attachByAddrB':
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:2048: undefined reference to `__emutls_v._tlsstart'
c:/mingw32/bin/../lib/gcc/mingw32/4.5.2/../../../libgphobos2.a(thread.o): In function `D4core6thread18thread_getTLSBlockFZAv':
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:2632: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:2632: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:2632: undefined reference to `__emutls_v._tlsstart'
c:/mingw32/bin/../lib/gcc/mingw32/4.5.2/../../../libgphobos2.a(thread.o): In function `D4core6thread6Thread6__ctorMFZC4core6thread6Thread':
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsend'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
C:\crossdev\gdc\v2\build\mingw32\libphobos/../../../gcc-4.5.2/libphobos/core/thread.d:1363: undefined reference to `__emutls_v._tlsstart'
这是一个错误还是我需要将一些额外的标志传递给gdc?
答案 0 :(得分:1)
我还尝试使用-b2模式的bitbucket源中的GDC来编译库,试图将一些D功能与C ++应用程序接口。
我发现缺少与_tlsstart和_tlsend的链接存在同样的问题。 部分解决方案是在库中包含“main”函数:
void main(){}
我正在使用linux上的静态库。我用以下方法检查了生成的静态库:
nm libDexample.a
这表明上面那个简单的main将额外的符号插入到libDexample.d中(它也最终出现在c ++可执行文件中):
_Dmain
_tlsend
_tlsstart
当然,如果在D应用程序中使用库,这些符号会给出与多个定义相关的链接错误。因此,您可以定义一个单独的库,例如libtls.d,其中包含:
extern(C) void make_it_link_please(){}
//inserts the _tlsstart and _tlsend stuff???????
void main()
{
}
在c ++应用程序但不是D应用程序的情况下,与libtl链接。