B
B
Boniface2014-07-03 09:43:36
linux
Boniface, 2014-07-03 09:43:36

How to create dynamic libraries in C++ under Linux?

Hello!
Please tell me how to implement an analogue of the dll library in C ++ in Linux. That is, I have a program, I connect a library to it, then after some time I change the logic of the functions in the connected library, and without recompiling the main program, everything works with the new functionality.
I tried to do so. Created a class mac.cpp - this is the main program. And I created the mylib library without the main method, compiling it with the -c switch.
Then I built the program: g++ mac.cpp mylib.o . Everything works great, but if mylib.o is rebuilt separately, these changes are not reflected in the compiled application.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2014-07-03
@Boniface

gcc allows you to create static and dynamic libraries. Use the -shared linking option and you will get a .so file at the output - which is the analogue of .dll in linux. Here
are all the linking parameters. Well, an example:
gcc *.o -shared -o file.so [-l<libraries>]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question