Thread: Creating .lib?

  1. #1
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69

    Creating .lib?

    Hi,

    I am trying to include some pre-written code into my project from: http://finance.bi.no/~bernt/gcc_prog.../doc_date.html

    Im having some trouble getting it to work. I am using MSVC++6.

    I don't understand this instruction:

    Compile date.cc, put into library libdate.a, make library available.
    Ive tried adding date.cc and the date.h header file to the project but I just get an error when I try to use any of its functions.

    How do I compile the date.cc to a .lib?

  2. #2
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    I think this thread covers multiple file use pretty well. You don't need to make a lib or dll for this. If you are still having problems why don't you at least tell use what the error messages are.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  3. #3
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    I get this error:

    error C2679: binary '-' : no operator defined which takes a right-hand operand of type 'class date' (or there is no acceptable conversion)
    Im trying to implement it like this:

    Code:
    int day=0;
    date d1(20050310);
    date d2(20050207);
    
    day = d2-d1
    cout<<day;
    Ive included both date.cc and date.h in my project.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Well, if you look at the header you'll find that there is no operator - that takes two dates. In other words, substracting two dates simply isn't supported by the class you have.

    I've also noticed another oddity in there. I didn't know combined assignment operators could be global.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    Thats strange because on the site it says:

    Some aritmetric operations are defined, which has a meaning that may seem strange at first, but they are natural for usage purposes.

    Adding/Subtracting number of days from a data:

    d=d1+7 gives d the date 7 days after date d1.

    d=d1-7 gives d the date 7 days before date d1.

    Finding the number of days between 2 dates. i=d1-d2. Here i is an integer that is the number of days between d1 and d2. i will be negative if d1 d2.

    Example:

    date d1(30,6,1993); date d2(19930610);
    i = d1-d2

    Gives i the value 20, the number of days between 10 jun 93 and 30 jun 93.

    Shame it doesn't work

    Do you know of a way I could find the number of days between 2 dates?

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Sure. Use a proper library.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. How to properly use a .lib file?
    By Kurisu33 in forum C++ Programming
    Replies: 6
    Last Post: 09-28-2006, 08:19 PM
  3. Replies: 4
    Last Post: 07-06-2006, 02:53 AM
  4. what is the use of a .lib file
    By studentc in forum C Programming
    Replies: 2
    Last Post: 02-02-2006, 09:50 AM
  5. Creating Custom Controls
    By Grayson_Peddie in forum C# Programming
    Replies: 1
    Last Post: 12-29-2003, 01:41 PM