Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging two C++ packages

I've got two C++ packages A and B where A depends on B. I'd like to break this dependency by having A swallow a minimal part of the B code, so that B can be tossed out entirely.

Does anyone have any advice for how I could profile package A to find out exactly with classes/functions,etc I need to bring in from B?

EDIT: I simply removed package B and went though (a lot of) cycles of compile A, copy files from B, updated Makefile.am accordingly. Now I'm pretty sure I've bloated package A with more stuff than was needed. How might I find sections of A` code that are never used in the executable/libraries that come out of it?

like image 731
ajwood Avatar asked Apr 16 '26 07:04

ajwood


1 Answers

I think there are three possible ways of action:

  1. Really import only what is needed: Undo what you did, and do it again, but this time do not copy whole files from B but merely the single functions that the compiler tells you are missing.

  2. On your current situation, let some tool analyze the code for you (see Looking for a free source code analyzer (Function depedency tree) and Looking for a free source code analyzer (Function depedency tree)), or write extensive code using all of A and run a code coverage analysis.

  3. Comment out the functions in the sources you copied over from B (not in the headers). Now your linker will complain about any missing function. Uncomment these, delete the rest, including their declarations in the headers. This is the reverse approach to the first.
like image 50
Arne Mertz Avatar answered Apr 17 '26 21:04

Arne Mertz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!