linking in linux
BCS
ao at pathlink.com
Thu Sep 27 21:19:19 PDT 2007
Reply to llee,
> I'm having problems calling functions that are defined in other .d
> files under linux.
>
> Whenever I make a function call to a function that is defined in
> another .d file, the linker (ld) returns an error (exit code 1) saying
> that the referenced function is undefined.
>
> I have a program that is trying to call a function named
> distorm_decode (...). This function is declared in the file distorm.d.
> The function is defined in a file named distorm.c. This file was
> compiled using the gcc compiler and stored in a .a archive (library)
> using ar. When I try to compile my program ld returns the following
> error:
>
> d_disassembler.d:(.gnu.linkonce.t_Dmain + 0x10c): undefined reference
> to 'distorm_decode'
> collect2: ld returned 1 exit status
> --errorlevel 1
> This is not the first time that I've encountered this problem. Other
> programs have also failed to compile, even when the function is
> defined in another d module.
>
> Any help would be appreciated.
>
A little source code would help (the d file for starters). My only guess
from what you have sad would be that the declaration is wrong. Two things
come to mind:
Are you sure that the function is being compiled as a C function and not
a C++ function?
Did you use extern(C) in the d file?
from the like message it looks like #2 is out, but it can't hurt to check
and I may be reading the message wrong. As for #1, I'm not even sure how
to check that one.
More information about the Digitalmars-d
mailing list