doubt related to static library

Discussion in 'C Programming' started by sam_cit@yahoo.co.in, Apr 25, 2007.

  1. Guest

    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!!!
    , Apr 25, 2007
    #1
    1. Advertising

  2. <> schrieb im Newsbeitrag
    news:...
    >I have the following files and their code,
    >
    > main.c
    >

    #include <stdio.h>
    > extern void test1();
    >
    > int main()
    > {
    > printf("...in main...\n");
    > test1();
    > return(0);
    > }
    >
    > test.c
    >

    #include <stdi.h>
    > 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
    Joachim Schmitz, Apr 25, 2007
    #2
    1. Advertising

  3. wrote:

    > 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.


    --
    pa at panix dot com
    Pierre Asselin, Apr 25, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. doubt related to string pointers.

    , May 16, 2005, in forum: C Programming
    Replies:
    8
    Views:
    357
    Barry Schwarz
    May 22, 2005
  2. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    623
  3. Replies:
    0
    Views:
    557
  4. Peter Otten
    Replies:
    2
    Views:
    110
    Cousin Stanley
    Aug 10, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    114
    Terry Reedy
    Aug 10, 2013
Loading...

Share This Page