Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost 1.71.0 can't be compiled with mingw #16

Open
Haffon opened this issue Aug 20, 2019 · 19 comments
Open

boost 1.71.0 can't be compiled with mingw #16

Haffon opened this issue Aug 20, 2019 · 19 comments

Comments

@Haffon
Copy link

Haffon commented Aug 20, 2019

bootstrap.bat gcc #come from E:\MinGW\bin
Building Boost.Build engine
builtins.cpp: In function 'FILE* windows_popen_wrapper(const char*, const char*)':
builtins.cpp:2483:39: error: '_popen' was not declared in this scope
result = _popen( command, "r" );
^
builtins.cpp: In function 'LIST* builtin_shell(FRAME*, int)':
builtins.cpp:2549:29: error: '_pclose' was not declared in this scope
exit_status = pclose( p );
...

1.70.0 is okay.

@Haffon
Copy link
Author

Haffon commented Aug 20, 2019

type erasure module build failed:
clang-linux.compile.c++.without-pch bin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn\dynamic_binding.o
clang-linux.archive bin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn\libboost_type_erasure-clang-mt-a32-1_71.a
ar: bin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn\libboost_type_erasure-clang-mt-a32-1_71.a: No such file or directory
ranlib: 'bin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn\libboost_type_erasure-clang-mt-a32-1_71.a': No such file

"ar"  rc "bin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn\libboost_type_erasure-clang-mt-a32-1_71.a" "bin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn\dynamic_binding.o"
"ranlib" "bin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn\libboost_type_erasure-clang-mt-a32-1_71.a"

...failed clang-linux.archive bin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn\libboost_type_erasure-clang-mt-a32-1_71.a...
...skipped pC:\Users\01372525\.conan\data\boost\1.71.0\bashbug\stable\build\4e65a98fd5c197b6539ce5c3062c84123c059f0c\boost_1_71_0\armv7\liblibboost_type_erasure-clang-mt-a32-1_71.a for lack of <pbin.v2\libs\type_erasure\build\clng-lnx-andrd\rls\lnk-sttc\trgt-os-andrd\thrdp-pthrd\thrd-mlt\vsblt-hdn>libboost_type_erasure-clang-mt-a32-1_71.a...

other module or version 1.70.0 is okay. type_erasure issue only occur inside conan, it is okay when build standalone without conan.

@mclow mclow transferred this issue from boostorg/boost Aug 21, 2019
@skillcoder
Copy link

skillcoder commented Sep 21, 2019

The same issue for me

g:\boost_1_71_0>bootstrap.bat gcc
Building Boost.Build engine
builtins.cpp: In function 'FILE* windows_popen_wrapper(const char*, const char*)':
builtins.cpp:2483:39: error: '_popen' was not declared in this scope
         result = _popen( command, "r" );
                                       ^
builtins.cpp: In function 'LIST* builtin_shell(FRAME*, int)':
builtins.cpp:2549:29: error: '_pclose' was not declared in this scope
     exit_status = pclose( p );
                             ^
debugger.cpp: In function 'char* debug_string_read(FILE*)':
debugger.cpp:110:33: error: 'strdup' was not declared in this scope
     result = strdup( buf->value );
                                 ^
debugger.cpp: In function 'void debug_init_handles(const char*, const char*)':
debugger.cpp:1073:43: error: '_fdopen' was not declared in this scope
     command_input = _fdopen( read_fd, "r" );
                                           ^
debugger.cpp: In function 'void init_parent_handles(HANDLE, HANDLE)':
debugger.cpp:1091:78: error: '_fdopen' was not declared in this scope
     command_child = _fdopen( _open_osfhandle( (intptr_t)in, _O_RDONLY ), "r" );
                                                                              ^
