linking in linux

Regan Heath regan at netmail.co.nz
Fri Sep 28 01:57:28 PDT 2007


BCS wrote:
> 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). 

And the command line used to compile and link.

Regan



More information about the Digitalmars-d mailing list