Static Libraries

This is a discussion on Static Libraries within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm new to static libraries and am trying to use a static library in my code. First, I created ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    12

    Static Libraries

    Hi, I'm new to static libraries and am trying to use a static library in my code.

    First, I created a static library, libfunc.a, using this code:
    g++ -c math.cc
    ar rcs libfunc.a math.o

    I have another file, main.cc, that needs to use a function, eval() in the math object.

    I tried to include the libfunc library:
    #include "libfunc.a"
    in the main.cc file, but that generates an error (in every line of the libfunc.a file).

    I know I have to link main.cc with the library using:
    gcc main.o -lfunc -o main

    but I can't call the methods in math from the main file.

    Thanks

  2. #2
    Registered User
    Join Date
    Nov 2003
    Posts
    12
    I found out how to use it:

    extern void eval();

  3. #3
    Disturbed Boy gustavosserra's Avatar
    Join Date
    Apr 2003
    Posts
    244
    I think that you donīt need to use extern. Just the header file (.h).
    Nothing more to tell about me...
    Happy day =)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  3. uploading file to http server via multipart form data
    By Dynamo in forum C++ Programming
    Replies: 1
    Last Post: 09-03-2008, 04:36 AM
  4. LNK2001 ERROR!!! need help
    By lifeafterdeath in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2008, 05:05 PM
  5. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 04:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21