I am trying to run some code from my university, but when I do "cmake .." inside "build" I get the following error:
CMake Error: The following variables are used in this project, but
they are set to NOTFOUND. Please set them or make sure they are set
and tested correctly in the CMake files: iceutil_lib
linked by target "cppgui" in directory /Users/alej/Desktop/project1
linked by target "project1" in directory /Users/alej/Desktop/project1
-- Configuring incomplete, errors occurred!
Any of my friends are getting errors, can you help me?
CMake tries to find all the libraries necessary to create the library or executable you are trying to build from the code from your university.
The found paths to those libraries are stored in special variables in CMake. By default, those variables carry the value <Library-Name>-NOTFOUND. This NOTFOUND flag is what makes CMake prompt the error message.
In general there are two possible reasons, why CMake can not find the library for you:
The library is not installed on your system
The library is installed somewhere CMake did not search for it. In this case you can help CMake by setting the library installation path into the respective CMake variables. To do this, open the file CMakeCache.txt with a text editor and search for ICEUTIL_LIB. Replace the blabla-NOTFOUND value with the actual (absolute) path of the library. There might be other variables with the ICEUTIL prefix. One of them might be named like ICEUTIL_HEADERS or ICEUTIL_INCLUDE_DIR. Replace the value of this one with the absolute path of where the .h files for ICEUTIL are found. If the include path is not set, CMake might run fine without errors, but later you will run into compiler errors saying include file not found.
Related
I have recently installed CMake in order to write code to make use of Libbitcoin in C++ but I am having a hard time, I was trying to build the example code on GitHub here. And it haters been going terribly. I can't manage to link the library right in CMake, here is my code. I read and people were saying that I should try Autoconf but I have no idea how to even start that as I know nothing about Autoconf. I have CMake 3.16, and installed Libbitcoin with brew but alias were made in /usr/local/include for the library, I am on Mac OS X 10.15. The CMake runs fine but when running "make", it responds with:
Scanning dependencies of target CreateAddr
main.cxx:1:10: fatal error: bitcoin/bitcoin.hpp: No such file or directory
1 | #include <bitcoin/bitcoin.hpp>
| ^~~~~~~~~~~~~~~~~~~~~
Here is my CMake text:
Please all help is appreciated I am beyond lost.
It is hard to be sure without knowing the specifics of your installation, but it appears that your include directory paths may be overlapping with what is specified for the header in main.cxx. The include_directories() call tells the compiler to include headers from this directory:
/usr/local/include/bitcoin
Then, in main.cxx, you're including the file with bitcoin/bitcoin.hpp. Combining these suggests the file is located here:
/usr/local/include/bitcoin/bitcoin/bitcoin.hpp
The error states the header could not be found, so perhaps you meant to locate it here:
/usr/local/include/bitcoin/bitcoin.hpp
In that case, just remove the relative directory path from the main.cxx file, like this:
#include <bitcoin.hpp>
Also, you want to link to your libbitcoin library correctly. Using link_directories() is not recommended. Instead, you can specify the full path to your libbitcoin library directly in the call to target_link_libraries(). The library may not be located in /usr/local/include/bitcoin. With these changes, the last few lines in your CMake would look something more like this:
include_directories(/usr/local/include/bitcoin)
add_executable(CreateAddr main.cxx)
target_link_libraries(CreateAddr PUBLIC /your/path/to/libs/libbitcoin.so)
I am trying to compile this project: https://github.com/computationalpathologygroup/ASAP.git from source.
Pugixml is a dependency
I have built pugixml from source and set PugiXML_DIR and PUGIXML_INCLUDE_DIR And it still gives me error: "CMake Error: The following variables are used in this project, but they are set to NOTFOUND."
Things I have tried:
I am doing this on windows, using cmake 3.14 and visual studio 2017.
I have successfully built pugixml from source and included the .lib file as well
I have tried including and excluding combinations of PUGIXML_INCLUDE_DIR, PUGIXML_LIBRARY, PugiXML_DIR.
This is the error I get:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
cpp/ASAP/annotation/PUGIXML_INCLUDE_DIR
used as include directory in directory
/cpp/ASAP/annotation
cpp/ASAP/multiresolutionimageinterface/PUGIXML_INCLUDE_DIR
used as include directory in directory cpp/ASAP/multiresolutionimageinterface
Other information: setting PugiXML_DIR is mandatory, and the cmake looks for a file named "pugixml-config.cmake" in that directory. And the config cmake file is supposed to point to compiled lib file. But when it wasn't able to find, I simply copied the lib file I compiled to the location pugixml-config.cmake was pointing.
In ASAP versions before 4.04.2019 they play dirty games with extracting include directory from the IMPORTED target. annotation/CMakeLists.txt:30:
get_target_property(PUGIXML_INCLUDE_DIR pugixml INTERFACE_INCLUDE_DIRECTORIES)
In some cases this results in setting PUGIXML_INCLUDE_DIR variable to "-NOTFOUND", thus you got corresponded error message from CMake.
In commit 36d8bd75 they add FindPugiXML.cmake script, which handle find_package(PugiXML) call instead of configuration script shipped with PugiXML. In that find script they obtain include directory with find_path, which looks more natually:
find_path(PugiXML_INCLUDE_DIR pugixml.hpp)
Because in newer ASAP versions the configuration script (pugixml-config.cmake), shipped with PugiXML, is no longer used, one cannot hint about PugiXML location with PugiXML_DIR or PugiXML_ROOT. In case PugiXML is installed into non-system-default location, one may simply set PugiXML_INCLUDE_DIR variable to the PugiXML include directory.
Short version (TL;DR)
Using CMake with the PkgConfig module I try to print all the include directories for a library I need for my project, let's call it thelibrary. I do this by printing the value of the THELIBRARY_INCLUDE_DIRS variable. The list of include directories is printed, but one directory is missing.
This really surprised it, as if I type the following on a terminal:
pkg-config thelibrary --cflags
then all the include directories are printed, including the one missing from THELIBRARY_INCLUDE_DIRS.
The same happens if I try to print the value of THELIBRARY_CFLAGS.
How is this possible? Where is the mistake? (Hoping it is a mistake of mine)
Details
Context
I am working on a C++ Cmake project which is compiled correctly under Mac OS but not under Linux (Ubuntu), and when investigating on the possible reasons I found the issue below.
Problem
I included the PkgConfig module in file CMakeLists.txt by writing:
find_package(PkgConfig REQUIRED)
After that, in order to use the library, I set the PKG_CONFIG_PATH environment variable by writing:
set(ENV{PKG_CONFIG_PATH} "/usr/local/opt/thelibrary/pkgconfig:$ENV{PKG_CONFIG_PATH}")
Finally, I put this instruction to search the library.
pkg_check_modules(THELIBRARY thelibrary)
Finally, in order to debug, I have tried to print the list of included directories by writing:
MESSAGE( STATUS "THELIBRARY DIRS: " ${THELIBRARY_INCLUDE_DIRS} )
The problem is, it worked, in fact it printed a list of include directories, but the problem is that the most important one is missing. In fact, the output is something like:
/opt/auxlib1/include/opt/auxlib2/include ...
where auxlib1, auxlib2 etc. are auxiliary include directories I need to compile.
But I also expected the dir /opt/thelibrary/include in output, which is printed if I use the pkg-config command on the terminal as said at the beginning. How is it possible that only that directory is not printed?
Thanks to the suggestion by Tsyvarev (deleting CMakeCache.txt), I understood what the cause was, and since this may happen to other people, I hope this explanation helps.
The reason why the directory /opt/thelibrary/include wasn't appearing in THELIBRARY_INCLUDE_DIRS is that file CMakeCache.txt contained information about a previous version of the library, whose header files were installed in a directory with a slightly different name, which was removed when that previous version was uninstalled.
Since that directory does not exist anymore, then it doesn't appear in THELIBRARY_INCLUDE_DIRS, and the new directory does not appear simply because the file CmakeCache.txt was still pointing to the previous version.
Solution: delete CmakeCache.txt and re-run cmake.
I am trying to build a trivial proof of concept project using CMake, and I am rapidly getting tired of it - to the point that I think it may have been a better idea to handcraft my own damn Makefile.
I have a directory structure that looks something like this:
project:
/extproj
/src/file.cpp
/include/file1.h
My CMakeLists.txt file contains the following section, which I, having read the CMake documentation, rather naively believed, will be specifying the include directories for the project:
INCLUDE_DIRECTORIES (include/
extproj/sdk/math/linearalg/
extproj/sdk/math/nonlinearsolvers/
)
I am trying to build it using the following command
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${ALL_SOURCES}
Where ${ALL_SOURCES} is a list variable that contains all the C++ files I need to compile. I have verified that this variable contains the correct files.
I can't however, for the life of me, work out what on earth is being passed to the compiler as the include directories.
I searched online, and so a post that recommended using get_directory_properties. I tried that and of course CMake immediately failed to generate the Makefile and complained:
Unknown CMake command "get_directory_properties".
When I create a Makefile and run make on it, the compiler barfs immediately, with the error message:
/path/to/project/src/file1.cpp:1:10: fatal error: 'file1.h' file not
found
Is there ANY WAY, I can find out what on earth is being used as the include paths being passed to my compiler?
I believe the correct way to compile the source files is using
add_executable(executableName ${SRCS}. Then the directories added using include_directories(...) get passed to the compiler automatically.
If you are using a custom command to compile you need to change your CMakeLists.txt file.
set(MY_INCLUDE_DIRS_FLAGS "-Iinclude/ -Iextproj/sdk/math/linearalg/ -Iextproj/sdk/mat/nonlinearsolvers/")
set(MY_COMPILE_COMMAND ${CMAKE_CXX_COMPILER} ${MY_INCLUDE_DIRS_FLAGS} ${CMAKE_CXX_FLAGS} ${ALL_SOURCES}
I have checked out a version of project from SVN. Below are the different kinds of errors I got while trying to CMAKE a project from SVN. Could it be that some of the files are not checked out? Please, go through the three kinds of errors and help me out with it.
==================Type 1==================================
CMake Error at CMakeLists.txt:184 (add_subdirectory):
add_subdirectory given source "google/gmock" which is not an existing
directory.
==================Type 2==================================
Subversion executable was not found.
CMake Error at CMakeLists.txt:14 (UpLinqSVN_WC_INFO):
Unknown CMake command "UpLinqSVN_WC_INFO".
Call Stack (most recent call first):
CMakeLists.txt:207 (CreateVersionInfo)
========================TYPE 3==========================================
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FFMPEG_AVCODEC_LIB
linked by target "UpLinq" in directory C:/Users/Krishna/Desktop/2.5/GUI
FFMPEG_AVCORE_LIB
linked by target "UpLinq" in directory C:/Users/Krishna/Desktop/2.5/GUI
FFMPEG_AVDEVICE_LIB
linked by target "UpLinq" in directory C:/Users/Krishna/Desktop/2.5/GUI
Configuring incomplete, errors occurred!
Error 1 indeed indicates that the CMakeLists.txt expected there to be a directory called google/gmock (relative to the CMakeLists.txt which is calling add_subdirectory at line 184).
Without more info, there's no way to tell if this is an error in the CMakeLists file or in the repository.
The first part of error 2 (can't find Subversion exe) looks like a custom error message. It may be looking for a ".svn" folder in the project root, and assuming that Subversion is available. Presumably it then looks for the Subversion exe and fails to find it (not in path maybe?)
The second part of error2 (unknown CMake command) is saying that at line 14 of CMakeLists.txt, there's a command called UpLinqSVN_WC_INFO being invoked. It doesn't recognise this as a valid command, which probably means that it's defined as a function or macro in another CMake file somewhere. It would need to be defined before it's invoked at line 14. It could be that the CMakeLists.txt you're executing is expected to be run as part of a larger build, which would define this function before starting on your CMakeLists.txt.
Error 3 is saying that there's a CMake target called "UpLinq" (an exe or lib) which has a dependency on ${FFMPEG_AVCODEC_LIB}. At some point, there's probably been a find_library call looking for the avcodec library which has also failed. The result of the search is held in the variable FFMPEG_AVCODEC, and it shows that ${FFMPEG_AVCODEC} has a value of FFMPEG_AVCODEC-NOTFOUND.
If you need more help than this, you'll need to put up a copy of the relevant parts of the CMakeLists files involved, and a bit more info about your environment / directory structures.