I've got a 'n.c' as main function, and 'o.c' as import function, like below:
$ cat n.c o.c
int f();
int main(){
f();
return 0;
}
#include<stdio.h>
int f(){
printf("hello\n");
return 2;
}
Then scons file like below:
Library('o.c')
Program('n.c',LIBS=['o'])
What I hope here is to compile o.c and generate libo.a(OK), and n.c will use this '.a' to generate final executable. So I specified LIBS=['o'], in hoep that it will specify an archive file to find libo.a library. But:
$ scons -Q
gcc -o n n.o -lo
/usr/bin/ld: cannot find -lo
collect2: error: ld returned 1 exit status
scons: *** [n] Error 1
Actually, scons interpreted my command to be '-lo', which is to find a dynamic shared library. This is not what I wanted, because during linking, archive is used like object files. Does '-l' work with archive files, and why scons interprets LIBS to use dynamic link shared libraries?
Thanks.
You also need to specify the path where to search for libraries, in this case:
Please also check chapter 4 "Building and Linking with Libraries" of our UserGuide, which does not only explain how to create and work with Libraries, it further states that your claim from above "SCons interprets LIBS to use dynamic link shared libraries" is plain wrong. Otherwise the object files would end with
*.os
instead...