Search code examples
c++visual-studioboostc++17boost-process

Moving function from console application to shared library project seem to bring unrelated compilation error


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?


Solution

  • 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>