Skip to content

ROS2 Foxy fails to build osrf_testing_tools_cpp because of unresolved external symbol pthread_atfork #56

Open
@votecoffee

Description

@votecoffee

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/Installation/Dashing/Windows-Development-Setup/

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions