OpenCV, MinGW and Cuda

Hello! I am trying to write a cross platform program for both linux and windows.

Currently I am having trouble getting cuda to work with mingw. From what I understand, cuda is only intended to work with visual studio. So I compiled opencv 3.4.0 with visual studio 2017, and it appears to work. Now, the problem is, as I’m sure its obvious, visual c++ isn’t the same thing as GNC C++, thus causing my issues. When I run through the cmake gui (to build opencv), it tells me that cuda isn’t supported for MinGW, because of course it isn’t.

What can I do to get GPU functionality in OpenCV with MinGW? Is there a way to generate the appropriate libs for MinGW while compiling with Visual Studio. Could I just simply copy whatever .lib’s (or would they be .a’s?) I need from a linux build (I would think not, but its worth asking)?

How have other people handled this problem?

the best way to write portable CUDA program is to compile it with MSVC on Windows, GCC on Linux, and use only common subset of their features. Probably, you don’t even know MSVC/GNU specific extensions, so you will do it automatically. And stick with reasonable version of C++, probably C++14 will be fine

If I understand you correctly, I ought to be able to compile the same main.cpp in windows (via visual studio) and linux (via eclipse or c::b) with little to no headache? I didn’t think it was that easy. I’ll give it a shot!

It might be advantagous to use CMAKE, so that you have only a single ‘Project’ file.

See https://devblogs.nvidia.com/building-cuda-applications-cmake/