No ".cmake" file in home directory - c++

I've been trying to compile a C++ project that links to the Caffe deep learning library. One piece of advice I received when using cmake was that the CMAKE_MODULES_PATH variable gets updated when I've compiled the library before so I can refer to Caffe in future cmake builds. This is supposed to be stored here:
~/.cmake/
However when I search for hidden items in my home directory, I can't find it anywhere. I'm running cmake 2.8 - is this a feature of another version or am I missing something?

CMake doesn't create any such directory. Nor does CMake search that location by default. You can create it yourself if you like, and add it to CMAKE_MODULE_PATH.

Related

CMake not finding package that is clearly there

I am trying to build a project via cmake in qtcreator, but am having trouble with the external package dependencies.
There have been several packages that it could not find, but I added symlinks to the actual file locations into the directory cmake was looking in, afetr which they worked fine.
However, this one library libopencv_viz.so.3.2.0 isn't cooperationg with me. I added the symlink and visually verified that the file/link is in the correct location, but cmake is still telling me that it cannot find the file, and I have no clue how to solve this. As I stated in a prior post, I am still just learning cmake right now, so I have absolutely no clue why it would not be able to find a package that is verifiably in the correct location.
CMake Error at /usr/share/OpenCV/OpenCVModules.cmake:192 (message):
The imported target "opencv_viz" references the file
"/usr/lib/x86_64-linux-gnu/libopencv_viz.so.3.2.0"
but this file does not exist. Possible reasons include:
The file was deleted, renamed, or moved to another location.
An install or uninstall procedure did not complete successfully.
The installation package was faulty and contained
"/usr/share/OpenCV/OpenCVModules.cmake"
but not all the files it references.
Creating symlinks by hand suggests you have an incomplete installation. Clean up your manual symlinks, and figure out what's wrong with your installation.
It is normal on Linux that the .so.x.y.z with the full numeric version is the runtime library. That is, the file that is required for applications to run. The version number ensures that the application loads the same library that it was built against.
The .so symlink to .so.x.y.z is for the build chain. When the compiler (linker, really) goes to link against libopencv_viz, it will search for libopencv_viz.so, resolve the symlink to versioned file, and link that.
Many distributions (including Ubuntu) separate the runtime libraries from the development components. My guess is that you've installed the package named libopencv-viz3.2, but not the one named libopencv-viz-dev.

Cannot point to DCMTKConfig.cmake

Using Windows 10, I want to configure the source of OpenSceneGraph via CMake to make it build-ready for Visual Studio. I also need some DCMTK functionalities, hence I want to link it.
OpenSceneGraph provides an attempt to link DCMTK in its CMakeLists.txt, but it fails (and since linking it is optional, configuration is finished nevertheless).
-- Trying to find DCMTK expecting DCMTKConfig.cmake
-- Trying to find DCMTK expecting DCMTKConfig.cmake - failed
-- Trying to find DCMTK relying on FindDCMTK.cmake
-- Please set DCMTK_DIR and re-run configure (missing: DCMTK_config_INCLUDE_DIR DCMTK_dcmdata_INCLUDE_DIR DCMTK_dcmimage_INCLUDE_DIR DCMTK_dcmimgle_INCLUDE_DIR DCMTK_dcmjpeg_INCLUDE_DIR DCMTK_dcmjpls_INCLUDE_DIR DCMTK_dcmnet_INCLUDE_DIR DCMTK_dcmpstat_INCLUDE_DIR DCMTK_dcmqrdb_INCLUDE_DIR DCMTK_dcmsign_INCLUDE_DIR DCMTK_dcmsr_INCLUDE_DIR DCMTK_dcmtls_INCLUDE_DIR DCMTK_ofstd_INCLUDE_DIR DCMTK_oflog_INCLUDE_DIR)
My DCMTK package does provide a DCMTKConfig.cmake file, and I've set a system environment variable DCMTK_DIR that points to its directory.
Researching the problem, I've found the article on FindDCMTK but I can't get any viable information out of it.
The directories for OpenSceneGraph and DCMTK are next to each other in a specified location.
How do I instruct CMake to find the configuration file of DCMTK?
As suggested by Tsyvarev in the comments above, I would also advise using the CMAKE Gui on Windows - when you attempt to configure, it should display everything it either set or changed with red highlights. Then you can manually edit the DCMTK related variables to point to the correct folders and/or files - you might be able to just edit the Root folders and hit configure again to let it populate based on root. When you are satisfied with the settings and not getting errors, then you can hit Generate to let it create the Visual Studio files.

Where is the lib folder (or its replacement) in the current OpenCV?

