there occurs an error: reference to ‘DataType’ is ambiguous when I compile my own inference project with command "make"

fcn_inference.cpp:60:33: error: reference to ‘DataType’ is ambiguous
In file included from /usr/include/opencv2/core.hpp:56:0,
from /usr/include/opencv2/opencv.hpp:52,
from fcn_inference.cpp:19:
/usr/include/opencv2/core/traits.hpp:106:30: note: candidates are: template class cv::DataType
template class DataType
In file included from fcn_inference.cpp:13:0:
…/…/include/NvInfer.h:108:12: note: enum class nvinfer1::DataType
enum class DataType : int


Could you share more information about this issue?
For example, which source do you use?

From the log, guess that issue is from different TensorRT version.
Please remember that TensorRT API has slightly changed from v1.0 to v2.1.

You can get some information from Jetson_inference.



742824147, did you manage to solve that problem? I am facing the same issue.


Hi damilola_sleshinloye, the error is referring to that both OpenCV and TensorRT define a “DataType” type, and the compiler is unsure which type is being referred to from the source. Please prefix your usage of DataType with nvinfer1 namespace (nvinfer1::DataType), does the error go away?

Otherwise you may want to include OpenCV separately or in a different namespace, or change the order in which you perform the includes.

1 Like


dusty_nv, thanks a lot. The error went away, sorry for the noob question :).