跳转到内容
新建笔记

(前置定义)error: '__gthread_mutex_t' does not name a type 121 | __gthread_mutex_t _M_mutex;

问题:

process.h
#ifndef PROCESS_H
#define PROCESS_H
#include <opencv2/opencv.hpp>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
void test(void);
namespace prc
{
class PROCESS
{
public:
std::string orgName;
std::string _outPath;
const std::vector<float> mean{ 0.485f, 0.456f, 0.406f };
const std::vector<float> stddev{ 0.229f, 0.224f, 0.225f };
PROCESS(const std::string& outpath) :_outPath(outpath) {};
std::unique_ptr<float> preprocess(const std::string& filename) const;
std::unique_ptr<float> postprocess() const;
protected:
cv::Mat org;
cv::Mat inp;
cv::Mat out;
private:
cv::Mat __read(const std::string& name) const;
};
}; // namespace prc
#endif // PROCESS_H
mian.h
#pragma once
#include <string>
#include <fstream>
#include "NvInfer.h"
#include "cuda_runtime_api.h"
#include "NvInferPlugin.h"
#include "logging.h"
#include "process.h"
main.cpp
#include "main.h"
const std::string outpath = "F:/code/projects/threadSeg_Yolo_RT/assets/out";
prc::PROCESS yolo_process(outpath);
int main()
{
return 0;
}

这样的话会报错 ,是关于关于opencv的。

error: ‘__gthread_mutex_t’ does not name a type 121 | __gthread_mutex_t _M_mutex;

解决方法:

main.h
//mian.h
#pragma once
#include <opencv2/opencv.hpp> // 这里需要添加opencv头文件
#include <string>
#include <fstream>
#include "NvInfer.h"
#include "cuda_runtime_api.h"
#include "NvInferPlugin.h"
#include "logging.h"
#include "process.h"

c++ class “xxxx“ does not name a type是怎么一回事_c++ does not name a type-CSDN博客


来源:CSDN 原文,首次发布于 2024-06-16。