现象
使用vs2017编译时boost179时(执行b2.exe时),报了如下错误:boost_1_79_0/tools/build/src/build\targets.jam:617: in start-building from module targets
error: Recursion in main target references
error: the following target are being built currently:
error: ./forward -> ./stage -> ./stage-proper -> libs/filesystem/build/stage -> libs/filesystem/build/stage-dependencies -> libs/log/build/stage -> libs/log/build/stage-dependencies -> * * * libs/filesystem/build/stage * * *
原因分析
在网上没能查到解决方法,然后看了看打印信息,想起我电脑上装了多个VS版本,猜想可能是编译时没有找对VS版本
解决方法
在使用b2.exe编译时,指明vs版本(vs 2017是vc141)
b2.exe install --toolset=msvc-14.1 --prefix="D:\Boost\boost_1_79\vs2017" link=static runtime-link=shared runtime-link=static threading=multi debug release
然后编译成功~
执行b2.exe --help,可查看命令参数含义:
stage/install:stage表示只生成库(dll和lib),install还会生成包含头文件的include目录。
toolset:指定编译器,可选的如msvc-14.2(VS2019编译器)等。
without/with:选择不编译/编译哪些库。
stagedir/prefix:stage时使用stagedir,install时使用prefix,表示编译生成文件的路径。
build-dir:编译生成的中间文件的路径。默认在根目录下,目录名为bin.v2,等编译完成后可将这个目录全部删除,所以不需要去设置。
link:生成动态链接库/静态链接库。生成动态链接库需使用shared方式,生成静态链接库需使用static方式。
runtime-link:动态/静态链接C/C++运行时库。
threading:单/多线程编译。分别指定single/multi方式。
debug/release:编译debug/release版本。
参考链接
-
https://blog.csdn.net/chexlong/article/details/126230195?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166322418916782395344356%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=166322418916782395344356&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2blogfirst_rank_ecpm_v1~rank_v31_ecpm-4-126230195-null-null.nonecase&utm_term=boost1.79%E7%BC%96%E8%AF%91&spm=1018.2226.3001.4450
-
https://blog.csdn.net/u012424737/article/details/110439018
有帮助的话,点个赞吧~