[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] undefined reference to `C_numbers_toplevel'
From: |
Jim Ursetto |
Subject: |
Re: [Chicken-users] undefined reference to `C_numbers_toplevel' |
Date: |
Tue, 27 Nov 2012 15:48:22 -0600 |
On Nov 23, 2012, at 3:59 PM, Peter Bex wrote:
> On Fri, Nov 23, 2012 at 12:27:29PM -0800, Miguel Fernandez wrote:
>> I get the following error:
>>
>> main.o: In function `C_toplevel':
>> main.c:(.text+0x1c2): undefined reference to `C_numbers_toplevel'
>> collect2: ld returned 1 exit status
>
> I'm not sure why that happens. I guess it's caused by the "uses" switch
> which assumes you're statically linking?
Essentially. -uses generates a call to C_numbers_toplevel() to initialize the
unit, but that can't be resolved as it's not in a numbers.o or -lnumbers file
passed to the linker. Rather, numbers' toplevel is resolved later via
dlopen(3) + dlsym(3).
Note that the numbers toplevel is referred to as C_toplevel() when using
dynamic loading, but as C_numbers_toplevel() by -uses, since it has to be
unique in the latter case. (The C_numbers_toplevel() code is generated by
-unit.) This name difference means you can't contrive to link the numbers.so
module directly into your program and use it via -uses instead of (use); not to
mention bypassing the module import code.
tl;dr: Don't you use -uses, for -uses uses you.
Jim