Why do not the rename buttons exist in compilers?

I work on Linux with C ++ using eclipse. But I also worked with Visual Studio. They do not have (or at least I don’t know how to do this) a button for a re-project.

Example:

I have a big project (1), with hundreds of cpp. This project uses a small library (2) to execute foo. If I change the behavior of foo and compile it by creating a library, I need to clear the big proyect (1), recompile, which links external libraries (2), and it works.

The problem is that a large project does not change, but with hundreds of cpps its compilation time is about 5 minutes. 5 minutes is a small change in the second library.

Can this problem be avoided?

Thank you in advance

+4
source share
3 answers

Usually, make with makefile used for this.

Using this method, you can create your own rules for building code, including bypassing the compilation of a large number of source files, if you only need what you need.

For example, makefile :

 prog: main.o other.o makefile gcc -o prog main.o other.o main.o: main.c makefile gcc -c -o main.o main.c other.o: other.c makefile gcc -c -o other.o other.c 

will not recompile main.c unless the file you changed was other.c . He simply compiled other.c to do other.o , and then link other.o and main.o together to create a prog .

This is typically done in the command line world. This is probably also how it is done behind the curtains in many IDEs, and is also hidden from you.

What you need to find out is why dependency checking does not work as expected. Without additional information on how your project is set up, it’s a little difficult to decide.

+3
source

I suspect, but this is just an assumption, your project has no dependency between your foo library and other results in your project.

That way, when you modify foo, the compiler does not know that it needs to recompile (as much as it needs to change in foo) the rest of the project, and this forces you to manually clean and rebuild.

Typically, a dependency is determined using a compiler-specific method, maybe this other mail from SO can help you or simply manage eclipse C ++ dependencies.

+5
source

Add your static library to the Linker-Settings-> Miscellaneous-> Other objects. Your executable will simply be reloaded if the library is newer. No compilation.

0
source

Source: https://habr.com/ru/post/1434783/


All Articles