Compilation problems with GDC/GCC
DRex via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 15 05:45:47 PDT 2017
On Friday, 14 April 2017 at 18:00:22 UTC, Johannes Pfau wrote:
> Am Fri, 14 Apr 2017 13:03:22 +0000
> schrieb DRex <armstronga94 at hotmail.com>:
>
>
> GDC should generally only need to link to -lgdruntime (and
> -lgphobos if you need it). However, if you really link using ld
> you'll have to provide the C startup files, -lc and similar
> stuff for C as well, which gets quite complicated.
>
> You'll have to post the exact commands you used and some
> of the missing symbol names so we can give better answers.
>
> -- Johannes
okay so here is an outline of the situation:
The project is a rather large C project that is being ported to D
(small pieces at a time) and as I said before, it's make files
are simply way too complicated t unravel and rewrite (the main
make file has 5000 some lines of code).
I have re-written some small elements of C code so far in D. I
need to compile the D code into object (*.o) files, and simply
including them as references in the make files doesn't work
because ld on its own doesn't know how to link D files (as I
assume it doesn't by default know to link the object files with
the D runtime).
On small projects with C and D (test projects for including D
with C) showed that I can simply replace ld with gdc when I go to
link, i.e. instead of `ld cfile.o dfile.o -o foo` I can use `gdc
cfile.o dfile.o -o foo` and it will link the objects together and
make the program. However this is not a viable solution to the
project without navigating through the make files, as there are
some options that are passed to the linker that GDC doesn't seem
to recognize, and this build fails.
After reading the above comment, I have tried linking with `ld
*options* -lgdruntime`, which failed, I also tried specifying the
druntime lib with its full path
'-l:/usr/gcc/x86_64-linux-gnu/5/libgdruntime.a' and derivatives
thereof and ld says it cannot find it. UPDATE: using -L instead
of -l seems to have worked, but I am now recieveing a lot of
'undefined referece' errors, so many that I wont write them here,
but some of them are:
`test.o: In function `main':
test.d:(.text+0x21): undefined reference to `_d_run_main'
`test.o: In function `_D4test9__modinitFZv':
test.d:(.text+0xaa): undefined reference to `_Dmodule_ref'`
`test.o:(.data+0x10): undefined reference to
`_D3std5stdio12__ModuleInfoZ'`
More information about the Digitalmars-d-learn
mailing list