Failure to compile with CUDA 7.0 + clang on OSX (Bug #4125)
Description
When trying to compile OpenCV 3.0 (fresh github clone) on OSX with CUDA 7.0 (and clang, which is the default on OSX), I get the following error:
/Users/kevin/src/opencv/opencv-git/modules/core/include/opencv2/core/cvstd.hpp(1048): error: "swap" is not a class or function template name in the current scope
Compiling is fixed by the following diff:
diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp index 0da8faf..8c2e96f 100644 --- a/modules/core/include/opencv2/core/cvstd.hpp +++ b/modules/core/include/opencv2/core/cvstd.hpp @@ -1040,16 +1040,15 @@ static inline bool operator>= (const String& lhs, const char* rhs) { return lh #ifndef OPENCV_NOSTL_TRANSITIONAL namespace std +{ + static inline void swap(cv::String& a, cv::String& b) { a.swap(b); } +} #else namespace cv -#endif { - template<> inline - void swap<cv::String>(cv::String& a, cv::String& b) - { - a.swap(b); - } + template<> inline void swap<cv::String>(cv::String& a, cv::String& b) { a.swap(b); } } +#endif #include "opencv2/core/ptr.inl.hpp"
If this fix will work, I can submit a PR, but I highly suspect there is a better fix.
Associated revisions
Merge pull request #4125 from ruslo:interface.include.dirs
History
Updated by Vladislav Vinogradov about 10 years ago
Hello Kevin,
Thank you for you fix!
Please submit a PR with your patch, so it can be tested by buildbot on different configurations.
I think you can use
static inline void swap(cv::String& a, cv::String& b) { a.swap(b); }
implementation for both cases (cv
and std
).
But it will be better to ask authors of opencv2/core/cvstd.hpp
header in GitHub Pull Request.
- Status changed from New to Open
- Assignee changed from Vladislav Vinogradov to Kevin Squire
Updated by Maksim Shabunin almost 10 years ago
- Target version changed from 3.0-beta to 3.0
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4908