link a executable program with static libraries ,but fail

a.c:

#include <stdio.h>

extern void fun();

int main()

{

fun();

return 0;

}

b.c:

#include <stdio.h>

void fun()

{

printf("\n call me");

}

1) create liba.a and libb.a using "ar -ruv" command

2) link the executable program "a.out" with following command:

cc -o a.out -L. -la -lb

report the error:

usage: cc [ options] files. Use 'cc -flags' for details

Can you tell me how to do it

[512 byte] By [ddsoftybcad] at [2007-11-26 10:12:05]
# 1

The error reported by cc means that it expects a file to compile or link. Options that you've specified only tell compiler which libraries a.out is to be linked with, but don't tell compiler what files it should use to produce executable.

To get from cc what you [I guess] expect you need to invoke it like this:

$ cc -o a.out liba.a libb.a

or

$ cc -o a.out liba.a -L. -lb

(not sure which way is right, probably both).

MaximKartashev at 2007-7-7 1:59:45 > top of Java-index,Development Tools,Solaris and Linux Development Tools...