andy@ausvm1.iinus1.ibm.com (Andy Martin) (04/11/91)
I have a number of objects $objs that I want to link into a shared object $obj for addition into an archive. Thses objects depend upon a number of libraries -lc, -lX11, -lbsd, -lnck, etc. When I explictily mention the libriares on the first ld line it works ok: % ld -H512 -T512 -o $shobj $objs -bE:$exp -bM:SRE -lc -lXll -lbsd -lnck % ar rv $shlib $shobj % cc prog.c $shlib % setenv LIBPATH : % a.out % However when I use the -r flag to ignore the unresolved references for a later pass I get the error below. % ld -H512 -T512 -o $shobj $objs -bE:$exp -bM:SRE -r % ar rv $shlib $shobj % cc prog.c $shlib -lXll -lbsd -lnck % setenv LIBPATH : % a.out Could not load program a.out Could not load library $shlib[shobj] Error was: Exec format error % I have tried numerous variations on the same theme and am not having much luck. Some better words of wisdom than the manual provides would be helpful regarding shared libraries and dynamic loading. Andy Martin Cooperating Compound Object Toolkit (CCOT) IBM Personal Systems Programming, 11400 Burnet Road, Austin, TX, 78759. Office: 808/1K-014, Internal Zip: 3008, Phone: (512) 823-1801. INET: amartin@ausvm1.iinus1.ibm.com VNET: AMARTIN at AUSVM1 Austin: andy@ruddles.austin.ibm.com
marc@watson.ibm.com (Marc Auslander) (04/12/91)
In article <6558@awdprime.UUCP> andy@ausvm1.iinus1.ibm.com (Andy Martin) writes: ... >However when I use the -r flag to ignore the unresolved references for a later >pass I get the error below. > % ld -H512 -T512 -o $shobj $objs -bE:$exp -bM:SRE -r > % ar rv $shlib $shobj > % cc prog.c $shlib -lXll -lbsd -lnck > % setenv LIBPATH : > % a.out > Could not load program a.out > Could not load library $shlib[shobj] > Error was: Exec format error > % You cannot make an executable module or library using -r. -r is only for intermediate ld steps, with the output intended as input to another ld step. A shared object must be executable. The execloader is telling you it is not. By the way, -r always make the module non-executable, even if no undefined symbols where found. -- Marc Auslander <marc@ibm.com>