如何使用"-pthread"而不是"-mthread"编译boost_thread?
How to compile boost_thread with "-pthread" instead of "-mthread"?
我有一个操作系统,没有-mthread
可用。我有-pthread
。如何使用-pthread
而不是-mthread
编译 boost_thread ?
我当前的编译器构建日志:
./b2 -j1 --with-thread link=static --prefix=./install-dir release threading=multi --builddir=./bu
ild-dir install
Component configuration:
- chrono : not building
- context : not building
- date_time : not building
- exception : not building
- filesystem : not building
- graph : not building
- graph_parallel : not building
- iostreams : not building
- locale : not building
- math : not building
- mpi : not building
- program_options : not building
- python : not building
- random : not building
- regex : not building
- serialization : not building
- signals : not building
- system : not building
- test : not building
- thread : building
- timer : not building
- wave : not building
...patience...
...found 19764 targets...
...updating 16 targets...
gcc.compile.c++ bin.v2/libs/system/build/gcc-4.2.1/release/link-static/threading-multi/error_code.o
cc1plus: error: unrecognized command line option "-mthreads"
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -mthreads -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_STATIC_LINK=1 -DNDEBUG -I"." -c -o "bin.v2libssystembuildgcc-4.2.
1releaselink-staticthreading-multierror_code.o" "libssystemsrcerror_code.cpp"
...failed gcc.compile.c++ bin.v2/libs/system/build/gcc-4.2.1/release/link-static/threading-multi/error_code.o...
...skipped <pbin.v2/libs/system/build/gcc-4.2.1/release/link-static/threading-multi>libboost_system.a(clean) for lack of <pbin.v2/libs/system/build/gcc-4.2.1/release/link-static/threading-multi>error_
code.o...
...skipped <pbin.v2/libs/system/build/gcc-4.2.1/release/link-static/threading-multi>libboost_system.a for lack of <pbin.v2/libs/system/build/gcc-4.2.1/release/link-static/threading-multi>error_code.o.
..
...skipped <pinstall-dir/lib>libboost_system.a for lack of <pbin.v2/libs/system/build/gcc-4.2.1/release/link-static/threading-multi>libboost_system.a...
gcc.compile.c++ bin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi/chrono.o
cc1plus: error: unrecognized command line option "-mthreads"
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -mthreads -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_All_STATIC_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATE
D -DBOOST_SYSTEM_STATIC_LINK=1 -DNDEBUG -I"." -c -o "bin.v2libschronobuildgcc-4.2.1releaselink-staticthreading-multichrono.o" "libschronosrcchrono.cpp"
...failed gcc.compile.c++ bin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi/chrono.o...
gcc.compile.c++ bin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi/thread_clock.o
cc1plus: error: unrecognized command line option "-mthreads"
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -mthreads -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_All_STATIC_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATE
D -DBOOST_SYSTEM_STATIC_LINK=1 -DNDEBUG -I"." -c -o "bin.v2libschronobuildgcc-4.2.1releaselink-staticthreading-multithread_clock.o" "libschronosrcthread_clock.cpp"
...failed gcc.compile.c++ bin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi/thread_clock.o...
gcc.compile.c++ bin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi/process_cpu_clocks.o
cc1plus: error: unrecognized command line option "-mthreads"
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -mthreads -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_All_STATIC_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATE
D -DBOOST_SYSTEM_STATIC_LINK=1 -DNDEBUG -I"." -c -o "bin.v2libschronobuildgcc-4.2.1releaselink-staticthreading-multiprocess_cpu_clocks.o" "libschronosrcprocess_cpu_clocks.cpp"
...failed gcc.compile.c++ bin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi/process_cpu_clocks.o...
...skipped <pbin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi>libboost_chrono.a(clean) for lack of <pbin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi>chrono
.o...
...skipped <pbin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi>libboost_chrono.a for lack of <pbin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi>chrono.o...
...skipped <pinstall-dir/lib>libboost_chrono.a for lack of <pbin.v2/libs/chrono/build/gcc-4.2.1/release/link-static/threading-multi>libboost_chrono.a...
gcc.compile.c++ bin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi/pthread/thread.o
cc1plus: error: unrecognized command line option "-mthreads"
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -mthreads -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_STATIC_LINK=1 -DBOOST_SYSTEM_NO_DEPREC
ATED -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2libsthreadbuildgcc-4.2.1releaselink-staticthreading-multipthreadthread.o" "libs
threadsrcpthreadthread.cpp"
...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi/pthread/thread.o...
gcc.compile.c++ bin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi/pthread/once.o
cc1plus: error: unrecognized command line option "-mthreads"
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -mthreads -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_STATIC_LINK=1 -DBOOST_SYSTEM_NO_DEPREC
ATED -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2libsthreadbuildgcc-4.2.1releaselink-staticthreading-multipthreadonce.o" "libsth
readsrcpthreadonce.cpp"
...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi/pthread/once.o...
gcc.compile.c++ bin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi/future.o
cc1plus: error: unrecognized command line option "-mthreads"
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -mthreads -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_STATIC_LINK=1 -DBOOST_SYSTEM_NO_DEPREC
ATED -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2libsthreadbuildgcc-4.2.1releaselink-staticthreading-multifuture.o" "libsthreads
rcfuture.cpp"
...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi/future.o...
...skipped <pbin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi>libboost_thread.a(clean) for lack of <pbin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi>pthrea
d/thread.o...
...skipped <pbin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi>libboost_thread.a for lack of <pbin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi>pthread/threa
d.o...
...skipped <pinstall-dir/lib>libboost_thread.a for lack of <pbin.v2/libs/thread/build/gcc-4.2.1/release/link-static/threading-multi>libboost_thread.a...
...failed updating 7 targets...
...skipped 9 targets...
可以以某种方式使用编译器在我的平台上编译我的平台上,以使boost_thread thint与-pthread
进行编译?
平台 - 旧的,hevily修改的cigwin,GCC -4.2.1
您可以尝试修补工具/build/v2/tools/gcc.jam
1017 rule setup-threading ( targets * : sources * : properties * )
1018 {
1019 local threading = [ feature.get-values threading : $(properties) ] ;
1020 if $(threading) = multi
1021 {
1022 local target = [ feature.get-values target-os : $(properties) ] ;
1023 local option ;
1024 local libs ;
1025
1026 switch $(target)
1027 {
1028 case windows : option = -mthreads ;
1029 case cygwin : option = -mthreads ;
1030 case solaris : option = -pthreads ; libs = rt ;
1031 case beos : # No threading options.
1032 case *bsd : option = -pthread ; # There is no -lrt on BSD.
1033 case sgi : # gcc on IRIX does not support multi-threading.
1034 case darwin : # No threading options.
1035 case * : option = -pthread ; libs = rt ;
1036 }
1037
如果您提供了更多信息,我可以尝试为您提供帮助。
您可以使用CXXFLAGS参数将标志传递给编译器,请参见http://www.boost.org/build/doc/doc/html/bbv2/reference/reference/tools.html.s.html#bbv2。reference.tools.compiler.gcc有些可能会有所帮助的是:cxxflags = -dpthreads cxxflags = -dboost_thread_posix cxxflags = -pthread cxxflags = -dthread
您可能必须进行试验才能完全获得所需的结果,但是我将从将您的命令重新编写为
./b2 -j1 --with-thread link=static cxxflags=-DPTHREADS cxxflags=-DBOOST_THREAD_POSIX cxxflags=-pthread cxxflags=-DTHREAD --prefix=./install-dir release threading=multi --builddir=./build-dir install
相关文章:
- 编译 Boost 时在 OS X 上的"ld:未知选项:-soname"
- 在其他容器中使用 boost::container::static_vector 时,GCC 编译错误"将'const s'绑定到类型's&'的引用丢弃限定符"
- 在 Centos7 上使用 boost 1.71.0 编译错误
- 包含来自 boost 1.73.0 的read_graphviz_new.cpp无法编译
- 编译用于Sony NMOS实现的C++boost库
- Simple_ls.cpp的C++Boost编译错误-未找到对Boost的引用::文件系统::路径::文件名
- python的Boost编译错误
- 在 Ubuntu 14.04 上使用 boost 编译:未定义对 'boost::thread::get_id() const' 的引用
- 使用boost编译时出错
- 关于使用cmake和boost编译c++代码的错误
- ubuntu服务器14.04上的Boost编译失败
- 使用boost编译错误.图1.56.0和g++ 4.6.4
- OS X 10.8.5下的Boost编译错误
- Boost编译标记gcc错误
- 使用mingw的boost编译错误
- Boost编译标志,它是什么意思
- Boost编译问题
- 用boost编译一些代码.Python在win7-64位
- 不能用boost编译
- 使用boost编译以使用可用的boost版本