I'm using https://bitbucket.org/goshawk/gdc/downloads/gcc-4.5.2-tdm-1-gdc-r575-20110723.zip with TDM GCC 4.5.2 in -v2 mode to build a DLL. In one of the modules I do import std.stdint
. So I thought I should link against libgphobos2 to fix this but it gives me even more errors:
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'
Is this a bug or do I need to pass some extra flags to gdc?
I also experimented with GDC from bitbucket sources in -v2 mode for compiling a library, in an attempt to interface some D functionality with a C++ application.
I found the same problem with missing link to _tlsstart and _tlsend. A partial solution is to include a "main" function in the library:
void main(){}
I'm working with a static library on linux. I inspected the resulting static library with:
nm libDexample.a
This shows that the above trivial main inserts extra symbols into libDexample.d, (which also end up in the c++ executable):
_Dmain
_tlsend
_tlsstart
Of course, these symbols give link errors relating to multiple definitions if the library is used in a D application. Therefore, you can define a separate library eg libtls.d containing:
extern(C) void make_it_link_please(){}
//inserts the _tlsstart and _tlsend stuff???????
void main()
{
}
Where one links with libtls in the case of a c++ application but not a D application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With