前言

在linux系统运行程序,小鹅知道的有3种编译方式,一种是直接命令行编译,一种是使用Cmake,一种是使用脚本文件(*.sh)。本文介绍的是使用命令行编译。

使用过程

注意不同系统的编译器版本可能有所不同,gcc是C语言的编译器,g++是c++的编译器。

1. 使用Jsoncpp开源库

g++ test.cpp -o test -ljsoncpp

2. 使用opencv开源库

 g++ test.cpp -o test `pkg-config --cflags --libs opencv` 

注意,标点符号是反单引号(TAB键上方最左边的按键)而不是单引号。

3.使用c++新特性

 g++ test.cpp -o test -std=c++11

或者

 g++ test.cpp -o test -ljsoncpp `pkg-config -std=gnu++11

4. 使用多个库

 g++ test.cpp -o test -ljsoncpp `pkg-config --cflags --libs opencv` -std=c++11

运行程序

./test

参考

1.c++新特性在linux终端中的编译运行

相关文章:

  • 2021-11-01
  • 2022-12-23
  • 2021-11-01
  • 2021-09-28
  • 2021-06-30
  • 2022-01-22
  • 2021-11-25
  • 2021-12-22
猜你喜欢
  • 2021-06-22
  • 2021-07-13
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2021-11-03
相关资源
相似解决方案