Re: [Chicken-users] undefined reference to `C_numbers_toplevel'
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 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] undefined reference to `C_numbers_toplevel'
Jim Ursetto scripsit: tl;dr: Don't you use -uses, for -uses uses you. That is my opinion, and it is further my opinion that units must be destroyed; they are a menace to Chicken. --Not Cato the Censor -- John Cowan co...@ccil.org http://www.ccil.org/~cowan Statistics don't help a great deal in making important decisions. Most people have more than the average number of feet, but I'm not about to start a company selling shoes in threes. --Ross Gardler ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] undefined reference to `C_numbers_toplevel'
On Fri, Nov 23, 2012 at 12:27:29PM -0800, Miguel Fernandez wrote: Hey everyone, Hello Miguel! I'm just starting out in Scheme, and trying to compile a small snippet that uses complex numbers. The code is as follows: (use numbers) (begin (display 3+3i) (newline) ) I installed the `numbers` egg with `chicken-install`, load it with `use`, and when I run it (as a script) through the interpreter `csi` it works perfectly. Unfortunately, when I try to compile it with: csc -uses numbers main.scm Hm, I think uses is for old-style units. Normally you'd just compile the program and it should work. Because numbers has special syntax that extends the basic reader you'll need to use csc -X numbers-syntax main.scm See also the docs: http://wiki.call-cc.org/eggref/4/numbers#compiled-code 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? Hope this helps, Peter -- http://sjamaan.ath.cx -- The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music. -- Donald Knuth ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users