ROS2 Foxy build from source failed in Windows 10 with Visual Studios 2019

asked 2020-11-05 06:42:46 -0600

votecoffee gravatar image

I ran through the steps to build from source in a VS Command Prompt elevated to admin.

I am following the steps from here: https://index.ros.org/doc/ros2/Instal...

I get this error:

Failed   <<< osrf_testing_tools_cpp [1min 31s, exited with code 1]

The log file is C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles shows this:

C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\src.c(15,17): warning C4013: 'pthread_atfork' undefined; assuming extern returning int [C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\cmTC_2d2b6.vcxproj]

src.obj : error LNK2019: unresolved external symbol pthread_atfork referenced in function main [C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\cmTC_2d2b6.vcxproj]

The full log file:

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: C:/dev/ros2_foxy/build/osrf_testing_tools_cpp/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe cmTC_2d2b6.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.



  Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29111 for x64

  src.c

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /I"C:\vcpkg\installed\x64-windows\include" /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D WIN32 /D _WINDOWS /D CMAKE_HAVE_LIBC_PTHREAD /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_2d2b6.dir\Debug\\" /Fd"cmTC_2d2b6.dir\Debug\vc142.pdb" /Gd /TC /errorReport:queue C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\src.c

C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\src.c(15,17): warning C4013: 'pthread_atfork' undefined; assuming extern returning int [C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\cmTC_2d2b6.vcxproj]

src.obj : error LNK2019: unresolved external symbol pthread_atfork referenced in function main [C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\cmTC_2d2b6.vcxproj]

C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\Debug\cmTC_2d2b6.exe : fatal error LNK1120: 1 unresolved externals [C:\dev\ros2_foxy\build\osrf_testing_tools_cpp\CMakeFiles\CMakeTmp\cmTC_2d2b6.vcxproj]



Source file was:
#include <pthread.h>

void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}
edit retag flag offensive close merge delete