QT进行libtorch开发,用到了C++的numpy库numcpp和boost,现记录下其下载配置流程。
一、下载numcpp、boost
numcpp项目:https://github.com/dpilger26/NumCpp
boost安装包:https://www.boost.org/users/history/version_1_67_0.html
二、下载配置boost
1)进入下载网站,下载二进制文件
2)点击Windows Binaries后下载下图exe(boost_1_67_0-msvc-14.1-64.exe)
3)默认路径安装,安装完后得到库文件
4)Vs2017配置boost库
VS属性页里,C/C++ - 常规,附加包含目录C:\local\boost_1_67_0(对应到自己的安装路径)
链接器-常规,添加库目录C:\local\boost_1_67_0\libs
点击应用
5)测试boost
主程序中添加如下代码:
#include<iostream>
#include<stdio.h>
#include<boost/version.hpp> //包含boost头文件
#include<boost/config.hpp>
int main() {
using namespace std;
cout << BOOST_VERSION << endl;
cout << BOOST_LIB_VERSION << endl;
cout << BOOST_PLATFORM << endl;
cout << BOOST_COMPILER << endl;
cout << BOOST_STDLIB << endl;
system("pause");
return 0;
}
运行得到下图,boost配置成功
三、编译numcpp
1)管理员打开PowerShell中进入NumCpp的文件目录,输入以下命令:
cd E:/download/NumCpp-master/NumCpp-master
2)NumCpp工程目录下手动建立一个build文件夹:
3)输入下面命令
cd build
cmake ..
编译完成后输入下面cmake命令
cmake --build . --target install
4)NumCpp编译完成,编译得到的文件默认在C:\Program Files (x86)\NumCpp下,得到相应的文件**(注:Program Files文件夹名有空格可能导致之后QT添加库失败,建议复制到其他文件夹)**
5)NumCpp配置
VS属性页里,VC++目录,包含目录添加C:\Program Files (x86)\NumCpp
点击应用
6)测试
VS主函数里输入
#include "NumCpp.hpp"
#include <cstdlib>
#include <iostream>
int main()
{
auto a = nc::eye<double>(4);
std::cout << a;
return EXIT_SUCCESS;
}
编译运行得到如下结果,说明NumCpp配置成功