c++ - 为 C++ 构建 Boost 库时出错
问题描述
我正在尝试构建 Boost 库以在 CodeBlocks 上的 C++ 项目中使用它,但一些错误阻止它完成。
我从这个页面的网站下载了 7z 文件: https ://www.boost.org/users/download/ Windows 版本。
然后我尝试在解压缩后构建它。起初它找不到 printf,但是当我在环境变量中向上移动 gcc.exe 路径时,它让我不再有错误窗口。
所以我再次下载它以尝试从一个未修改的版本重建,这就是发生的事情
C:\Users\Trusc\Desktop\boost_1_72_0\boost_1_72_0>bootstrap.bat gcc -v
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 'void try_wait_callback(void*, BOOLEAN)':
execnt.cpp:837:39: error: 'UnregisterWait' was not declared in this scope
UnregisterWait( slot->wait_handle );
^
execnt.cpp: In function 'void register_wait(int)':
execnt.cpp:860:52: error: 'RegisterWaitForSingleObject' was not declared in this scope
WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE );
^
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 );
^
File Not Found
Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.
C:\Users\Trusc\Desktop\boost_1_72_0\boost_1_72_0>
这是 bootstrap.log 所说的
###
### Using 'gcc' toolset.
###
C:\Users\Trusc\Desktop\boost_1_72_0\boost_1_72_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
C:\Users\Trusc\Desktop\boost_1_72_0\boost_1_72_0\tools\build\src\engine>dir *.exe
Volume in drive C is OS
Volume Serial Number is 5E38-88DC
Directory of C:\Users\Trusc\Desktop\boost_1_72_0\boost_1_72_0\tools\build\src\engine
C:\Users\Trusc\Desktop\boost_1_72_0\boost_1_72_0\tools\build\src\engine>copy /b .\b2.exe .\bjam.exe
The system cannot find the file specified.
这是我正在使用的 gcc 版本,来自 Codeblocks 安装文件中的 MinGW 文件夹
C:\Users\Trusc\Desktop\boost_1_72_0\boost_1_72_0>gcc --version
gcc (tdm-1) 5.1.0
Copyright (C) 2015 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.
如果需要,我很乐意提供更多信息。请考虑到我是图书馆的新手。
谢谢
解决方案
我最终解决了这个问题。我了解到 1.72.0 版本与 MinGW 存在兼容性问题,所以我恢复到 1.70.0 版本,并且使用 MinGW 我已经能够编译它并获得我需要的所有库。