I am writing a program in C++ using Eclipse. I want to compile it as a library for Linux, somthing like a DLL in Windows. How I can do this? Do you know any tutorials on how libraries are created?
I just want to understand that is the analog of a DLL for Linux and how to create it. I will be thankful for a small example.
In Linux, DLL's equivalents are (kind of anyway) shared objects (.so).
You need to do something like this:
$ g++ -c -fPIC libfile1.cpp
$ g++ -c -fPIC libfile2.cpp
$ g++ -shared -o libyourlib.so libfile1.o libfile2.o
Take a look at some open source C++ library projects for more information. GTKMM is one of them.
Of course, instead of compiling everything manually it's highly recommended to use a make file or an IDE (such as Eclipse with CDT or KDevelop or {pick your favorite here}) that will create one for you behind the scenes.
In UNIX/Linux world DLLs are called shared libraries and typically have .so or .o extension.
See Linux HOWTO on shared libs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With