How to link an external library in my C++ application?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rasmidas
    New Member
    • Jun 2007
    • 56

    How to link an external library in my C++ application?

    How can I use one external library in my C++ program?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Depends upon your operating system.

    With Windows you can load an externa library at run-time by a call to LoadLibrary(). You may do the same thing at compile time using a Visual C++ DLL project. In this case, Visual C++ generates a .lib file which you use as the link in your program.. When you make a call to this library, the function in the .lib does a LoadLibrary and then calls the function you want from the external library (the DLL) using GetProcAddress.

    Comment

    • rasmidas
      New Member
      • Jun 2007
      • 56

      #3
      I am using C++ on Solaris. Hence the Makefile utility for compiling. Please let me know how can I link the external library to my program.


      Originally posted by weaknessforcats
      Depends upon your operating system.

      With Windows you can load an externa library at run-time by a call to LoadLibrary(). You may do the same thing at compile time using a Visual C++ DLL project. In this case, Visual C++ generates a .lib file which you use as the link in your program.. When you make a call to this library, the function in the .lib does a LoadLibrary and then calls the function you want from the external library (the DLL) using GetProcAddress.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        There should be man pages for this with examples.

        Makefiles vary in syntax based on the OS so you are better off looking at the docs that come with your C++ compiler.

        Essentially after the compile phase is compleete, there will be lines describing linker input and here is where you specify your libraries.

        I believe makefiles are processed from the end to the beginning so your compile steps will be at the end of the file and the linker steps will appear before them.

        Comment

        Working...