doubt related to static library


S

sam_cit

I have the following files and their code,

main.c

extern void test1();

int main()
{
printf("...in main...\n");
test1();
return(0);
}

test.c

void test1()
{
printf("...in test1...\n");
}


cc -c test.o
ar -rc libtest.a test.o
cc main.o -L /path -ltest -o sample

It works and i get expected results, however my doubt is that the
static library that i created is libtest.a but i specify only test in
the
cc command and it still works. Can anyone tell how cc finds the
correct static library?

Thanks in advance!!!
 
Ad

Advertisements

J

Joachim Schmitz

I have the following files and their code,

main.c
#include said:
extern void test1();

int main()
{
printf("...in main...\n");
test1();
return(0);
}

test.c
#include said:
void test1()
{
printf("...in test1...\n");
}


cc -c test.o
ar -rc libtest.a test.o
cc main.o -L /path -ltest -o sample

It works and i get expected results, however my doubt is that the
static library that i created is libtest.a but i specify only test in
the
cc command and it still works. Can anyone tell how cc finds the
correct static library?

Thanks in advance!!!
Perfectly valid on the UNIX boxes I usually work on, but would be plaform
and implementation specific and as such off topic in clc. Read the
documantation of your system (e.g. man-page of cc and ld)

Bye, Jojo
 
Ad

Advertisements

P

Pierre Asselin

cc main.o -L /path -ltest -o sample
It works and i get expected results, however my doubt is that the
static library that i created is libtest.a but i specify only test in
the cc command and it still works. Can anyone tell how cc finds the
correct static library?

The answer to your question is in your compiler's documentation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top