Robotics StackExchange | Archived questions

ROS2 for Win32: rcl fails to compile: unresolved external symbol __InterlockedExchange64

Hi,

I'm still trying to compile ROS2 for Windows x86. I changed colcon so it will call cmake for "Visual Studio 15 2017" without "Win64" (see: https://answers.ros.org/question/324217/ros2-for-win32-x86-how-to-make-colcon-call-cmake-without-win64/)

I am using Windows 10 (tried 32bit and 64bit) and Visual Studio 2017 Community 15.0. I try to build using the "x86 Native Tools Command Prompt for VS 2017" (same error with x64). I get stuck while compiling rcl:

Error   LNK2019 unresolved external symbol __InterlockedExchangeAdd64 referenced in function _rcl_timer_init    rcl C:\dev\ros2\build\rcl\timer.obj 1   
Error   LNK2001 unresolved external symbol __InterlockedExchangeAdd64   rcl C:\dev\ros2\build\rcl\client.obj    1   
Error   LNK2001 unresolved external symbol __InterlockedExchangeAdd64   rcl C:\dev\ros2\build\rcl\context.obj   1   
Error   LNK2001 unresolved external symbol __InterlockedExchangeAdd64   rcl C:\dev\ros2\build\rcl\init.obj  1   
Error   LNK2001 unresolved external symbol __InterlockedExchangeAdd64   rcl C:\dev\ros2\build\rcl\time.obj  1   
Error   LNK2019 unresolved external symbol __InterlockedExchange64 referenced in function _rcl_send_request rcl C:\dev\ros2\build\rcl\client.obj    1   
Error   LNK2001 unresolved external symbol __InterlockedExchange64  rcl C:\dev\ros2\build\rcl\timer.obj 1   

The linked libs are:

C:\dev\ros2\install\Lib\builtin_interfaces__rosidl_typesupport_c.lib
C:\dev\ros2\install\Lib\builtin_interfaces__rosidl_typesupport_cpp.lib
C:\dev\ros2\install\Lib\builtin_interfaces__rosidl_typesupport_fastrtps_c.lib
C:\dev\ros2\install\Lib\builtin_interfaces__rosidl_generator_c.lib
C:\dev\ros2\install\Lib\builtin_interfaces__rosidl_typesupport_fastrtps_cpp.lib
C:\dev\ros2\install\Lib\builtin_interfaces__rosidl_typesupport_introspection_c.lib
C:\dev\ros2\install\Lib\builtin_interfaces__rosidl_typesupport_introspection_cpp.lib
C:\dev\ros2\install\Lib\rosidl_typesupport_c.lib
C:\dev\ros2\install\Lib\rosidl_typesupport_cpp.lib
C:\dev\ros2\install\Lib\rosidl_typesupport_introspection_c.lib
C:\dev\ros2\install\Lib\rosidl_typesupport_introspection_cpp.lib
C:\dev\ros2\install\Lib\rcl_interfaces__rosidl_typesupport_c.lib
C:\dev\ros2\install\Lib\rcl_interfaces__rosidl_typesupport_cpp.lib
C:\dev\ros2\install\Lib\rcl_interfaces__rosidl_typesupport_fastrtps_c.lib
C:\dev\ros2\install\Lib\rcl_interfaces__rosidl_generator_c.lib
C:\dev\ros2\install\Lib\rcl_interfaces__rosidl_typesupport_fastrtps_cpp.lib
C:\dev\ros2\install\Lib\rcl_interfaces__rosidl_typesupport_introspection_c.lib
C:\dev\ros2\install\Lib\rcl_interfaces__rosidl_typesupport_introspection_cpp.lib
C:\dev\ros2\install\Lib\rmw_implementation.lib
C:\dev\ros2\install\Lib\rmw.lib
C:\dev\ros2\install\Lib\rcutils.lib
C:\dev\ros2\install\Lib\rosidl_generator_c.lib
C:\dev\ros2\install\Lib\rcl_logging_noop.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib

Any ideas how to fix this?

Thank you in advance marossa


Edit:

Other things, that are different to the "normal" 64bit build: OpenSSL 32bit (1.0.2s), Python 3.7 32bit, self compiled for x86: tinyxml2, tinyxml (built with /MD instead of /MT).

I updated my source files (they were about a week old) and as @sloretz pointed out, there is a testatomics file in in rcutils now. As expected, it fails with the same error. I will append the full stdoutstderr.log to give you the maximum information possible:

