How can I use one external library in my C++ program?
How to link an external library in my C++ application?
Collapse
X
-
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. -
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.
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
-
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
Comment