如何在依赖静态链接库加速 [英] How to link Boost in a dependant static library
问题描述
在微软的Visual C ++ 2010
我在的解决方案,用于提升和完美的工作有一个C ++项目。
然后我决定把这个项目转化为静态库,并创建一个新的项目,它取决于该静态库。
现在,我转换静态库的建立没有错误和警告(编译和链接)
但新项目编译但不链接。
我越来越:
1 GT; LINK:致命错误LNK1104:无法打开文件'libboost_thread-VC100-MT-1_45.lib
作为测试我加入了完整的目录路径,此库的连接选项...,然后将它抱怨
1 GT; LINK:致命错误LNK1104:无法打开文件'libboost_date_time-VC100-MT-1_45.lib
我现在已经完全加入到路径所有图书馆,它现在建立并运行。
我不开心的这个解决方案是因为:
- 我不希望库的用户
不必担心在链接
促进。 - 这是凌乱
我知道一个答案是创建一个DLL,但有没有办法静态做到这一点,并保持连接我的静态库的水平。
感谢:)
编辑:
如果我告诉.exe文件链接器忽略升压库明确则一切正常,除了该.exe不应该担心刺激可言。
/ NODEFAULTLIB:libboost_thread-VC100-MT-1_45.lib/NODEFAULTLIB:\"libboost_date_time-vc100-mt-1_45.lib
显然,你不需要的.libs,因为你的EXE没有他们还链接。你似乎可以用升压只有头的方法和类。所以,只要告诉提振定义项目中的preprocessor符号BOOST_ALL_NO_LIB禁用自动连接。
如果你想使你的.lib不必要的大通过包括所有的提振,这个问题似乎举行一个答案(我从来没有真正尝试过我自己):<一href=\"http://stackoverflow.com/questions/2157629/linking-static-libraries-to-other-static-libraries\">Linking静态库与其他静态库
In MS Visual C++ 2010
I had a single C++ project in my solution which used boost and worked perfectly.
I then decided to convert this project into a static library and create a new project which depends on this static library.
Now, my converted static library builds without errors and warnings (compiler and linker) but the new project compiles but does not link.
I am getting:
1>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-1_45.lib'
As a test I added the full directory path to the linker options for this library... and then it complained about
1>LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc100-mt-1_45.lib'
I have now added complete paths to all the libraries and it now builds and run.
I am not happy with this solution because:
- I don't want users of the library to have to worry about linking in boost.
- It is messy
I know an answer would be to create a DLL but is there a way to do this statically and keep the linking at my static library level.
Thanks :)
Edit:
If I tell the .exe linker to ignore the boost libs explicitly then it all is ok except the .exe should not have to worry about boost at all.
/NODEFAULTLIB:"libboost_thread-vc100-mt-1_45.lib" /NODEFAULTLIB:"libboost_date_time-vc100-mt-1_45.lib"
Apparently you don't need the .libs, as your exe also links without them. You seem to be using boost header-only methods and classes. So just tell boost to disable auto linking by defining the preprocessor symbol BOOST_ALL_NO_LIB in your project.
If you want to make your .lib unnecessary big by including all of boost, this question seems to hold an answer (which I never really tried myself): Linking static libraries to other static libraries
这篇关于如何在依赖静态链接库加速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!