digitalmars.D.learn - Linker error
- Chris (7/7) Jun 10 2016 I get the error below with code like this:
- ketmar (6/13) Jun 10 2016 post the whole code and command line, please.
- Chris (14/31) Jun 10 2016 The whole code would be too much.
- Steven Schveighoffer (14/23) Jun 10 2016 This linker error is saying it can't find a required typeinfo
- Chris (7/36) Jun 10 2016 I've got it now. I remembered that it is to do with passing
I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the module. (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10Input ange6__initZ+0x10): undefined reference to `_D64TypeInfo_C3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ' collect2: error: ld returned 1 exit status
Jun 10 2016
On Friday, 10 June 2016 at 12:04:50 UTC, Chris wrote:I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the module. (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10Input ange6__initZ+0x10): undefined reference to `_D64TypeInfo_C3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ' collect2: error: ld returned 1 exit statuspost the whole code and command line, please. it looks like you doing separate compilation, and forgot to put something to command line, or there is some conflict between installed compiler versions (for example, dmd and ldc, and one somehow is trying to use libphobos from another).
Jun 10 2016
On Friday, 10 June 2016 at 12:12:17 UTC, ketmar wrote:On Friday, 10 June 2016 at 12:04:50 UTC, Chris wrote:The whole code would be too much. This, however compiles and links perfectly well: ` import std.algorithm; import std.conv : to; void main() { auto res = [1, 2, 3].map!(a => a.to!string); } ` I use dub and `dvm use 2.071.0`. The code compiled perfectly well until I used `map!` I have no clue what causes it. I even used `dub clean`I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the module. (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10Input ange6__initZ+0x10): undefined reference to `_D64TypeInfo_C3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ' collect2: error: ld returned 1 exit statuspost the whole code and command line, please. it looks like you doing separate compilation, and forgot to put something to command line, or there is some conflict between installed compiler versions (for example, dmd and ldc, and one somehow is trying to use libphobos from another).
Jun 10 2016
On Friday, 10 June 2016 at 12:52:05 UTC, Chris wrote:I use dub and `dvm use 2.071.0`.hm. sorry, i can't help you with this. straight "dmd test.d" is ok, so it's probably something with dub/dvm interaction...
Jun 10 2016
On Friday, 10 June 2016 at 13:00:23 UTC, ketmar wrote:On Friday, 10 June 2016 at 12:52:05 UTC, Chris wrote:It doesn't compile with `dmd file1.d file2.d` either. I'll have to look into this. Weird.I use dub and `dvm use 2.071.0`.hm. sorry, i can't help you with this. straight "dmd test.d" is ok, so it's probably something with dub/dvm interaction...
Jun 10 2016
On Friday, 10 June 2016 at 13:04:32 UTC, Chris wrote:It doesn't compile with `dmd file1.d file2.d` either. I'll have to look into this. Weird.looks like a clear sign of dmd versions conflict. most of the time things like that caused by some leftover from previous dmd — like old libphobos.a lying somewhere in link path, or alike. try to get link command from "dmd -v", and supply it with explicit path to correct libphobos to check if there is really something interferring.
Jun 10 2016
On 6/10/16 8:04 AM, Chris wrote:I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the module. (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ+0x10): undefined reference to `_D64TypeInfo_C3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ' collect2: error: ld returned 1 exit statusThis linker error is saying it can't find a required typeinfo initializer for std.range.interfaces.InputRange (of some type, not an expert in demangling D symbols). Generally this happens when you compile against a third-party library file but don't link to it (I think that type of symbol is stored in the module info). Your posted code has nothing to do with this, so I'm not sure this is the exact line you are having trouble with. Your posted map line should not be invoking this error at all. Have you tried Vladimir's DustMite tool? It can automatically whittle down your code into a minimal test case. https://github.com/CyberShadow/DustMite/wiki -Steve
Jun 10 2016
On Friday, 10 June 2016 at 13:17:32 UTC, Steven Schveighoffer wrote:On 6/10/16 8:04 AM, Chris wrote:I've got it now. I remembered that it is to do with passing -allinst to the compiler. You're right, it's not `map!` as such. It's the template instantiation. However, the problem only appeared when I started to use `map!`I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the module. (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ+0x10): undefined reference to `_D64TypeInfo_C3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ' collect2: error: ld returned 1 exit statusThis linker error is saying it can't find a required typeinfo initializer for std.range.interfaces.InputRange (of some type, not an expert in demangling D symbols). Generally this happens when you compile against a third-party library file but don't link to it (I think that type of symbol is stored in the module info). Your posted code has nothing to do with this, so I'm not sure this is the exact line you are having trouble with. Your posted map line should not be invoking this error at all. Have you tried Vladimir's DustMite tool? It can automatically whittle down your code into a minimal test case. https://github.com/CyberShadow/DustMite/wiki -Steve
Jun 10 2016