Compilation problems with GDC/GCC

DRex via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 14 05:01:39 PDT 2017


On Friday, 14 April 2017 at 11:51:54 UTC, Nicholas Wilson wrote:
> On Friday, 14 April 2017 at 11:32:57 UTC, DRex wrote:
>> I have project which involves both C and D code.  For reasons 
>> that are much too long to explain, I have to use GCC to 
>> compile the C code into object files (GDC to compile the D 
>> code into object files) and then ld to link all the object 
>> files together.  Now (unless I am missing something) ld cant 
>> link D object files (a whole bunch of errors about undefined 
>> references to a million different things) which I can only 
>> assume is attributed to ld not knowing about the D libraries 
>> and runtime.  GDC can link D object files just fine, but again 
>> for reasons too long to explain, I cannot use GDC to link the 
>> object files together.
>>
>> I need to take a handful of specific C files and a handful of 
>> Specific D files and link them together (and redirect it into 
>> another .o object file using the -r switch of ld) but again, 
>> ld can't deal with D object files.  I have tried using the 
>> -Xlinker as well as -Wl switches from GDC to pass the -r 
>> switch to the linker, but GDC just spews out "/usr/bin/ld: 
>> cannot find -lgcc_s" and fails.
>>
>> Sorry if I am making no sense, if I am not being clear, let me 
>> know and I will try to re-explain, hoping someone can help me.
>>
>> Cheers.
>
> It is most likely the druntime libraries the linker is 
> complaining about, ld most certainly can deal with D object 
> files. You could try passing them to the linker, but I'm not 
> familiar with the -r option and how that would interact.
>
> One of the verbose flags of gdc will probably allow you to see 
> the linker invocation (or strace or the like) and you could 
> replicate that.

the -r option redirects the linked object files into another 
object file, so the point being I can pass a D object and a C 
object to the linker and produce another object file.

As for linking D files, do you mean passing the druntime 
libraries to ld?  I used gdc -v and it gave me a whole bunch of 
info, it showed the an entry 'LIBRARY_PATH' which contains the 
path to libgphobos and libgdruntime as well as a whole bunch of 
other libs, i'm assuming that is what you are telling me to pass 
to the linker?



More information about the Digitalmars-d-learn mailing list