OpenCV with gcc and CMake: Cannot find source file [closed]
Hello I installed OpenCV in Fedora 22 using this tutorial.
Now I'm following this example but CMake cannot find source file.
The CMakeLists.txt and DisplayImage.cpp are in the same directory.
[doliveira@localhost OpenCV_tests]$ cmake .
-- The C compiler identification is GNU 5.1.1
-- The CXX compiler identification is GNU 5.1.1
-- Check for working C compiler: /usr/lib64/ccache/cc
-- Check for working C compiler: /usr/lib64/ccache/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++
-- Check for working CXX compiler: /usr/lib64/ccache/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:5 (add_executable):
Cannot find source file:
DisplayImage.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
-- Generating done
-- Generating done
-- Build files have been written to: /home/doliveira/Documentos/OpenCV_tests
There is some problem with CMake or OpenCV instalation?
Some info: cmake version 3.2.2 and OpenCV 3.0.0
Thank you
It seems that's not a problem with opencv install but with file DisplayImage.cpp. Are you sure of file name ( uppercase , lowercase)?
Yes, the name are the same. I just copied it from the tutorial
My CMakeLists.txt
May be I'm wrong but I still think your filename is wrong not your CMakefLists.txt. you can try like this
I changed the CMakeLists.txt with your code and there is the result:
What's that meaning?
The folder where I execute
cmake .
is thatIt means that cmake cannot find any source file in folder. You're using linux and called cmake from a terminal I think. So simple way is :
So nowmay be I'm wrong your name file is good but CMakeLists.txt is not in same directory than sourcefile or you don't call cmake from directory where are CMakeLists.txt and DisplayImage.cpp
I call cmake in the same directory where are CMakeLists.txt and DisplayImage.cpp.
How can I sprecifie the directory of DisplayImage.cpp in the CMakeLists.txt?
It's really weird.
yes it's possible go to cmake site. But you can specify source_dir in command line
Now I still think you've got problem with file name. Have you copy cmakelist from web? May be you've got some invisible character. When I select this line
I have got a white character after cpp Try to rename DisplayImage.cpp in Displayimage.cc...
The problem was the name!
The white character after the .cpp.
I will never see that detail.
Thank you @LBerger for your time!
@sturkmen Yes, I did but didn't work to
ok. anyhow you got solution i think. while i was writing my comment you post stating the problem was about filename.