I'm following a book written for the older version of OpenCV (OpenCV 2 Computer Vision, by PACT) and it tells me to include the lib folder in my Visual Studio 2013 Property Manager when creating a new property sheet.
I don't see a directory called lib in the current GitHub version (opencv-master, which is OpenCV 3.1.x). Has this folder been replaced by something else?
I built OpenCV with cmake. I found a 4 year old unanswered question wherein someone was also looking for this folder. They tried building the library from another directory that no longer exists, but that didn't work for them anyway...
Another OpenCV user just told me that GitHub doesn't include the libraries, so you have to cmake them locally. I'm still not clear on where / how I can cmake them.
I realize the pre-built binaries have this, but I'm avoiding them because I need the SURF functions in opencv_contrib, so I needed to build it from source.
The pre-built binaries will have a library folder in the corresponding path
Local System Path(Opencv Folder)-> build->x64/x86->vc10/vc11/vc12->lib.
As you mentioned that you don't wish to use it then the only option left for you is to build it locally which is a much better option if you plan to use Opencv libraries for varied functions and projects as it resolves many build errors that you might face later.
I used the Cmake Graphical user interface to build opencv, following are the steps I followed to successfully build the libraries on my system .
So, you would need to create a new folder that will contain all
the Makefiles generated.
Please refer to this image for clearer understanding:
In GUI you define source directory path where OpenCVConfig.cmake is present, according to your image it's the
current folder in your image opencv-master.
Similarly, define the path to the new directory you created where all the build files would be stored.
Make sure to uncheck Build_Examples to avoid configuration errors.
Then click Configure at the bottom when configuring is done .(you may need to configure it twice)
After click the tab adjacent to configure, Generate to create the solution file.It will ask you for the compiler name
select the
compiler installed on your system from the list of choices. After
generation is done.
Go to this path Build_New_Directory(the directory you created) you will find OpenCV.sln build this project, it will take around 10-15 minutes depending on your processor, wait patiently .If you get a build error at this point don't invest your time in debugging on Visual Studio go back to Cmake GUi and configure it again and this time give the path to dependent libraries on your system that it could not find .Repeat the process it should be successfully build now.
After it is successfully build you can now locate the path of all opencv libraries build on your system as follows.
Build_New_Directory(the directory you created)->
install->x64->vc10(compiler I used)->lib.
As an update to Nikita's awnser:
There is a cmake build bug where the x64 folder will not be created if OpenCV_RUNTIME is not set. This will happen if you build an old OpenCV (e.g. <= 3.2.0) with a newer Visual Studio Version than was available at that time (e.g. Visual Studio 2017)
To fix this, add the correct MSVC_VERSION elseif-cases in both ./cmake/OpenCVDetectCXXCompiler.cmake and the ./cmake/templates/OpenCVConfig.root-WIN32.cmake.in (or ./cmake/OpenCVConfig.cmake in < v3.2.0) files:
[...]
elseif(MSVC_VERSION EQUAL 1900)
set(OpenCV_RUNTIME vc14)
# old version ends here with endif()
elseif(MSVC_VERSION GREATER 1909 AND MSVC_VERSION LESS 1920)
set(OpenCV_RUNTIME vc15)
elseif(MSVC_VERSION GREATER 1919 AND MSVC_VERSION LESS 1930)
set(OpenCV_RUNTIME vc16)
endif()
[...]

Issue with CLion and find_package: Generated CMake files are placed in some odd location

So basically I have the following setup:
A small test library called mylib with an according CMake file. The CMake file creates all the necessary information so that another project (which is going to be my binary) can use find_package to add the library. The library also has a install target.
A small binary called mybin again wih according CMake file which is depended on the mylib project. Using find_package I can add mylib either by specifying the location of the according myLibConfig.cmake (and myLibTargets.cmake etc.) files or by executing the install target of mylib and then letting CMake find the library itself.
Using CMake and XCode everything works like a charm. First, I configure and build the library. Second, I configure my binary project, specify the location of the library and then build it without any problems.
Now I want to do the same using CLion. My problem now is that CLion puts all the generated CMake file (which usually are placed in the build folder) in some cryptic location which can't be changed in the IDE. Now, when I want to build the mybin project I have to specify this cryptic location which seems kinda odd to me (especially because you have to find out first where CLion actually places those files).
So my question is: Is there a more convenient way to handle the described configuration? I guess this is more or less the standard use case which makes me wonder if I'm missing out on something. Being able to specify where CLion should put the generated CMake files would solve my problem I guess.
I know that i can install the library (using the install target) and then let CMake find it. The problem here is that CLion (to my understanding) doesn't support install targets and therefore I have to use (in my case) XCode to build and install the library first.
I was misunderstsanding the intention of find_package(as Tsyvarev pointed out). By using the solution proposed in this question I managed to add an install target to CLion which now allows me to conveniently build "mylib" and use it in the "mybin" project without having to configure anything manually.

Following a Lynda.com c++ tutorial and having problems setting up paths on Eclipse (OSX 10.9.3)

I am currently learning C++ using Lynda.com tutorials, I am a complete beginner and am following the tutorials on how to set up Eclipse on my Mac.
When I initially run the version-test.cpp program provided, it runs fine with the expected output (GCC version 4.2.1)
The tutorial requires my Mac to be running GCC version 4.7.0 or above and it explains how to upgrade GCC. The tutorial instructs me to save the updated GCC files within my home directory within the folder hpc-gcc and then follows on to explain the method to set my PATHs to find this folder.
Now when I run the version-test.cpp program it fails with the following error
dyld: Library not loaded: /usr/local/lib/libmpc.3.dylib
Referenced from: /Users/gary/hpc-gcc/bin/../libexec/gcc/x86_64-apple-darwin13.1.0/4.9.0/cc1plus
Reason: image not found
So from this message I can see that the system cannot find the required files within /usr/local/lib.
I am able to copy the files from hpc-gcc/bin to /usr/local/lib and have the program compile and run correctly but I am hoping to find out why Eclipse cannot read the required files directly from ~/hpc-gcc/bin
I have spent the last 2 hours searching forums and search engines for the answer but I am no further forward. I realise I can simply have the GCC files within /usr/local/lib and it will work but I want to understand where I am going wrong.
Solved.
You need to go into the properties of the Working folder (if you are following the lynda.com program you will understand the working folder) and under C/C++ Build -> Environment menu (Where we added in the LIBRARY_PATH, PATH, AND CPATH variables) and add in DYLD_LIBRARY_PATH with a value of ${HOME}/hpc-gcc/lib.
Remember the C/C++ Build "menus" are for build and debug, so the project is not able to find the library for the building process.
And you will be good to go.