basic ld linker question

From: Charles Vachon <cvachon2_at_mrn.gouv.qc.ca>
Date: Thu, 07 Sep 2000 15:09:40 -0400

Hello Tru64 admins,

Trying to compile a C program on Tru64 4.0F.
Let's say I have a .c program like this:

/*
* A very basic C program: basic.c
*/

#include <stdio.h>
int main( int argc, char *argv[] )
{
int i;

printf( "program %s has %d arguments:\n", argv[0],argc-1 );

for ( i=1; i < argc; i++ )
  printf( "argv %d: %s\n", i, argv[i] );

return(0);
}
/*
* end of basic C program
*/

I can successfully compile and link with "cc -o basic basic.c".

What stumps me is when I create an object file with "cc -c basic.c",
which produces a basic.o file, and then I try to link using "ld
-call_shared -o basic -lc basic.o", I do get a "Unresolved: printf" from
ld. Further, if I chmod u+x the resulting (executable) object file named
basic and I try to execute it, I do get messages like the following

10893:./basic: /sbin/loader: Error: Unresolved symbol in
/usr/shlib/libc.so: __ldr_data
10893:./basic: /sbin/loader: Error: Unresolved symbol in
/usr/shlib/libc.so: __Argc
10893:./basic: /sbin/loader: Error: Unresolved symbol in
/usr/shlib/libc.so: __Argv
10893:./basic: /sbin/loader: Fatal Error: this executable has
unresolvable symbols

Can anyone shed light on this?

I know this is certainly a very basic issue, but I'm not all too
familiar with the numerous options to ld and cc commands.

Thanks in advance.

--
===============================================
Charles Vachon tel: (418) 627-6355 x2760
  email: cvachon2_at_mrn.gouv.qc.ca
  Administrateur de système
  FRCQ/Ministère des Ressources
  Naturelles du Québec
===============================================
Received on Thu Sep 07 2000 - 19:10:55 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:41 NZDT