0

My solution has several c++ console applications. That solution also has a project build as a Static Library (.lib). This library is used in all the console applications for any common functionality. All these project also use various boost libraries.

Recently there was a need to reuse a function from a console application in other applications.I therefore decided to move that function out from console application to that static library. However, doing so brings following compilation error.

c:\mySolution\packages\boost.1.69.0.0\lib\native\include\boost\asio\detail\impl\win_thread.ipp(90): error C2039: '_beginthreadex': is not a member of '`global namespace''
c:\mySolution\packages\boost.1.69.0.0\lib\native\include\boost\asio\detail\impl\win_thread.ipp(90): error C3861: '_beginthreadex': identifier not found

This function uses boost::process library and it works perfectly fine from within the console application. However, when I move same function into the Shared library project I start seeing this error. There is no other warning and it does not point to any of my application code. Any idea what could be the reason behind this error?

whoami
  • 1,689
  • 3
  • 22
  • 45

1 Answers1

1

From the documentation, you need to #include <process.h>. (I am using a quoted code block below to allow for table formatting...)

Requirements

Routine               Required header

_beginthread          <process.h>
_beginthreadex        <process.h>
jxh
  • 69,070
  • 8
  • 110
  • 193
  • Thanks for the tip but it does not help. I am also curious why this may help because when the function is in the console application, I don't have process.h included there either but everything works fine there. – whoami Apr 09 '19 at 23:46
  • There might be a setting in the project properties that says whether the code is allowed to use threads or not. – user253751 Apr 10 '19 at 00:01
  • there are some for runtime libraries but none of those seem to be hepful – whoami Apr 10 '19 at 00:35
  • Are you trying to not link in the MSVCRT*.dll files? `_beginthreadex` requires it. – jxh Apr 10 '19 at 08:06