Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How-to build OpenDDS v3.26.1 with prebuilt Xerces-C++ v3.2.4 using CMake and MSVC on Windows #4375

Closed
FlorianWolters opened this issue Nov 30, 2023 · 8 comments · Fixed by #4572
Assignees

Comments

@FlorianWolters
Copy link

FlorianWolters commented Nov 30, 2023

I am currently trying to build OpenDDS v3.26.1 including ACE_XML_Utils using CMake v3.27.9 in the two build configs Debug and Release.

Here are the steps I executed so far:

  1. Pre-requisite: Configure and build Xerces-C++ v3.2.4:

    cd xerces-c-3.2.4
    cmake -G "Ninja Multi-Config" -S . -B .build -DCMAKE_INSTALL_PREFIX:PATH=.install
    cmake --build .build --target install --config Debug
    cmake --build .build --target install --config Release
    
  2. Configure OpenDDS:

    cd opendds-3.26.1
    cmake -G "Visual Studio 17 2022" -S . -B .build -DCMAKE_INSTALL_PREFIX:PATH=.install -DOPENDDS_XERCES3:BOOL=ON -DXercesC_DIR:PATH=D:\dev\.build\xerces-c-3.2.4-src\.install\cmake -DCMAKE_PREFIX_PATH:PATH=D:\dev\.build\xerces-c-3.2.4-src\.install
    
  3. Build OpenDDS:

    cmake --build .build --target install --config Debug
    cmake --build .build --target install --config Release
    

During the execution of cmake --build .build --target install --config Debug I got the following compile error:

           1>Die Erstellung des Projekts "D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ACE_TAO_for_OpenDDS.sln" ist abgeschlossen (Standardziele) -- FEHLER.

  Fehler beim Buildvorgang.

         "D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ACE_TAO_for_OpenDDS.sln" (Standardziel) (1) ->
         "D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ace\XML_Utils\ACE_XML_Utils.vcxproj.metaproj" (Standardziel) (2) ->
         "D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ace\XML_Utils\ACE_XML_Utils.vcxproj" (Standardziel) (48) ->
         (ClCompile Ziel) ->
D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ace\XML_Utils\XML_Error_Handler.h(21,10): error C1083: Cannot open include file: 'xercesc/sax/ErrorHandler.hpp': No such file or directory [D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ace\XML_Utils\ACE_XML_Utils.vcxproj] [D:\dev\.build\opendds-3.26.1-src\.build\build_ace_tao.vcxproj]
D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ace\XML_Utils\XercesString.h(16,10): error C1083: Cannot open include file: 'xercesc/util/XMLString.hpp': No such file or directory [D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ace\XML_Utils\ACE_XML_Utils.vcxproj] [D:\dev\.build\opendds-3.26.1-src\.build\build_ace_tao.vcxproj]
D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ace\XML_Utils\XercesString.h(16,10): error C1083: Cannot open include file: 'xercesc/util/XMLString.hpp': No such file or directory [D:\dev\.build\opendds-3.26.1-src\.build\ace_tao\ace\XML_Utils\ACE_XML_Utils.vcxproj] [D:\dev\.build\opendds-3.26.1-src\.build\build_ace_tao.vcxproj]

I noticed that during the OpenDDS configure phase ACE+TAO is automatically downloaded and then configured using Perl. I was unable to use the Ninja Multi-Config generator and therefore changed to MSBuild. This observation seems to be related to my issue, I assume the CMake-configured Xerces-C++ paths are not properly propagated to the ACE+TAO build.

Is it possible to work around this issue?

If not, the next I'd try is to also prebuilt ACE+TAO and try to configure the OpenDDS build accordingly.

Any help is highly appreciated.

@jrw972 jrw972 assigned jrw972 and iguessthislldo and unassigned jrw972 Nov 30, 2023
@iguessthislldo
Copy link
Member

I assume the CMake-configured Xerces-C++ paths are not properly propagated to the ACE+TAO build.

Yes, that's correct. This appears to be an oversight on my part as don't think I've tried to built OpenDDS with Xerces on Windows. The ACE/TAO build requires setting the XERCESCROOT in this case. The build worked for me after I set that. You should able to use set XERCESCROOT=D:\dev\.build\xerces-c-3.2.4-src\.install to workaround the issue as well. I'm going to work on a permanent fix for this and open a PR.

I will also look into Ninja Multi-Config. I don't think I've tried using that at all on any platform.