execnt.cpp: In function 'int is_parent_child(DWORD, DWORD)':
execnt.cpp:1085:61: error: 'stricmp' was not declared in this scope
                 if ( !stricmp( pinfo.szExeFile, "csrss.exe" ) &&
                                                             ^
execnt.cpp:1088:60: error: 'stricmp' was not declared in this scope
                 if ( !stricmp( pinfo.szExeFile, "smss.exe" ) &&
                                                            ^
jam.cpp: In function 'int main(int, char**, char**)':
jam.cpp:200:22: error: 'environ' was not declared in this scope
 # define use_environ environ
                      ^
jam.cpp:561:37: note: in expansion of macro 'use_environ'
         var_defines( root_module(), use_environ, 1 );
                                     ^~~~~~~~~~~
jam.cpp: In function 'char* executable_path(const char*)':
jam.cpp:729:66: error: 'strdup' was not declared in this scope
     return ( !ret || ret == sizeof( buf ) ) ? NULL : strdup( buf );
                                                                  ^
sysinfo.cpp: In function 'unsigned int {anonymous}::std_thread_hardware_concurrency()':
sysinfo.cpp:93:21: error: 'std::thread' has not been declared
         return std::thread::hardware_concurrency();
                     ^~~~~~

bootstrap.log

###
### Using 'gcc' toolset.
###

g:\boost_1_71_0\tools\build\src\engine>g++ -x c++ -std=c++11 -s -O3 -o b2.exe   -DNDEBUG  builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp filent.cpp filesys.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam.cpp jambase.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp regexp.cpp rules.cpp scan.cpp search.cpp strings.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp  

g:\boost_1_71_0>g++ --version

g++ (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@Friteee
Copy link

Friteee commented Sep 28, 2019

Same here. Anyone found a solution to this?

@Friteee
Copy link

Friteee commented Sep 30, 2019

Installed the 1_70 version of boost + installed mingw_64 instead of unmaintained mingw, now compiles smoothly.

@Empischon
Copy link

Same problem:

D:\CppLib\boost_1_71_0\tools\build>bootstrap.bat mingw
Bootstrapping the build engine
builtins.cpp: In function 'FILE* windows_popen_wrapper(const char*, const char*)':
builtins.cpp:2483:18: error: '_popen' was not declared in this scope
result = _popen( command, "r" );
^~~~~~
builtins.cpp:2483:18: note: suggested alternative: '_lopen'
result = _popen( command, "r" );
^~~~~~
_lopen
builtins.cpp: In function 'LIST* builtin_shell(FRAME*, int)':
builtins.cpp:2418:20: error: '_pclose' was not declared in this scope
#define pclose _pclose
^~~~~~~
builtins.cpp:2549:19: note: in expansion of macro 'pclose'
exit_status = pclose( p );
^~~~~~
builtins.cpp:2418:20: note: suggested alternative: '_lclose'
#define pclose _pclose
^~~~~~~
builtins.cpp:2549:19: note: in expansion of macro 'pclose'
exit_status = pclose( p );
^~~~~~
debugger.cpp: In function 'char* debug_string_read(FILE*)':
debugger.cpp:110:14: error: 'strdup' was not declared in this scope
result = strdup( buf->value );
^~~~~~
debugger.cpp:110:14: note: suggested alternative: 'strcmp'
result = strdup( buf->value );
^~~~~~
strcmp
debugger.cpp: In function 'void debug_init_handles(const char*, const char*)':
debugger.cpp:1073:21: error: '_fdopen' was not declared in this scope
command_input = _fdopen( read_fd, "r" );
^~~~~~~
debugger.cpp:1073:21: note: suggested alternative: '_wsopen'
command_input = _fdopen( read_fd, "r" );
^~~~~~~
_wsopen
debugger.cpp: In function 'void init_parent_handles(HANDLE, HANDLE)':
debugger.cpp:1091:21: error: '_fdopen' was not declared in this scope
command_child = _fdopen( _open_osfhandle( (intptr_t)in, _O_RDONLY ), "r" );
^~~~~~~
debugger.cpp:1091:21: note: suggested alternative: '_wsopen'
command_child = _fdopen( _open_osfhandle( (intptr_t)in, _O_RDONLY ), "r" );
^~~~~~~
_wsopen
execnt.cpp: In function 'int is_parent_child(DWORD, DWORD)':
execnt.cpp:1085:23: error: 'stricmp' was not declared in this scope
if ( !stricmp( pinfo.szExeFile, "csrss.exe" ) &&
^~~~~~~
execnt.cpp:1085:23: note: suggested alternative: 'strncmp'
if ( !stricmp( pinfo.szExeFile, "csrss.exe" ) &&
^~~~~~~
strncmp
execnt.cpp:1088:23: error: 'stricmp' was not declared in this scope
if ( !stricmp( pinfo.szExeFile, "smss.exe" ) &&
^~~~~~~
execnt.cpp:1088:23: note: suggested alternative: 'strncmp'
if ( !stricmp( pinfo.szExeFile, "smss.exe" ) &&
^~~~~~~
strncmp
jam.cpp: In function 'int main(int, char**, char**)':
jam.cpp:200:22: error: 'environ' was not declared in this scope

define use_environ environ

                  ^~~~~~~

jam.cpp:561:37: note: in expansion of macro 'use_environ'
var_defines( root_module(), use_environ, 1 );
^~~~~~~~~~~
jam.cpp:200:22: note: suggested alternative: 'union'

define use_environ environ

                  ^~~~~~~

jam.cpp:561:37: note: in expansion of macro 'use_environ'
var_defines( root_module(), use_environ, 1 );
^~~~~~~~~~~
jam.cpp: In function 'char* executable_path(const char*)':
jam.cpp:729:54: error: 'strdup' was not declared in this scope
return ( !ret || ret == sizeof( buf ) ) ? NULL : strdup( buf );
^~~~~~
jam.cpp:729:54: note: suggested alternative: 'strcmp'
return ( !ret || ret == sizeof( buf ) ) ? NULL : strdup( buf );
^~~~~~
strcmp
sysinfo.cpp: In function 'unsigned int {anonymous}::std_thread_hardware_concurrency()':
sysinfo.cpp:93:21: error: 'std::thread' has not been declared
return std::thread::hardware_concurrency();
^~~~~~
File Not Found

Failed to bootstrap the build engine
Please consult bootstrap.log for further diagnostics.

D:\CppLib\boost_1_71_0\tools\build>g++ --version
g++ (MinGW.org GCC-8.2.0-3) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@antonypace
Copy link

Same here - 3 months later. I'm surprised such a fundamental problem got through the release procedure. I'm also going to try reverting to 1.70

@Lusica1031
Copy link

Installed the 1_70 version of boost + installed mingw_64 instead of unmaintained mingw, now compiles smoothly.

Thanks! it works for me to change the version.

@gdias1992
Copy link

gdias1992 commented Dec 16, 2019

Same problem.

Same here - 3 months later. I'm surprised such a fundamental problem got through the release procedure. I'm also going to try reverting to 1.70

Thanks!

@changshen
Copy link

The problem still there. We must use MinGW_64 g++ compiler?

But there are some issues with MinGW_64/Windows 10/Code::Blocks

g++ --version
g++ (MinGW.org GCC-8.2.0-3) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

git source to most current one (sync with master. version boost-1.72.0)

Building Boost.Build engine
builtins.cpp: In function 'FILE* windows_popen_wrapper(const char*, const char*)':
builtins.cpp:2483:18: error: '_popen' was not declared in this scope
result = _popen( command, "r" );
^~~~~~
builtins.cpp:2483:18: note: suggested alternative: '_lopen'
result = _popen( command, "r" );
^~~~~~
_lopen
builtins.cpp: In function 'LIST* builtin_shell(FRAME*, int)':
builtins.cpp:2418:20: error: '_pclose' was not declared in this scope
#define pclose _pclose
^~~~~~~
builtins.cpp:2549:19: note: in expansion of macro 'pclose'
exit_status = pclose( p );
^~~~~~
builtins.cpp:2418:20: note: suggested alternative: '_lclose'
#define pclose _pclose
^~~~~~~
builtins.cpp:2549:19: note: in expansion of macro 'pclose'
exit_status = pclose( p );
^~~~~~
debugger.cpp: In function 'char* debug_string_read(FILE*)':
debugger.cpp:110:14: error: 'strdup' was not declared in this scope
result = strdup( buf->value );
^~~~~~
debugger.cpp:110:14: note: suggested alternative: 'strcmp'
result = strdup( buf->value );
^~~~~~
strcmp
debugger.cpp: In function 'void debug_init_handles(const char*, const char*)':
debugger.cpp:1073:21: error: '_fdopen' was not declared in this scope
command_input = _fdopen( read_fd, "r" );
^~~~~~~
debugger.cpp:1073:21: note: suggested alternative: '_wsopen'
command_input = _fdopen( read_fd, "r" );
^~~~~~~
_wsopen
debugger.cpp: In function 'void init_parent_handles(HANDLE, HANDLE)':
debugger.cpp:1091:21: error: '_fdopen' was not declared in this scope
command_child = _fdopen( _open_osfhandle( (intptr_t)in, _O_RDONLY ), "r" );
^~~~~~~
debugger.cpp:1091:21: note: suggested alternative: '_wsopen'
command_child = _fdopen( _open_osfhandle( (intptr_t)in, _O_RDONLY ), "r" );
^~~~~~~
_wsopen
execnt.cpp: In function 'int is_parent_child(DWORD, DWORD)':
execnt.cpp:1085:23: error: 'stricmp' was not declared in this scope
if ( !stricmp( pinfo.szExeFile, "csrss.exe" ) &&
^~~~~~~
execnt.cpp:1085:23: note: suggested alternative: 'strncmp'
if ( !stricmp( pinfo.szExeFile, "csrss.exe" ) &&
^~~~~~~
strncmp
execnt.cpp:1088:23: error: 'stricmp' was not declared in this scope
if ( !stricmp( pinfo.szExeFile, "smss.exe" ) &&
^~~~~~~
execnt.cpp:1088:23: note: suggested alternative: 'strncmp'
if ( !stricmp( pinfo.szExeFile, "smss.exe" ) &&
^~~~~~~
strncmp
jam.cpp: In function 'int main(int, char**, char**)':
jam.cpp:200:22: error: 'environ' was not declared in this scope

define use_environ environ

                  ^~~~~~~

jam.cpp:561:37: note: in expansion of macro 'use_environ'
var_defines( root_module(), use_environ, 1 );
^~~~~~~~~~~
jam.cpp:200:22: note: suggested alternative: 'union'

define use_environ environ

                  ^~~~~~~

jam.cpp:561:37: note: in expansion of macro 'use_environ'
var_defines( root_module(), use_environ, 1 );
^~~~~~~~~~~
jam.cpp: In function 'char* executable_path(const char*)':
jam.cpp:729:54: error: 'strdup' was not declared in this scope
return ( !ret || ret == sizeof( buf ) ) ? NULL : strdup( buf );
^~~~~~
jam.cpp:729:54: note: suggested alternative: 'strcmp'
return ( !ret || ret == sizeof( buf ) ) ? NULL : strdup( buf );
^~~~~~
strcmp
sysinfo.cpp: In function 'unsigned int {anonymous}::std_thread_hardware_concurrency()':
sysinfo.cpp:93:21: error: 'std::thread' has not been declared
return std::thread::hardware_concurrency();
^~~~~~
File Not Found

Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.

@jungletek
Copy link

If you're posting code, use the code tags FFS.

@morinmorin
Copy link
Member

@mclow, @grafikrobot, I think this is an issue in Boost.Build rather than Boost.TypeErasure.

src/engine/builtins.cpp uses _popen/_pclose, but they are not defined when compiled with -std=c++** options on MinGW GCC. (Mingw-w64 GCC defines them even with -std=c++** options.) Solutions would be

  • Use -std=gnu++** option; or
  • Add -U__STRICT_ANSI__ option.

@wut08
Copy link

wut08 commented Jun 27, 2020

Not just MingW, it can't be compiled with anything. going to try 1.70

@grafikrobot
Copy link
Member

I don't remember about the B2 that shipped with 1.71.. But at least the current B2 (4.3) builds fine with MinGW..

https://dev.azure.com/grafikrobot/B2/_build/results?buildId=924&view=logs&j=305851a9-a7bb-55db-0042-7e2b6f48aa1c&t=37d4889e-ed03-50ca-1a92-27bcc3794f08&l=13

Some important facts:

  • You can use the most current b2 (of the 4.x series) to build any Boost version back to Boost 1.66.0.
  • If you have another non-mingw compiler you can use that to build B2. The compiler you use to build B2 has no bearing on the compiler you use to build Boost itself.

@boroboro77
Copy link

I have the same issue.

@doug-lew-diagraph
Copy link

doug-lew-diagraph commented Jan 7, 2021

I'm currently trying to build boost 1.75, running boostrap.sh, in MinGW with gcc 6.3.0 and I am running into the same error:

sysinfo.cpp:93:21: error: 'std::thread' has not been declared

I had previously had -std=c++11 but based on the recommendation above I changed it to "gnu++11" but there is no change the build still generates the same error.

@jungletek
Copy link

I'm currently trying to build boost 1.75, running boostrap.sh, in MinGW with gcc 6.3.0 and I am running into the same error:

sysinfo.cpp:93:21: error: 'std::thread' has not been declared

Pretty sure that's because the version of MinGW is old enough that it doesn't have std::thread in the stdlib. Strongly suggest switching to a maintained version as suggested earlier in the thread. I switched to MSYS2 and the mingw-w64 that is available via its package manager, and am very happy with it (also Boost is available, so really no need to compile it yourself anymore unless you have a special case).

@doug-lew-diagraph
Copy link

Thank you for your recommendation jungletek! I upgraded my version on MinGW and used the package manager to get the latest gcc tool set (10.2.0). I am no longer seeing this error when I execute ./bootstrap.sh. It still does not build but due to other errors that will be in another post.
I do need to do the build because my project is cross compiling to an embedded ARM processor.

@eristavi
Copy link

eristavi commented Feb 7, 2022

I don't know how helpful it will be for anyone but here is my boost successful installation and configuration.

Please note that the following instructions are for MSVC 14.2 without Mingw

  1. Download the binaries from version 1.78.0 or you may choose the version you desire.
    boost_1_78_0-msvc-14.2-64.exe
    boost_1_78_0-msvc-12.0-32.exe

  2. Install the downloaded binaries
    In my case, I have created a dev folder in my D drive D:/dev and installed boost there. During the installation Boost installer asked for installation directory default was C:/Program Files/Boost_1_78_0 I changed the directory as I like things readable and clean D:/dev/boost

  3. Open the CMD "Command Prompt" and navigate to the installed folder in my case it's D:/dev/boost
    Note: Don't use PowerShell, or PowerShell 7. It gave me some weird errors.
    use the command bootstrap.bat to initiate the installer and generate b2.exe file

  4. Let's Start Building

a. Building for x86 architecture use the following command
b2 --build-dir=build\x86 address-model=32 threading=multi --stagedir=.\bin\x86 --toolset=msvc -j 16 link=static,shared runtime-link=static,shared --variant=debug,release

b. Building Debug for x64 architecture use the following command
b2 --build-dir=build\x64 address-model=64 threading=multi --stagedir=.\bin\x64 --toolset=msvc -j 8 link=static,shared runtime-link=static,shared --variant=debug,release

  1. Add the Environment Variables to the Path to generated binaries. In my example is the following

Explaining the build command arguments

Arguments used in the previous two commands.
--build-dir: Specify the directory to place all the intermediate files while building.
address-model: Specify the targeting address model.
threading: Compile Boost to be thread-aware. (see this question on stackoverflow for more info.)
--stage-dir: the directory where the binaries will be placed.
--toolset: The compiler and linker that will be used to build the artefacts. We chose msvc; this should be the default on Windows, but in case we have more compilers installed on the system, it’s better to explicitly define it.
-j: how many threads to use for building. This can drastically improve the build times on multi-threading environments, i.e. most modern machines.
link: declare a library target.
runtime-link: linking statically/dynamically to the C++ standard library and compiler runtime support libraries.
--variant: Build debug or release version of the binaries.

Source: George Gkasdrogkas See the full guide. It's very clean and easy.

Regards

@jungletek
Copy link

I don't know how helpful it will be for anyone but here is my boost successful installation and configuration.

Please note that the following instructions are for MSVC 14.2 without Mingw

The build flags may be helpful for some, but this is a thread about MinGW, so providing MSVC-related stuff is of questionable utility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests