how do I use libraries ?

This is a discussion on how do I use libraries ? within the C++ Programming forums, part of the General Programming Boards category; I want to use a library (crypto++) which I compiled easily enough, but I have no idea how to use ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    3

    how do I use libraries ?

    I want to use a library (crypto++) which I compiled easily enough, but I have no idea how to use it in my code... Or any library for that matter. How does one use a library and get intellisense on the classes function in it?
    using VS2003.

  2. #2
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Check documentions that come with the library.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    3
    I'm more interested in knowing how to use libraries in general then this particular one. How do I include them in my code / set them up in the compiler ?

  4. #4
    Banned
    Join Date
    Jun 2005
    Posts
    594
    with visual studio you just add the library to your
    project.


    project -> add exsisting item -> add your library*


    *
    make sure the file drop down box is on all files,
    or the lib file might now show up, depending on your
    library that should be enough for visual studio.

  5. #5
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    or if its something you are gonna use a lot you can put it in the library directory or add a new directory for libraries

    Go to Tools > Options
    and then go to down to Projects > VC++ Directories
    in the uper corner you can change it to libraries and add a directory.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  6. #6
    Registered User
    Join Date
    Jul 2005
    Posts
    3

    How do i use it in a project?

    so I've set the library in the compiler but to use it in a project I do what ?

    #include "mylib.lib"
    mylib.aFunction();

  7. #7
    Banned
    Join Date
    Jun 2005
    Posts
    594
    no if you add it the way i said,
    you dont have to add any sort
    of include for it, using visual studio anyways.

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    You probably should add an include (at least with my compilers), but you can call the function as if you wrote it:
    Code:
    a_function();
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Essentially the steps are this:
    a. Make sure the library will get linked (I have no VC++ experience, but this is what ILoveVectors gave instructions for)
    b. Include the appropriate header files from the library where you need them in your code (what you need where can be found in the documentation)
    c. Call the functions, use the classes, etc just as normal

    It might help to realize that std::cout and company are not part of the C++ language, but rather, part of a library themselves, the C++ Standard Library ... and you use them just as "black boxes" per se, but the syntax is no different than if you had written them.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GCC: Compiling with both static and shared libraries
    By eatwithaspork in forum C Programming
    Replies: 4
    Last Post: 06-23-2008, 02:48 PM
  2. Replies: 7
    Last Post: 05-13-2008, 04:47 AM
  3. MinGW thread-safe runtime libraries
    By Mario F. in forum C++ Programming
    Replies: 3
    Last Post: 08-21-2006, 09:15 AM
  4. Libraries and headers
    By darksaidin in forum C++ Programming
    Replies: 10
    Last Post: 07-23-2003, 07:24 AM
  5. QT and external libraries
    By Quacker in forum Linux Programming
    Replies: 1
    Last Post: 04-08-2003, 08:02 AM

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