Results 1 to 7 of 7

Thread: merge two project source codes

  1. #1
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default merge two project source codes

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: merge two project source codes

    namespaces should work, maybe you missed some types that are duplicated by class name.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: merge two project source codes

    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...

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: merge two project source codes

    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,
    _

  5. #5
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: merge two project source codes

    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: merge two project source codes

    Quote Originally Posted by davidovv View Post
    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,
    _

  7. The following user says thank you to anda_skoa for this useful post:

    davidovv (18th July 2014)

  8. #7
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: merge two project source codes

    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.

Similar Threads

  1. Replies: 1
    Last Post: 21st April 2014, 23:21
  2. Replies: 0
    Last Post: 26th November 2012, 13:18
  3. Replies: 2
    Last Post: 22nd April 2011, 00:39
  4. Replies: 0
    Last Post: 6th August 2010, 11:01
  5. Qt open source project
    By s.lateralus in forum Newbie
    Replies: 3
    Last Post: 1st September 2009, 21:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.