OpenDDS / OpenDDS

OpenDDS is an open source C++ implementation of the Object Management Group (OMG) Data Distribution Service (DDS). OpenDDS also supports Java bindings through JNI.
http://www.opendds.org
Other
1.28k stars 463 forks source link

Problems building with Qt #1377

Closed Dumbledoom closed 2 years ago

Dumbledoom commented 4 years ago

I have been trying unsuccessfully to build with Qt5 for the last couple of days, following these instructions: https://github.com/objectcomputing/OpenDDS/blob/master/docs/qt.md. I am running:

Windows 7 SP1 OpenDDS 3.13.3 MSVS 2017 with SDK 10.0.16299.0

Whatever I do the build on iShapes, Monitor app and ExcelRTD fail, and specifically on iShapes it cannot locate the correct directories e.g. QtCore/QWidget. I have tried with Qt5 through vcpkg, as mentioned above in the instructions, Qt 5.12.6 and Qt 4.8.6 through direct install.

Qt5 through vcpkg The build that comes from running the vcpkg command mentioned in the above link does not have some of the include packages required in the files, and others are in different locations. When building iShapes this is the main issue. With ExcelRTD and Monitor I believe it is a similar problem. I set the --qt to be C:\vcpkg-master\installed\x64-windows, and C:\vcpkg-master\installed\x64-windows\include for --qt-include. I have also tried other plausible roots for these variables but still the same issue. I could still be messing up the environment variables here but there is definitely an in issue with include packages not being present in these directories.

Qt 5.12.6 Essentially I encountered the same problem as above, the build fails because include packages cannot be found.

Qt 4.8.6 This seemed to work better. I inspected the directories and could see that many of the missing include packages were there, however all projects still fail to build. iShapes and Monitor_App fail with this error:

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

This is probably fixable on my machine but so far I have not figured out the exact cause as I am certainly targeting x64.

ExcelRTD fails with 4 C++ syntax errors in the file RTDServerDLL.cpp :

unrecognized token, line 13

illegal escape sequence, line 13

newline in constant, line 13

missing ';' before 'const', line 20

I do not think these are errors in the code, I cannot see any problems with them, however I am at a loss as to why this is happening.

Other than these projects, the rest of OpenDDS builds fine and I have managed to run the tests. Any help on this would be hugely appreciated, I will say that I am new to OpenDDS and building software in this way, though I have had a couple of weeks having a go at it so have learnt a lot in that time.

jwillemsen commented 4 years ago

There are some changes proposed which are not complete for ACE/TAO to better support qt5 through vcpkg, maybe related, see https://github.com/DOCGroup/ACE_TAO/pull/968 and https://github.com/microsoft/vcpkg/pull/8468

mitza-oci commented 4 years ago

OpenDDS 3.13.x only builds with Qt4 OpenDDS master (soon to be 3.14) only builds with Qt5 We have used Qt5 via vcpkg on many VC++ development machines so we can help you get it set up.

Dumbledoom commented 4 years ago

@jwillemsen @mitza-oci thanks for getting back so quickly. This explains a lot, no wonder I was having issues with Qt5 then!

My latest build attempt with Qt4 did go better as I mentioned above, though I am still struggling to understand why I am having the issues I mentioned . I set --qt=C:\Qt\4.8.6\bin (also set in system path) and --qt-include=C:\Qt\4.8.6\include, I believe these are correct? With respect to the LNK1112 error, I don't think the build environment is targeting a x86 system. I have gone through these steps:

https://stackoverflow.com/questions/3563756/fatal-error-lnk1112-module-machine-type-x64-conflicts-with-target-machine-typ

with still no luck. I forgot to say in the op that my machine is 64-bit.

mitza-oci commented 4 years ago

Without actually running it, I think you want --qt=C:\Qt\4.8.6 without setting qt-include. That would mean that QTDIR doesn't end in bin. But it may work the same either way.

If you have a 64-bit build of Qt4 matched with a 64-bit build of OpenDDS, that will resolve LNK1112.

Dumbledoom commented 4 years ago

I have done as you said and set the QTDIR, and excluded include, it seems to work as expected.

The Qt4 build I have installed I think is the issue then, I have tried installing the latest version from here: https://download.qt.io/archive/qt/4.8/4.8.7/ but still having the same issue.

There is not a 64-bit executable it would seem, would you recommend build Qt4 from source instead?

Dumbledoom commented 4 years ago

So I had a look into building Qt4, could not even get it to configure. I saw also that it takes 10 hours to build which I do not think is reasonable considering there are likely pre-built versions.

Another avenue I have just tried is building everything as 32 bit, though now there seems to be more environment variable issues, and LNK1112 showed again but with the system bit types swapped.

EDIT: I have managed to get around the LNK1112 error on the monitor app by building a win32 debug version of OpenDDS, which confirms that it is the Qt4 version being the problem. When I try to start the monitor I now have an error saying MSVCP100D.dll is missing from my machine, I think that is related to building a debug version so I will try a release version next. Strangely the syntax errors I mentioned on ExcelRTD still caused that build to fail. Either way, it would be preferable to build a 64 bit version.

mitza-oci commented 4 years ago

If you are using prebuilt binaries from https://download.qt.io/archive, you'll have to match the compiler version and the platform (Win32 vs. x64) as they specify. The compiler version determines which runtime library (msvcp*.dll) it uses. You can also build Qt from source. None of this really has anything to do with OpenDDS.

Dumbledoom commented 4 years ago

I couldn't get the configuration script for Qt to work so I gave up on that and just built a 32 bit version, as the only installers Qt provides are 32 bit. It seems to work just fine, but I'll be investigating building 64 bit further at a later time.

I know this part hasn't been about OpenDDS, apologies, it stemmed from the op. More on the topic, however, is that the ExcelRTD plugin still failed to build correctly, quoting the errors I mentioned in the op. I can't see why these would be showing unless there is a problem with my include path files, as I cannot see any problems with the code on lines 13 and 20 in RTDServerDLL.cpp.

mitza-oci commented 4 years ago

Please paste the build output from ExcelRTD and attach the vcxproj file for it. Also please confirm that this is still with OpenDDS 3.13.3 with Visual Studio 2017.

Dumbledoom commented 4 years ago

Here is the vcxproj: ExcelRTD.zip

And the build output: ExcelRTD.log

I can confirm I am using those versions.

mitza-oci commented 4 years ago

Something went wrong in the project generation, this project's vcxproj contains RTD_DLL_NAME=\"$(TargetFileName)\" instead of RTD_DLL_NAME="$(TargetFileName)" You can edit it directly in Visual Studio so that it shows RTD_DLL_NAME="$(TargetFileName)" in the UI. Or even RTD_DLL_NAME=OpenDDS_ExcelRTDd.dll (for Debug).

Dumbledoom commented 4 years ago

I believe there may have been an issue with the visual studio command line I was using to run the configure script with; I have solved my Qt issues using the native x64 version of the cmd, beforehand I did not realize there was another cmd I could install. Running the configure script in the non 64 bit version produces the vcxproj file I linked above, however using the other one produces this:

ExcelRTD_x64.zip

I checked before compiling and found RTD_DLL_NAME="$(TargetFileName)", which on compile still resulted in the errors mentioned above. I will try editing it directly to RTD_DLL_NAME="$(TargetFileName)" and RTD_DLL_NAME=OpenDDS_ExcelRTDd.dll and report back.