2015-04-19 137 views
1

当包括头在CMake的项目中使用ttmath与Visual Studio编译2013 64位编译

#include "ttmath/ttmath.h" 

作为ttmath's web page(其中文库包含在文件夹ttmath在项目文件夹中)所描述的,我得到了一些编译器错误的类似以下内容:

main.cpp.obj:-1: error: LNK2019: unresolved external symbol ttmath_adc_x64 referenced in function "public: unsigned __int64 __cdecl ttmath::UInt<28>::Add(class ttmath::UInt<28> const &,unsigned __int64)" ([email protected][email protected][email protected]@[email protected]@[email protected][email protected]) 

我使用Qt Creator的3.3.1,其产生的CMakeLists.txt文件

project(my_project) 
cmake_minimum_required(VERSION 2.8) 
aux_source_directory(. SRC_LIST) 
add_executable(${PROJECT_NAME} ${SRC_LIST}) 

回答

1

here所述,问题在于Visual Studio 64位不支持汇编代码文件ttmathuint_x86_64_msvc.asm的内联。因此,选择通过包括ttmath.h之前加入

#define TTMATH_NOASM 1 

  1. 禁用组件。这在性能上将花费大约两倍。

  2. 装配并包括手动文件:

    • 执行命令"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\ml64.exe" /c ttmathuint_x86_64_msvc.asm(所述ttmath文件夹中)。

    • add_executable(${PROJECT_NAME} ${SRC_LIST} ttmath/ttmathuint_x86_64_msvc.obj)

替换 CMakeLists.txt最后一行包含在编译的目标文件