Boost不是由Boost构建的自动链接库,而是已构建的预期链接 [英] Boost autolinks libraries which are not built by Boost, but the intended ones are built

查看:103
本文介绍了Boost不是由Boost构建的自动链接库,而是已构建的预期链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Math应用程序,可以通过编写python脚本进行扩展.

I am developing a Math application which can be extended by writing python scripts.

我正在使用Qt 4.6.3(作为静态库构建,调试和发布版本)和Boost 1.43.0(作为静态库构建,运行时链接也设置为静态,多线程版本,调试和发布).一切都是使用MSVC ++ 2008构建的. Boost建立了以下库:

I am using Qt 4.6.3 (built as static library, debug and release versions) and Boost 1.43.0 (built as static library, runtime-link also set to static, multi-threaded version, debug and release). Everything is built with MSVC++2008. Boost built the following libraries:

  • libboost_python-vc90-mt-s-1_43.lib
  • libboost_python-vc90-mt-s.lib
  • libboost_python-vc90-mt-sgd-1_43.lib
  • libboost_python-vc90-mt-sgd.lib

我的项目可以编译,但是在链接阶段会出现以下错误:

My project compiles, but gives the following error during the linking phase:

1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'boost_python-vc90-mt-gd-1_43.lib'

为什么不选择我的已编译库之一?

Why is it not selecting one of my compiled libraries?

我认为库名称中的s代表静态,但是自动链接功能似乎选择了一个动态库,我希望将它们全部静态链接到一个可执行文件中.

I think the s in the library names stands for static, but then the auto-linking feature seems to select a dynamic library, and I want it all linked statically in one executable.

regex库也会发生同样的情况:我编译了相同的4个regex库,并通过快速测试显示了此链接错误:

The same happens with the regex library: I have the same 4 regex libraries compiled and a quick test shows this linking error:

1>LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc90-mt-gd-1_43.lib'

该怎么办?

推荐答案

问题已解决,在Boost库的编译过程中,我选择了link = static选项.创建静态库.我还选择了runtime-link = static选项,这是错误的!

The problem is fixed, during the compilation of the boost libraries, I selected the link=static option. Which creates static libraries. I also selected runtime-link=static option, and this was wrong!

此问题的解决方案是使用runtime-link = shared编译boost.现在,添加了一些带有正确文件名的额外库,以便链接程序可以找到它们.最初,编译器仍会搜索dll库(boost_python-vc90-mt-gd-1_43.lib,而不是libboost_python-vc90-mt-gd-1_43.lib),其他所有内容(从boost链接自动链接到静态库)都可以,但是因为boost.python设置了不同的自动链接,所以当您提供BOOST_PYTHON_STATIC_LIB时,它最终会链接到正确的库,并且可以正常工作!

The solution for this problem was compiling boost with runtime-link=shared. Now some extra libraries are added, with the correct filenames, so the linker can find them. At first the compiler still searches for the dll library (boost_python-vc90-mt-gd-1_43.lib, instead of libboost_python-vc90-mt-gd-1_43.lib), everything else from boost links automatically to a static library, but because boost.python has a different auto-linkage set up, when you provide BOOST_PYTHON_STATIC_LIB, it finally links to the right library and it works!

这篇关于Boost不是由Boost构建的自动链接库,而是已构建的预期链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