Merge two Qt/C++ projects: redefinition errors

1.6k Views Asked by At

I have a problem with merging two projects compiled separately. I created some classes (Qt and C++) to manage two mechanical stages (first project) and one class/interface for a laser scanner (second project). When I import the class/interface in the first project, the compiler gives me a lot of redefinition errors on some Windows api classes (the second project uses classes as winsock2).

Could someone help me to find my error? Not only my "grammatical" errors ;)

Thanks!

1

There are 1 best solutions below

5
On BEST ANSWER

Just clean the project, rebuild and run again. One possibility that this may happen is you probably might have used a previous version of library in any of your project and now after merging two projects you may be using latest version of library in other project. The already existing compiled binaries of project which you have merged will be looking for different version of library, but you may have included another version of it in your 2nd project or vice versa!!After merging both appears to be in same project! So try cleaning the Project, use only latest version of library and rebuild and run.

If you try to include both winsock.h and winsock2.h, this error will happen for sure. Because winsock2.h is a complete rewrite of winsock.h. So you would definitely get redefinition errors.

One possible solution is ..

  Try to include winsock2.h before you include the header file(s) which is 
  including winsock.h.That will do.

Or Try using only 1 version of it