在Linux,Windows和Mac三大系统下编译Boost库

2014-09-30更

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

Check:
Project Properties -> Configuration Properties -> Linker -> Command line.

"Additional Options" should NOT contain /machine:X86

I have such key, generated by CMake output: CMake generated x86 project, then I added x64 platform via Configuration Manager in Visual Studio 2010 - everything was updated fine except linker command line, specified /machine:X86 separately.



1. 起因

需要编译bgslibrary。用到了OpenCV。为了跨平台遍历文件,我用了boost filesystem.

Boost 库使用Boost.Build作为跨平台编译工具。也就相当于CMake?

2. Linux

照基本教程,没有任何问题

Getting Started on Unix variants (e.g. Linux, MacOS)

3. Windows

首先,boost default build with shared library output., from Linker error LNK1104 with 'libboost_filesystem-vc100-mt-s-1_49.lib'

而bgslibrary自带的VS. project 默认静态连接 (/MT 选项)

其次,改成/MD后还是有unresovled reference 错误。怀疑是64位的问题。

用 b2 architecture=x86 address-model=64 stage 重编译一遍,解决!!

结论: Windows下Boost 默认编译32位的动态链接库版本

4. Mac

Mac ML 包括了两个标准C++库: libstdc++(GNU C)和libc++(clang)。MacPorts中编译的boost和OpenCV都默认连接libstdc++

最后编译成功的命令行

./bootstrap.sh --with-toolset=clang --prefix=./build-boost155/
./b2 --build-dir=`pwd`/build-boost155/build/ -

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值