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/ -