i have installed musl into /projects/musl/usr.local.musl
with the
/projects/musl > ls usr.local.musl/
bin include lib
/projects/musl > ls usr.local.musl/lib
crt1.o crtn.o libcrypt.a libdl.a libpthread.a librt.a libxnet.a rcrt1.o
crti.o libc.a libc.so libm.a libresolv.a libutil.a musl-gcc.specs Scrt1.o
---
i have musl static and libc static working with linklib and libc dynamic working with function external lib
but none of the function 'external lib' work for musl
but none of musl dynamic work either with function 'external lib' or linklib work
could you look at the code and tell me what i am doing wrong?
program musl; // from https://forum.lazarus.freepascal.org/index.php/topic,64570.0.html
uses ctypes;
var s : ansistring = 'write : ';
// glibc dynamic linked good
//function c_write(const fd: cint; const buffer: pchar; const count: cint): cint; cdecl; external 'libc' name 'write';
// glibc static linked
{$linklib /lib/libc.a} // good
function c_write(const fd: cint; const buffer: pchar; const count: cint): cint; cdecl; external name 'write';
// glibc dynamic linked
//{$linklib /lib/libc.so} // fails
//{$linklib libc} // good
//function c_write(const fd: cint; const buffer: pchar; const count: cint): cint; cdecl; external name 'write';
// musl static linked
{$linklib /projects/musl/usr.local.musl/lib/libc.a} // good
function c_write1(const fd: cint; const buffer: pchar; const count: cint): cint; cdecl; external name 'write';
// musl dynamic linked
//{$linklib /projects/musl/usr.local.musl/lib/libc.so} // fails
//function c_write1(const fd: cint; const buffer: pchar; const count: cint): cint; cdecl; external name 'write';
// /usr/local/bin/ld: cannot find -l/projects/musl/usr.local.musl/lib/libc.a
//function c_write2(const fd: cint; const buffer: pchar; const count: cint): cint; cdecl; external '/projects/musl/usr.local.musl/lib/libc.a' name 'write';
// /usr/local/bin/ld: cannot find -l/projects/musl/usr.local.musl/lib/libc
//function c_write2(const fd: cint; const buffer: pchar; const count: cint): cint; cdecl; external '/projects/musl/usr.local.musl/lib/libc.so' name 'write';
begin
writeln;
// glibc
c_write(1, pchar(s), length(s));
writeln('libc');
// musl
c_write1(1, pchar(s), length(s));
writeln('musl1');
// external musl method static and dynamic both fail
//c_write2(1, pchar(s), length(s));
//writeln('musli2');
writeln;
end.