eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
799 stars 349 forks source link

ddsrt_duration_to_msecs_ceil only for Windows development ? #1117

Open DannyBoyKN opened 2 years ago

DannyBoyKN commented 2 years ago

Hi, just starting with DDS in general and with CycloneDDS in particular because it seems to be the only open DDS implementation as pure C implementation. Correct me if I'm wrong. There might be other (commercial) implementation that I had no time to investigate.

Under linux (Ubuntu 18) cloning and building is quite straight forward and I could test the examples.

Under Windows 7 it was hard to setup the environment (VSCode) to use cmake to build: I did follow your instructions using

$ cd build
$ cmake -G "Visual Studio 15 2017" -DBUILD_EXAMPLES=ON ..
$ cmake --build .

For that VSCode CMakeSettings.json had to be created and configured as

{
  "configurations": [
    {
      "name": "x64-Release",
      "generator": "Visual Studio 15 2017 Win64",
      "configurationType": "RelWithDebInfo",
      "inheritEnvironments": [
        "msvc_x64_x64"
      ],
      "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
      "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
      "cmakeCommandArgs": "-DBISON_EXECUTABLE=C:\\ProgramData\\chocolatey\\bin\\win_bison.exe",
      "buildCommandArgs": "-v:n",
      "ctestCommandArgs": ""
    }
  ]
}

Bison was required at least in version 3.0.4 which was only available via Chocolatey.

With all that cmake --build. is still failing with:

PS cyclonedds\build-win> cmake --build .
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking File Globs
  ddsconf.vcxproj -> cyclonedds\build-win\bin\Debug\ddsconf.exe
  Generating cyclonedds.rnc, cyclonedds.xsd, manual/options.md
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code -1073741511. [cyclonedds\build-win\docs\schema.vcxproj]
PS cyclonedds\build-win> cd ..\build
PS cyclonedds\build> cmake --build .
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking File Globs
  Checking Build System
  Building Custom Rule cyclonedds/src/tools/ddsconf/CMakeLists.txt
  ddsconf.c
  rnc.c
  md.c
  xsd.c
  defconfig.c
  q_config.c
  getopt.c
  bswap.c
  io.c
  log.c
  retcode.c
  strtod.c
  strtol.c
  mh3.c
  avl.c
  expand_vars.c
  fibheap.c
  hopscotch.c
  xmlparser.c
  circlist.c
  Generating Code...
  Compiling...
  atomics.c
  cdtors.c
  heap.c
  rusage.c
  sockets.c
  gethostname.c
  socket.c
  string.c
  strerror.c
  sync.c
  md5.c
  process.c
  netstat.c
  dynlib.c
  filesystem.c
  Generating Code...
  environ.c
  environ.c
  ifaddrs.c
  ifaddrs.c
  random.c
  random.c
  threads.c
  threads.c
  time.c
  time.c
  ddsconf.vcxproj -> cyclonedds\build\bin\Debug\ddsconf.exe
  Generating cyclonedds.rnc, cyclonedds.xsd, manual/options.md
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code -1073741511. [cyclonedds\build\docs\schema.vcxproj]

There was no more output. I did not invest more time here since my primary intend is to use it under linux

Building worked perfectly:

$ cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=install -DBUILD_TESTING=ON  -DBUILD_EXAMPLES=ON ..
-- Linux/MacOS/QNX system found, trying to find iceoryx...
-- iceoryx not found, falling back to loopback communication.
-- Building with OpenSSL support
-- Configuring done
-- Generating done
-- Build files have been written to: cyclonedds/build

$ cmake --build . --target install
...
[100%] Generating cyclonedds.rnc, cyclonedds.xsd, manual/options.md
[100%] Built target schema
Install the project...
-- Install configuration: "Debug"
-- Installing: ./build/install/...
...

Running the examples as well 😄

Now I wanted to go for some own development with FreeRTOS for the ARM Cortex M3 to get familiar with the API.

$ cmake CMAKE_CROSSCOMPILING=true -DCMAKE_TOOLCHAIN_FILE=ARM_CM3.toolchain -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=install -DBUILD_EXAMPLES=ON -DWITH_FREERTOS=on FREERTOS_SOURCE_DIR=~/FreeRTOS-Kernel/ ..
-- Linux/MacOS/QNX system found, trying to find iceoryx...
-- iceoryx not found, falling back to loopback communication.
-- Building with OpenSSL support
-- Feature dynlib disabled
-- Configuring done
-- Generating done
-- Build files have been written to: cyclonedds/build-freertos

Without going into further details I stumbled upon a missing definition for ddsrt_duration_to_msecs_ceil !

freertos/time.c:66:26: error: inline function 'ddsrt_duration_to_msecs_ceil' declared but never defined [-Werror]
   66 | extern inline TickType_t ddsrt_duration_to_msecs_ceil(dds_duration_t reltime);

From cyclonedds/src/ddsrt/src/time/freertos/time.c it is declared as:

DDS_INLINE_EXPORT inline DWORD
ddsrt_duration_to_msecs_ceil(dds_duration_t reltime)

but not defined anywhere. It is used by void dds_sleepfor (dds_duration_t reltime) only. This is also true for windows, but not for posix and others. Since I cannot get the compilation working under windows I cannot tell anything there. 'dds_sleepfor' however is a central function although but not define for posix ?

Could you clarify a bit the differences in the platform tailorings ? What did I miss Many thanks

poetinger commented 1 year ago

@DannyBoyKN Hello, and sorry for not reaching out for so long. Do you still have issues with this? I will close this for now though, since no further comments have been made. If you still have issues or questions, please re-open the issue and we can take a look.