Linker errors with double functions

Other misc things
Post Reply
User avatar
jorgegv
Well known member
Posts: 309
Joined: Wed Nov 18, 2020 5:08 pm

Linker errors with double functions

Post by jorgegv »

Hi,

I've a colleague who tried to compile the following files, and they compile fine with sdcc+newlib or sccz80+classic, but fail miserably with sdcc+Classic:

hint-z80.zip

(just download, unzip, and run "make")

It seems that the type conversion support functions are there for newlib+sdcc, or classic+sccz80, but what's the problem with sdcc+classic?

Some of the missing functions when compiling with SDCC and Classic:

Code: Select all

(...)
hint.c:950: error: undefined symbol: ___uchar2fs_callee
  ^---- ___uchar2fs_callee
hint.c:1005: error: undefined symbol: ___fssub_callee
  ^---- ___fssub_callee
hint.c:1016: error: undefined symbol: ___fs2sint_callee
  ^---- ___fs2sint_callee
hint.c:1050: error: undefined symbol: ___slong2fs_callee
  ^---- ___slong2fs_callee
hint.c:1062: error: undefined symbol: ___sint2fs_callee
  ^---- ___sint2fs_callee
hint.c:1121: error: undefined symbol: ___slong2fs_callee
  ^---- ___slong2fs_callee
hint.c:1133: error: undefined symbol: ___uchar2fs_callee
  ^---- ___uchar2fs_callee
hint.c:1238: error: undefined symbol: ___uchar2fs_callee
  ^---- ___uchar2fs_callee
hint.c:1246: error: undefined symbol: ___uchar2fs_callee
  ^---- ___uchar2fs_callee
hint.c:1330: error: undefined symbol: ___fslt_callee
  ^---- ___fslt_callee
hint.c:1395: error: undefined symbol: ___fslt_callee
  ^---- ___fslt_callee
hint.c:1464: error: undefined symbol: ___fslt_callee
(...)
User avatar
dom
Well known member
Posts: 2280
Joined: Sun Jul 15, 2007 10:01 pm

Re: Linker errors with double functions

Post by dom »

The correct maths library needs to be used! -lmath48 instead of -lm - see: https://github.com/z88dk/z88dk/wiki/Cla ... ---lmath48
User avatar
jorgegv
Well known member
Posts: 309
Joined: Wed Nov 18, 2020 5:08 pm

Re: Linker errors with double functions

Post by jorgegv »

Wow, that was fast, Dom, thanks.

Now I seem to have caught a harder one:

Code: Select all

make DOUBLE.COM 
(...)
hkernel.c:99: warning 93: types 'double', 'long double' not supported. Assuming 'float'
hkernel.c:102: warning 93: types 'double', 'long double' not supported. Assuming 'float'
hkernel.c:137: error 9: FATAL Compiler Internal Error in file 'SDCCopt.c' line number '312' : 0 
Contact Author with source code
make: *** [Makefile:90: DOUBLE.COM] Error 1
User avatar
jorgegv
Well known member
Posts: 309
Joined: Wed Nov 18, 2020 5:08 pm

Re: Linker errors with double functions

Post by jorgegv »

This is the compile line, BTW:

Code: Select all

zcc +cpm -SO2 -compiler=sdcc -DIINT -DAMALLOC -lmath48 -create-app hint.c hkernel.c -Dunix -DDOUBLE  -o DOUBLE.COM
Z88DK used is nightly from 17-Dec-24
User avatar
dom
Well known member
Posts: 2280
Joined: Sun Jul 15, 2007 10:01 pm

Re: Linker errors with double functions

Post by dom »

The good news is that it doesn't occur with a recent nightly - we upgraded sdcc in January.
User avatar
jorgegv
Well known member
Posts: 309
Joined: Wed Nov 18, 2020 5:08 pm

Re: Linker errors with double functions

Post by jorgegv »

Got me on that one!
mk1nz
New member
Posts: 1
Joined: Wed Mar 12, 2025 10:36 pm

Re: Linker errors with double functions

Post by mk1nz »

dom wrote: Fri Mar 14, 2025 9:53 pm The good news is that it doesn't occur with a recent nightly - we upgraded sdcc in January.
Hello! Unfortunately compiled binary does not properly work. Resulting calculations are empty. I mean no numbers at all. (I tried with both general math lib and math48)

Using sccz80, there's another bug:

testCast.c::main::0::1:3: error: undefined symbol: l_f48_sllong2f
^---- l_f48_sllong2f

This happens during cast conversion from long long to double:

Code: Select all

int main(void){

double numbOne = 0.0;
long long numbTwo = 5;
numbOne = (double)(numbTwo);

return 0;
}
User avatar
dom
Well known member
Posts: 2280
Joined: Sun Jul 15, 2007 10:01 pm

Re: Linker errors with double functions

Post by dom »

If you're using sdcc then you've run into the need to specify printf formatters, add something like:

Code: Select all

#pragma printf "%d %0.f %s %c"
To clock.h and you'll get some numbers printed. See https://github.com/z88dk/z88dk/wiki/Cla ... converters for details

I'll endeavour to add the support routines needed for long long <-> double conversion - probably only for math48 though.
Post Reply