-- The C compiler identification is MSVC 19.10.25027.0
-- The CXX compiler identification is MSVC 19.10.25027.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ament_cmake_python: 0.7.3 (C:/dev/ros2/install/share/ament_cmake_python/cmake)
-- Found ament_cmake_ros: 0.7.0 (C:/dev/ros2/install/share/ament_cmake_ros/cmake)
-- Found PythonInterp: C:/Python37/python.exe (found suitable version "3.7.3", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: C:/Python37/python.exe
-- Found ament_cmake_gmock: 0.7.3 (C:/dev/ros2/install/share/ament_cmake_gmock/cmake)
-- Found ament_cmake_gtest: 0.7.3 (C:/dev/ros2/install/share/ament_cmake_gtest/cmake)
-- Found ament_cmake_pytest: 0.7.3 (C:/dev/ros2/install/share/ament_cmake_pytest/cmake)
-- Found ament_lint_auto: 0.7.3 (C:/dev/ros2/install/share/ament_lint_auto/cmake)
-- Found python_cmake_module: 0.7.6 (C:/dev/ros2/install/share/python_cmake_module/cmake)
-- Found PythonInterp: C:/Python37/python.exe (found suitable version "3.7.3", minimum required is "3.5") 
-- Found PythonLibs: optimized;C:/Python37/libs/python37.lib;debug;C:/Python37/libs/python37_d.lib (found suitable version "3.7.3", minimum required is "3.5") 
-- Using PYTHON_EXECUTABLE: C:/Python37/python.exe
-- Using PYTHON_INCLUDE_DIRS: C:/Python37/include
-- Using PYTHON_LIBRARIES: optimized;C:/Python37/libs/python37.lib;debug;C:/Python37/libs/python37_d.lib
-- Found PythonExtra: .pyd  
-- Found gtest sources under 'C:/dev/ros2/install/src/gtest_vendor': C++ tests using 'Google Test' will be built
-- Found gmock sources under 'C:/dev/ros2/install/src/gmock_vendor': C++ tests using 'Google Mock' will be built
-- Added test 'copyright' to check for copyright in CMake / C / C++ / Python code
-- Added test 'cppcheck' to perform static code analysis on C / C++ code
-- Configured cppcheck include dirs: C:/dev/ros2/src/ros2/rcutils/include
-- Added test 'cpplint' to check C / C++ code against the Google style
-- Added test 'flake8' to check Python code syntax and style conventions
-- Added test 'lint_cmake' to check CMake code style
-- Added test 'pep257' to check Python code against some of the style conventions in PEP 257
-- Added test 'uncrustify' to check C / C++ code style
-- Added test 'xmllint' to check XML markup files
-- Configuring done
-- Generating done
-- Build files have been written to: C:/dev/ros2/build/rcutils
Microsoft (R)-Buildmodul, Version 15.1.550.39093
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

  Checking Build System
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/gtest/CMakeFiles/generate.stamp is up-to-date.
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/gmock/CMakeFiles/generate.stamp is up-to-date.
  Expanding logging_macros.h.em
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  allocator.c
  array_list.c
  char_array.c
  cmdline_parser.c
  error_handling.c
  filesystem.c
  find.c
  format_string.c
C:\dev\ros2\src\ros2\rcutils\src\error_handling.c(104): warning C4244: "Funktion": Konvertierung von "int64_t" in "::size_t", m”glicher Datenverlust [C:\dev\ros2\build\rcutils\rcutils.vcxproj]
C:\dev\ros2\src\ros2\rcutils\src\error_handling.c(122): warning C4244: "Funktion": Konvertierung von "int64_t" in "::size_t", m”glicher Datenverlust [C:\dev\ros2\build\rcutils\rcutils.vcxproj]
C:\dev\ros2\src\ros2\rcutils\src\error_handling.c(143): warning C4244: "Funktion": Konvertierung von "int64_t" in "::size_t", m”glicher Datenverlust [C:\dev\ros2\build\rcutils\rcutils.vcxproj]
  get_env.c
  hash_map.c
  logging.c
  process.c
  repl_str.c
  snprintf.c
  split.c
  strdup.c
  string_array.c
  string_map.c
  time.c
  time_win32.c
  uint8_array.c
     Bibliothek "C:/dev/ros2/build/rcutils/Release/rcutils.lib" und Objekt "C:/dev/ros2/build/rcutils/Release/rcutils.exp" werden erstellt.
  rcutils.vcxproj -> C:\dev\ros2\build\rcutils\Release\rcutils.dll
  Building Custom Rule C:/dev/ros2/install/src/gtest_vendor/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/gtest/CMakeFiles/generate.stamp is up-to-date.
  gtest-all.cc
  gtest.vcxproj -> C:\dev\ros2\build\rcutils\gtest\Release\gtest.lib
  Building Custom Rule C:/dev/ros2/install/src/gtest_vendor/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/gtest/CMakeFiles/generate.stamp is up-to-date.
  gtest_main.cc
  gtest_main.vcxproj -> C:\dev\ros2\build\rcutils\gtest\Release\gtest_main.lib
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_allocator.cpp
  test_allocator.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_allocator.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_array_list.cpp
  test_array_list.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_array_list.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_atomics.c
C:\dev\ros2\src\ros2\rcutils\include\rcutils/stdatomic_helper.h(91): warning C4013: "_InterlockedExchangeAdd64" undefiniert; Annahme: extern mit Rckgabetyp int [C:\dev\ros2\build\rcutils\test_atomics_executable.vcxproj]
C:\dev\ros2\src\ros2\rcutils\include\rcutils/stdatomic_helper.h(140): warning C4013: "_InterlockedExchange64" undefiniert; Annahme: extern mit Rckgabetyp int [C:\dev\ros2\build\rcutils\test_atomics_executable.vcxproj]
test_atomics.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__InterlockedExchangeAdd64" in Funktion "_main". [C:\dev\ros2\build\rcutils\test_atomics_executable.vcxproj]
test_atomics.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__InterlockedExchange64" in Funktion "_main". [C:\dev\ros2\build\rcutils\test_atomics_executable.vcxproj]
C:\dev\ros2\build\rcutils\Release\test_atomics_executable.exe : fatal error LNK1120: 2 nicht aufgelöste Externe [C:\dev\ros2\build\rcutils\test_atomics_executable.vcxproj]
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_char_array.cpp
  test_char_array.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_char_array.exe
  Building Custom Rule C:/dev/ros2/install/src/gmock_vendor/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/gmock/CMakeFiles/generate.stamp is up-to-date.
  gtest-all.cc
  gmock-all.cc
  gmock.vcxproj -> C:\dev\ros2\build\rcutils\gmock\Release\gmock.lib
  Building Custom Rule C:/dev/ros2/install/src/gmock_vendor/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/gmock/CMakeFiles/generate.stamp is up-to-date.
  gmock_main.cc
  gmock_main.vcxproj -> C:\dev\ros2\build\rcutils\gmock\Release\gmock_main.lib
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_error_handling.cpp
  test_error_handling.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_error_handling.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_error_handling_helpers.cpp
  test_error_handling_helpers.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_error_handling_helpers.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_filesystem.cpp
  test_filesystem.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_filesystem.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_find.cpp
  test_find.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_find.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_format_string.cpp
  test_format_string.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_format_string.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_get_env.cpp
  test_get_env.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_get_env.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_hash_map.cpp
  test_hash_map.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_hash_map.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_isalnum_no_locale.cpp
  test_isalnum_no_locale.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_isalnum_no_locale.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_logging.cpp
  test_logging.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_logging.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_logging_long_messages.cpp
  test_logging_long_messages.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_logging_long_messages.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_logging_macros.cpp
  test_logging_macros.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_logging_macros.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_logging_macros.c
  test_logging_macros_c.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_logging_macros_c.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_repl_str.cpp
  test_repl_str.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_repl_str.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_snprintf.cpp
  test_snprintf.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_snprintf.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_split.cpp
  test_split.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_split.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_strdup.cpp
  test_strdup.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_strdup.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_string_array.cpp
  test_string_array.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_string_array.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_string_map.cpp
  test_string_map.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_string_map.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_time.cpp
  test_time.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_time.exe
  Building Custom Rule C:/dev/ros2/src/ros2/rcutils/CMakeLists.txt
  CMake does not need to re-run because C:/dev/ros2/build/rcutils/CMakeFiles/generate.stamp is up-to-date.
  test_uint8_array.cpp
  test_uint8_array.vcxproj -> C:\dev\ros2\build\rcutils\Release\test_uint8_array.exe

Asked by marossa on 2019-06-03 11:24:20 UTC

Comments

I'm not certain, but it could be that __InterlockedExchangeAdd64 is unsupported on x86 platforms.

Asked by gvdhoorn on 2019-06-03 11:45:01 UTC

Single underscore _InterlockedExchangeAdd64 is listed with arch 'x86, ARM, x64` in the documentation for VS 2017 and 2019, and is listed in intrinsics available on all architectures. Here's where it's used in rcutils

Asked by sloretz on 2019-06-03 12:00:41 UTC

The function does not seem to be used directly by rcl_timer_init, or anything in ros2/rcl. Could it be that InterlockedExchange64 is being used on Windows to implement one of the C runtime functions?


Edit: used here (among other places) and InterlockedExchange64 comes in via this.

Asked by gvdhoorn on 2019-06-03 12:05:17 UTC

I'd guess double underscore version is an implementation of the single underscore version which the rcl timer uses via rcutils_atomic_load_int64_t. @marossa, do the tests for rcutils pass? There is a test that checks atomics. If that works but rcl doesn't build, maybe there's some windows dependency not being properly exported?

Asked by sloretz on 2019-06-03 12:17:08 UTC

@sloretz, my ros2.sources was from May 27th with rcutils in ver. 0.6.2 (without the test_atomics). I updated my sources and now it fails, as you expected, in rcutils with the same error. Should I post the full stdout_stderr.log as an answer? It's too long for the comment. Edit: I guess it can't hurt: https://pastebin.com/CbEWncng

Asked by marossa on 2019-06-04 03:53:05 UTC

@marossa: just edit your original question text with long updates. I've done that for you, but you may want to add some context.

Asked by gvdhoorn on 2019-06-04 03:57:06 UTC

I'm still looking for a solution to the issue. I'm afraid I'm not deep enough into C++ to fix this myself. Any directions you could hint me? Why is VS looking for the double underscore instead of the single underscore?

Asked by marossa on 2019-06-07 08:25:46 UTC

I'm not speaking for @sloretz, but personally, this sounds more like a Windows specific linking problem than a ROS problem. You're trying to solve a linking problem while building ROS 2, true of course, but it might be beneficial to you to widen where you look for support.

Asked by gvdhoorn on 2019-06-07 09:16:27 UTC

Answers