最近在学习如何在Ubuntu中搭建C++的开发环境,为了方便开发环境的移植,我用到了anaconda虚拟环境。本文主要介绍如何利用在Ubuntu下利用Anaconda、Vscode来开发C++,以调用anaconda虚拟环境中的opencv库为例子。
1、这是我Ubuntu系统下anaconda虚拟环境中安装的所有库,用到的有Cmake、Opencv。在终端中使用conda list查看虚拟环境中安装的库。
2、我的文件目录如下:
其中:CMakeLists.txt文件:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage main.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
其中,main.cpp文件:
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv )
{
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );