PDA

View Full Version : merge two project source codes



davidovv
18th July 2014, 12:52
I have two gui applications, lets call them First and Second. I would like to be able to use Second application as a dynamically created form in First, create it on some menu item triggered.
The proble is both source codes have mainwindow.h and MainWindow class.
I experimented with namespaces, typedefs, tried to create static lib from Second and then too use it in First... but I ended with either code not compiling, or creating of First instead of Second MainWindow.
The MainWindow is under source control, changing existing files is not an option.
How do i achieve this?

anda_skoa
18th July 2014, 14:36
namespaces should work, maybe you missed some types that are duplicated by class name.

Cheers,
_

davidovv
18th July 2014, 15:03
Can you help me with steps to solve this
Again, i cant modify existing files just add new ones.
For example i created Second.pri next to Second.pro where i removed main.cpp but i need mainwindow.h and there is conflict with First- mainwindow.h
Next i tried addiing SecondStatic.pro that has CONFIG static and TEMPLATE lib, compiled to SecondStaticLib.a but i still nead to include header files in First from Second.
...
how should i start merging...

anda_skoa
18th July 2014, 16:50
How did you add namespaces if you did not change the files?

If you can't change the files then you'll have to create new files that are based on the ones you can't change, e.g. patches that are applied to the original files or a tool that takes the originals and generated new ones with disambiguated names.

Or try to to use defines have the preprocessor replace names that would otherwise clash

Cheers,
_

davidovv
18th July 2014, 18:50
How did you add namespaces if you did not change the files?
I created new class inside new SecondStatic.pro that inherits Second MainWindow, and tried to use that class, and there tried with namespaces and typedefs, but no success.
Maybe it looks silly but i had a feeling it could work.

patches that are applied to the original
That is what i am doing now (manually, with diff tool, meld, i compare my file with the one from svn) and i was trying to avoid that. I dont see how some automatic patch could work on next version of file.

use defines have the preprocessor replace names that would otherwise clash
I will see more about that.

anda_skoa
18th July 2014, 21:12
I created new class inside new SecondStatic.pro that inherits Second MainWindow, and tried to use that class, and there tried with namespaces and typedefs, but no success.

You could try with a dynamic library and symbol visibility set to hidden, so that only explicitly exported symbols are seen by the linker.
But the best approach is to avoid the same symbols alltogether of course.

Cheers,
_

davidovv
18th July 2014, 22:13
this is the the first time i actually try to build library, so most of the time i have to google what are you talking about.
Dynamic library with hide_symbols works, thanks.