@FlorianWolters
Copy link
Author

FlorianWolters commented Dec 6, 2023

Thanks for the reply. I've been able to successfully build OpenDDS in the Debug build config using a prebuilt Xerces-C++ now (after implementing additional changes). The Release build config still fails, though:

OpenDDS_Util.vcxproj -> D:\dev\.build\opendds-3.26.1-build\Release\lib\Release\OpenDDS_Util.lib
LINK : fatal error LNK1181: cannot open input file '..\..\ace_tao\lib\ACEsd.lib' [D:\dev\.build\opendds-3.26.1-build\Release\dds\idl\opendds_idl.vcxproj]

It seems that OpenDDS assumes CMAKE_DEBUG_POSTFIX:STRING=d for the ACE+TAO dependency if building the Release config. In addition, I can not identify Java files in the install directory of the Debug build config, even though I specified OPENDDS_JAVA.

Questions:

  1. What to change in the script below to make the Release build work?
  2. Is the usage of the OPENDDS_JAVA CMake variable correct in the script below? If not, what do I've to change?

Here is my current Windows batch script:

@echo off
cls

set "opendds_version=3.26.1"
set "xerxesc_version=3.2.4"

set "build_process_count=%NUMBER_OF_PROCESSORS%"
set "script_dir=%~dp0."
set "xerxecs_install_dir=%script_dir%\xerces-c-%xerxesc_version%"
set "java_install_dir=%PROGRAMFILES%\Eclipse Adoptium\jdk-21.0.1.12-hotspot"

set "XERCESCROOT=%xerxecs_install_dir%"

