gcc 编译opencv应用程序的命令

gcc Test.c -o Test `pkg-config --cflags --libs opencv`
./Test baboon.jpg

 这里接受一位同行提示,gcc直接编译cpp文件会有错误提示

类似提示如下,模拟在ubuntu 2020.04版本

usr/bin/ld: /tmp/cc5jklBT.o: in function `main':
helloworld.cpp:(.text+0x1d): undefined reference to `std::cout'
/usr/bin/ld: helloworld.cpp:(.text+0x22): undefined reference to `std::basic_ostream >& std::operator<<  >(std::basic_ostream >&, char const*)'
/usr/bin/ld: helloworld.cpp:(.text+0x2c): undefined reference to `std::basic_ostream >& std::endl >(std::basic_ostream >&)'
/usr/bin/ld: helloworld.cpp:(.text+0x37): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/usr/bin/ld: /tmp/cc5jklBT.o: in function `__static_initialization_and_destruction_0(int, int)':
helloworld.cpp:(.text+0x6b): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: helloworld.cpp:(.text+0x80): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status

修改为如下

gcc Test.c -o Test `pkg-config --cflags --libs opencv` -lstdc++
./Test baboon.jpg

 

你可能感兴趣的:(#,C++,Primer(第五版),视觉,#,opencv)