qmake
1.错误提示:using directive refers to implicitly-defined namespace ‘std’
#include<string>
using namespace std;#警告
有人说添加任何标准头文件,可我已经添加过了
下面我打印一个词
std::cout << "giao" << std::endl;
报错为:
no type named 'cout' in namespace 'std'
还有与之关联的错误提示为:
use of undeclared identifier std
查了很多资料没找到解决方式,后来经过自己摸索,应该是我的代码没有写在正确的位置。
std::cout << "Hello World!" << std::endl;应该放在类里面,我之前是直接在类外打印
正确代码示例如下
#include "crnn.h"
#include<string>
#include <iostream>
crnn::crnn()
{
std::cout << "Hello World!" << std::endl;
}
2.no template named “vector
#include <vector>
vector<void *>
解决方式:在vector前加上std::
编译时
1.no member named logger in namespace nvinfer1
这个应该和是否导入NvInfer头文件有关,我这里已经导入了,但还是报错,是因为在NvInfer头文件导入其他文件时出错,如下图
#include <NvInfer.h>
所以归根揭底还是.pro里面的库路径问题。
解决方式:
在终端搜索文件的位置,locate NvInferRuntime,找到路径后添加到.pro文件里。
添加路径
INCLUDEPATH += /home/tensorrt_tar/TensorRT-6.0.1.5/include
2.undefined reference to png_creat_read_struct@PNG16_0
......
解决方式:在.pro文件里添加libpng16.so路径
LIBS += /home/.conda/envs/pytorch/lib/libpng16.so
3.undefined reference to `jas_stream_close'
libpng16.so.16: undefined reference to `inflateValidate@ZLIB_1.2.9'
......
4.main.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
解决方式:https://blog.csdn.net/wangyjfrecky/article/details/80760093
运行时
1.error while loading shared libraries: libopencv_core.so.3.4: cannot open shared object file: No such file or directory (其他文件原理类似)
原因分析:编译时和运行时调库的方式不同,所以可能编译时没出现文件搜索错误,运行时却出现。
http://blog.sina.com.cn/s/blog_7137890701013rth.html这篇文章写的不错,可以参考下。
sudo vim /etc/ld.so.conf
#添加文件路径
include /etc/ld.so.conf.d/*.con
/home/Downloads/cuda/lib64
sudo ldconfig
2.second parameter of 'main' (argument array) must be of type 'char
3./usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.#error This file requires compiler and library support
原因分析:尝试了网上几乎所有的办法都不行,此外,我发现我的其他工程里可以正常使用c++11,但是当前这个工程就不能用,真的很离谱!搞了三天没解决!!!
4.libmyplugins.so: error adding symbols: File in wrong format