rem Configure+Generate Xerxes-C++.
rem
rem Important: Do not use another generator if using Windows and MSVC, because
rem then the header file `Xerxes_autoconf_config.hpp` may contain an incorrect
rem definition of the preprocessor macro `XERCES_SSIZE_T` using the unavailable
rem data type `ssize_t` (https://issues.apache.org/jira/browse/XERCESC-2194),
rem which would lead to compile errors.
cmake^
 -G "Visual Studio 17 2022"^
 -S "%script_dir%\xerces-c-%xerxesc_version%-src"^
 -B "%script_dir%\xerces-c-%xerxesc_version%-build"^
 -DBUILD_SHARED_LIBS:BOOL=OFF^
 -DCMAKE_DEBUG_POSTFIX:STRING=d^
 -DCMAKE_INSTALL_PREFIX:PATH="%xerxecs_install_dir%"

rem Build+Install Xerxes-C++ for build config "Debug".
cmake^
 --build "%script_dir%\xerces-c-%xerxesc_version%-build"^
 --parallel %build_process_count%^
 --config Debug^
 --target install

rem Build+Install Xerxes-C++ for build config "Release".
rem This overwrites the "Debug" executables with the "Release" executables.
cmake^
 --build "%script_dir%\xerces-c-%xerxesc_version%-build"^
 --parallel %build_process_count%^
 --config Release^
 --target install

rem Configure+Generate OpenDDS for build config "Release".
cmake^
 -G "Visual Studio 17 2022"^
 -S "%script_dir%\opendds-%opendds_version%-src"^
 -B "%script_dir%\opendds-%opendds_version%-build\Release"^
 -DBUILD_SHARED_LIBS:BOOL=OFF^
 -DCMAKE_BUILD_TYPE:STRING=Release^
 -DCMAKE_INSTALL_PREFIX:PATH="%script_dir%\opendds-%opendds_version%\Release"^
 -DCMAKE_UNITY_BUILD:BOOL=TRUE^
 -DOPENDDS_JAVA:PATH="%java_install_dir%"^
 -DOPENDDS_XERCES3:BOOL=ON^
 -DXercesC_DIR:PATH="%xerxecs_install_dir%\cmake"

rem Build+Install OpenDDS for build config "Release".
cmake^
 --build "%script_dir%\opendds-%opendds_version%-build\Release"^
 --parallel %build_process_count%^
 --config Release^
 --target install

rem Configure+Generate OpenDDS for build config "Debug".
cmake^
 -G "Visual Studio 17 2022"^
 -S "%script_dir%\opendds-%opendds_version%-src"^
 -B "%script_dir%\opendds-%opendds_version%-build\Debug"^
 -DBUILD_SHARED_LIBS:BOOL=OFF^
 -DCMAKE_BUILD_TYPE:STRING=Debug^
 -DCMAKE_DEBUG_POSTFIX:STRING=d^
 -DCMAKE_INSTALL_PREFIX:PATH="%script_dir%\opendds-%opendds_version%\Debug"^
 -DCMAKE_UNITY_BUILD:BOOL=TRUE^
 -DOPENDDS_JAVA:PATH="%java_install_dir%"^
 -DOPENDDS_XERCES3:BOOL=ON^
 -DXercesC_DIR:PATH="%xerxecs_install_dir%\cmake"

rem Build+Install OpenDDS for build config "Debug".
cmake^
 --build "%script_dir%\opendds-%opendds_version%-build\Debug"^
 --parallel %build_process_count%^
 --config Debug^
 --target install

Additional notes:

  • Using another generator different to Visual Studio 17 2022, both for Xerces-C++ and OpenDDS does cause a lot of problems, I wasn't able to easily solve (i.e. without changing build files).

    If the Ninja single-config generator is used the ACE+TAO build phase fails pretty fast (no matter if ACE+TAO is downloaded or OPENDDS_ACE_TAO_SRC and OPENDDS_MPC are set).

  • It seems that OpenDDS can only be build with CMake if using a separate build tree directory for each build config (Release, Debug), even if using a multi-config generator. With idiomatic CMake one would expect that a multi-config generator can be used with one build tree and decide which config to build using the build phase (--config argument). This doesn't seem to be possible for OpenDDS, because the variables CMAKE_BUILD_TYPE, OPENDDS_DEBUG and OPENDDS_OPTIMIZE (maybe more) already determine the build output during configure phase.

  • The documentation for the CMake variable OPENDDS_XERCES3 seems to be wrong. It does not seem to be a PATH, but a BOOL. Otherwise xercesc=1 is not displayed during configure. In addition XercesC_DIR has to be specified for find_package command calls to succeed.

  • I suggest improving the section "Building OpenDDS Using CMake" in the OpenDDS documentation by providing more advanced examples and showing the "right approach" (see my script above).

Next step is to solve the two remaining problems. After that I'll try to activate OpenDDS security features in the build. But at least I can start to evaluate OpenDDS using the Debug build config now on my system.

@FlorianWolters
Copy link
Author

FlorianWolters commented Dec 12, 2023

Follow-up on #4375 (comment): Does anyone have an idea why the Release build of OpenDDS with CMake fails and how-to fix this?

Edit: Note that the same error occurs if specifying an external ACE+TAO source directory via OPENDDS_ACE_TAO_SRC and OPENDDS_MPC. I've just tried it with v7.1.2 of ACE+TAO.

In addition here is the error of the OpenDDS CMake configure phase (in which ACE+TAO is build) if replacing the generator in my build script with Ninja:

-- Build files have been written to: D:/dev/.build/opendds-3.26.1-build/Release
[5/188] Performing configure step for 'build_ace_tao'
Already configured
[5/188] Performing build step for 'build_ace_tao'no such file or directory

FAILED: build_ace_tao-prefix/src/build_ace_tao-stamp/build_ace_tao-build D:/dev/.build/ace_tao-7.1.2-src/lib/ACEsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/ACE_XML_Utilssd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_AnyTypeCodesd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_Async_IORTablesd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_BiDirGIOPsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_CSD_Frameworksd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_CSD_ThreadPoolsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_CodecFactorysd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_Codesetsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_DynamicInterfacesd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IORManipsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IORTablesd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_ImR_Clientsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_Messagingsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_PIsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_PortableServersd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_Svc_Utilssd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAOsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BEsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BE_VIS_Asd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BE_VIS_Csd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BE_VIS_Esd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BE_VIS_Isd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BE_VIS_Osd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BE_VIS_Ssd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BE_VIS_Usd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_BE_VIS_Vsd.lib D:/dev/.build/ace_tao-7.1.2-src/bin/tao_idl.exe D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_IDL_FEsd.lib D:/dev/.build/ace_tao-7.1.2-src/lib/TAO_Valuetypesd.lib D:/dev/.build/ace_tao-7.1.2-src/bin/ace_gperf.exe D:/dev/.build/opendds-3.26.1-build/Release/build_ace_tao-prefix/src/build_ace_tao-stamp/build_ace_tao-build
C:\Windows\system32\cmd.exe /C "cd /D D:\dev\.build\ace_tao-7.1.2-src && "C:\Program Files\CMake\bin\cmake.exe" -E env ACE_ROOT=D:/dev/.build/ace_tao-7.1.2-src TAO_ROOT=D:/dev/.build/ace_tao-7.1.2-src/TAO MSBuild ACE_TAO_for_OpenDDS.sln -property:Configuration=Release,Platform= -maxcpucount && "C:\Program Files\CMake\bin\cmake.exe" -E touch D:/dev/.build/opendds-3.26.1-build/Release/build_ace_tao-prefix/src/build_ace_tao-stamp/build_ace_tao-build"
ninja: build stopped: subcommand failed.

@iguessthislldo
Copy link
Member

I'm not sure I can answer all this here, especially the generator and multi-config related issues. It would be better if you opened all the Multi-config-related things as a separate issue. Theoretically building both at the time should work as I tried to be mindful of it while writing CMake code, but it was never a goal of the initial CMake work, so it never got tested.

It seems that OpenDDS assumes CMAKE_DEBUG_POSTFIX:STRING=d for the ACE+TAO dependency if building the Release config.

It doesn't rely on CMAKE_DEBUG_POSTFIX at all, because as far as I know that variable isn't used for find_library like what we're using for finding ACE/TAO. It should be looking for both debug and non-debug variants, so it sounds like something else is going wrong.

I can not identify Java files in the install directory of the Debug build config, even though I specified OPENDDS_JAVA.

Java currently isn't supported when building with CMake. OPENDDS_JAVA should probably note that though.

  • The documentation for the CMake variable OPENDDS_XERCES3 seems to be wrong. It does not seem to be a PATH, but a BOOL. Otherwise xercesc=1 is not displayed during configure. In addition XercesC_DIR has to be specified for find_package command calls to succeed.

I'm not sure what you mean by it being a BOOL. I do see there's still issues with Xerces though past the environment variable workaround, I'm working on putting this work in #4374 and adding security/xerces for Windows to CI.

@FlorianWolters
Copy link
Author

Yes, I assume you're right that I've ran into multiple issue here.

But this is the point where I give up on OpenDDS and won't come back any time soon. Other open-source DDS implementations (one in particular) do have a much lower entry barrier. I've already spent too much time trying to get the OpenDDS CMake software build basically working. I'll go with one of the competitors.

The fact that no contributor of this project was able to provide me with working build instructions (I provided a whole script and additional feedback) signals to me, that something is clearly wrong here.

In addition, the ACE+TAO (aka DOC Group TAO) build itself is a mess and its documentation is pretty bad: It should just provide the necessary CLI commands, not hundreds of words of prosa. The arcane MPC build system it uses also doesn't help. I was barely able to create a batch script that builds ACE+TAO in isolation (dynamic and static linkage in combination with the build configs Release and Debug), but even with that I got problem with the Xerces-C++ dependency. My build tree of ACE+TAO is now 38.8 GB large. I assume I could build less targets here, but again: The documentation is that bad that I don't even know what is necessary to build. The "best" documentation I was able to found was FAQ this section from the OCI TAO.

Regarding

I'm not sure what you mean by it being a BOOL

In my experiments, for OpenDDS one has to set OPENDDS_XERCES3=ON (a BOOL in CMake) and not OPENDDS_XERCES3=/path/to/xercesc (a PATH in CMake) to enable Xerces-C++ in the ACE+TAO build (you can observe this by watching its output, it should output xerces=1). The official OpenDDS documentation states that OPENDDS_XERCES3 should be a path (refer to p. 59). But at this point I'm that confused, that it may be possible that I did something different wrong (refer to my script).

@iguessthislldo Nonetheless, thank you very much for your help.

@mitza-oci
Copy link
Member

mitza-oci commented Dec 14, 2023

Have you tried building OpenDDS using the configure script and MSVC? You can then use the resulting libraries in a CMake project.

Building OpenDDS with CMake is new so we're still working out some of the more advanced configurations. Thanks for your help with this.

@iguessthislldo
Copy link
Member

Alright, this took a while to get back to because I tried to include the Xerces fixes with #4374, but work on that PR stalled. The issue with the release build trying to use debug ACE was fixed in #4535. I'll have to come back to the other issues with multiconfig generators, but most if not all problems should be solved by making ACE/TAO build with CMake instead of this really problematic calling MPC from CMake workaround that's the root of basically all of these problems. I've summarized the work needed for that in #4578.

@iguessthislldo
Copy link
Member

Added #4580 for Ninja

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants