Doing cmu15-445 recently,in ubuntu 20.04 - format

To meet the formatting requirements, I ran "make format" in the command line and got the following output.
can someone help me with the
FileNotFoundError: No such file or directory: ' CLANG_FORMAT_BIN-NOTFOUND'

Same problem. Check CMakeLists.txt and make sure clang-format and clang-tidy have correct version(8 or 12).
# clang-format
find_program(CLANG_FORMAT_BIN
NAMES clang-format clang-format-12
HINTS ${BUSTUB_CLANG_SEARCH_PATH})
if ("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND")
message(WARNING "BusTub/main couldn't find clang-format.")
else()
message(STATUS "BusTub/main found clang-format at ${CLANG_FORMAT_BIN}")
endif()
# clang-tidy
find_program(CLANG_TIDY_BIN
NAMES clang-tidy clang-tidy-12
HINTS ${BUSTUB_CLANG_SEARCH_PATH})
if ("${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
message(WARNING "BusTub/main couldn't find clang-tidy.")
else()
# Output compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
message(STATUS "BusTub/main found clang-tidy at ${CLANG_TIDY_BIN}")
endif()

Related

CMAKE 3.8, imported targets not available for Boost version

I'm on Windows 10 and got this error when generating solution using CMake-GUI:
CMake Warning at C:/Program Files/CMake/share/cmake-3.8/Modules/FindBoost.cmake:765 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.8/Modules/FindBoost.cmake:869 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/CMake/share/cmake-3.8/Modules/FindBoost.cmake:1472 (_Boost_MISSING_DEPENDENCIES)
I know it's been asked and answered here CMake finds Boost but the imported targets not available for Boost version
but the solution in there (upgrading CMake) doesn't work for me, still get the same error after upgrading from 3.7 to 3.8
Update
My boost version is 106300.
Content of CMakeList file is below:
# doc/CMakeLists.txt uses configure_file behavior from CMake 2.8
cmake_minimum_required(VERSION 2.8)
project(tpie)
include_directories(.)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
#### CONFIG.H Checks:
include(CheckIncludeFiles)
if(NOT WIN32)
add_definitions("-Wall -Wextra")
endif(NOT WIN32)
if(WIN32)
add_definitions("-DWIN32_LEAN_AND_MEAN /bigobj")
endif(WIN32)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
#### Dependencies
## Boost
set(Boost_ADDITIONAL_VERSIONS "1.40.0" "1.40" "1.41" "1.41.0" "1.42" "1.42.0" "1.43" "1.43.0" "1.44" "1.44.0" "1.45" "1.45.0")
set(Boost_USE_MULTITHREADED ON)
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
endif(WIN32)
find_package(Boost COMPONENTS date_time filesystem system REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories( ${Boost_LIBRARY_DIRS} )
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if(TPIE_FRACTIONDB_DIR_INL)
include_directories(${TPIE_FRACTIONDB_DIR_INL})
endif(TPIE_FRACTIONDB_DIR_INL)
check_include_files("unistd.h" TPIE_HAVE_UNISTD_H)
check_include_files("sys/unistd.h" TPIE_HAVE_SYS_UNISTD_H)
# Ryan Pavlik's Git revision description helper
# http://stackoverflow.com/a/4318642
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_COMMIT)
## Snappy
option(TPIE_USE_SNAPPY "Use Snappy, a fast compressor/decompressor" ON)
if(TPIE_USE_SNAPPY)
find_package(Snappy)
if(${Snappy_FOUND})
set(TPIE_HAS_SNAPPY ON)
include_directories(${Snappy_INCLUDE_DIR})
else(${Snappy_FOUND})
set(TPIE_HAS_SNAPPY OFF)
endif(${Snappy_FOUND})
endif(TPIE_USE_SNAPPY)
#### Installation paths
#Default paths
set(BIN_INSTALL_DIR bin)
set(LIB_INSTALL_DIR lib)
set(HEADERS_INSTALL_DIR include/tpie)
if (WIN32)
set(DOC_INSTALL_DIR doc)
else(WIN32)
set(DOC_INSTALL_DIR "share/doc/tpie")
endif(WIN32)
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if (CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} bt)
string(REGEX MATCH " -DNDEBUG " TPIE_NDEBUG " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${bt}} ")
else()
option(TPIE_NDEBUG "Disable debugging information" ON)
endif()
set(TPIE_S ${CMAKE_CURRENT_SOURCE_DIR})
set(TPIE_B ${CMAKE_CURRENT_BINARY_DIR})
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tpie/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/tpie/config.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tpie/config.h DESTINATION ${HEADERS_INSTALL_DIR})
add_subdirectory(tpie)
add_subdirectory(doc)
option(COMPILE_TEST "Compile test programs" ON)
option(TPL_LOGGING "Enable tpie logging." ON)
option(TPIE_DEPRECATED_WARNINGS "Enable warnings for deprecated classes, methods and typedefs" OFF)
option(TPIE_PARALLEL_SORT "Enable parallel quick sort implementation" ON)
if (COMPILE_TEST)
ENABLE_TESTING()
add_subdirectory(test)
add_subdirectory(apps)
endif (COMPILE_TEST)
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_CONTACT "rav#cs.au.dk")
set(CPACK_GENERATOR TGZ)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "TPIE")
set(CPACK_PACKAGE_VENDOR "The TPIE maintainers")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.md")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "TPIE ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
if(WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
#set(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\thomasmoelhave.github.com/tpie/")
set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\thomasmoelhave.github.com/tpie/")
set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
set(CPACK_NSIS_MODIFY_PATH ON)
list(APPEND CPACK_GENERATOR NSIS)
else(WIN32 AND NOT UNIX)
list(APPEND CPACK_GENERATOR DEB)
endif(WIN32 AND NOT UNIX)
install(DIRECTORY tpie
DESTINATION include
FILES_MATCHING REGEX "\\.h$|\\.inl$"
PATTERN "deadcode" EXCLUDE)
install(DIRECTORY share/tpie
DESTINATION share)
include(CPack)
Any other idea? tks
Your CMAKE is too old for the boost 1.63.
Reinstall a newer CMAKE or do this(according to FindBoost.cmake source code in cmake/share/cmake-3.9/Modules/FindBoost.cmake line 516):
Note: to add a new Boost release, run
% cmake -DBOOST_DIR=/path/to/boost/source -P Utilities/Scripts/BoostScanDeps.cmake
Or, Just modify that line from
elseif(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106300)
to
elseif(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106500)

CMake Error "No C++11 compiler available!" with MS VS 2015

I'm trying to get mlpack-2.0.1 to work on Visual Studio 14 2015 (I'm using Windows) but have had no success and I've been trying for hours but keep getting the same error: "No C++11 compiler available!" Additionally, I've read a handful of other similar issues on Stack Exchange and none have done the trick. I'm confused because I've been using VS 2015 for months without any errors. Is it possible I changed some compiler setting there and didn't even know it? Should I uninstall visual studio and reinstall it? I've downloaded CMake 3.5.2 and its directory is (the .exe is in the \bin subfolder):
C:\Program Files (x86)\CMake\
The CMakeLists.txt file for mlpack-2.0.1 is found in:
C:\Users\owner\Desktop\C++\
I've used the CMake GUI and command prompt to try to get this to work but have been unable to do the job. I'm not all that sophisticated with changing CMake code so any help would be appreciated. Does anyone know what to do?
You have problem with mlpack:
cmake_minimum_required(VERSION 2.8.5)
project(mlpack C CXX)
# Ensure that we have a C++11 compiler.
include(CMake/CXX11.cmake)
check_for_cxx11_compiler(HAS_CXX11)
if(NOT HAS_CXX11)
message(FATAL_ERROR "No C++11 compiler available!")
endif(NOT HAS_CXX11)
enable_cxx11()
especially with CMake/CXX11.cmake:
macro(check_for_cxx11_compiler _VAR)
message(STATUS "Checking for C++11 compiler")
set(${_VAR})
if((MSVC AND (MSVC10 OR MSVC11 OR MSVC12)) OR
(CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.6) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.1) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.0))
set(${_VAR} 1)
message(STATUS "Checking for C++11 compiler - available")
else()
message(STATUS "Checking for C++11 compiler - unavailable")
endif()
endmacro()
So you have to add MSVC14 to condition:
macro(check_for_cxx11_compiler _VAR)
message(STATUS "Checking for C++11 compiler")
set(${_VAR})
if((MSVC AND (MSVC10 OR MSVC11 OR MSVC12 OR MSVC13 OR MSVC14)) OR
(CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.6) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.1) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.0))
set(${_VAR} 1)
message(STATUS "Checking for C++11 compiler - available")
else()
message(STATUS "Checking for C++11 compiler - unavailable")
endif()
endmacro()
Try this.

CMAKE: how to include and link alternative libraries?

My project need four libraries including MPI, BOOST, VTK and SQLITE3. Since BOOST and SQLITE3 are too old, I installed new version of the two libraries and the old version are not uninstalled:
BOOST # alternative BOOST
|___include
|___lib
|
SQLITE # alternative SQLITE
|___bin
|___include
|___lib
|___share
|
Mypoject
|___src
| |___CMakeLists
| |___.cpp and .h file
|
|___CMakeLists
And I used FindSQLite3.cmake to find the alternative SQLite3:
# Look for the header file.
FIND_PATH(SQLITE3_INCLUDE_DIR sqlite3.h /export/home/hh/hh/sqlite/include)
# Look for the library.
FIND_LIBRARY(SQLITE3_LIBRARY sqlite3 /export/home/hh/hh/sqlite/lib)
# Handle the QUIETLY and REQUIRED arguments and set SQLITE3_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)
# Copy the results to the output variables.
IF(SQLITE3_FOUND)
SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY})
SET(SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
ELSE(SQLITE3_FOUND)
SET(SQLITE3_LIBRARIES)
SET(SQLITE3_INCLUDE_DIRS)
ENDIF(SQLITE3_FOUND)
MARK_AS_ADVANCED(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)
I am trying to link alternative libraries by following lines:
# CMake version
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET(VERSION 0.1)
SET(SOVERSION 1)
# searching ENV{PATH} to find mpicc and
# store the path of mpicc to MPI_INTEL_C
FIND_PATH(MPI_INTEL_C mpicc $ENV{PATH})
# searching ENV{PATH} to find mpicxx and
# store the path of mpicc to MPI_INTEL_CXX
FIND_PATH(MPI_INTEL_CXX mpicxx $ENV{PATH})
IF(MPI_INTEL_C AND MPI_INTEL_CXX)
MESSAGE(STATUS "Intel MPI compiler is used.")
# set C++ complier as mpicxx, and set C complier as mpicc
SET(CMAKE_CXX_COMPILER mpicxx)
SET(CMAKE_C_COMPILER mpicc)
ENDIF(MPI_INTEL_C AND MPI_INTEL_CXX)
find_package(VTK REQUIRED NO_MODULE)
IF(VTK_FOUND)
MESSAGE(STATUS "VTK IS USED")
include(${VTK_USE_FILE})
ELSE()
MESSAGE("VTK IS NOT FOUND")
ENDIF(VTK_FOUND)
list(APPEND CMAKE_MODULE_PATH "/export/home/hh/hh/iRoot-make/cmake")
FIND_PACKAGE(SQLite3 REQUIRED)
MESSAGE(STATUS "${SQLITE3_INCLUDE_DIRS}")
MESSAGE(STATUS "${SQLITE3_LIBRARY}")
# try to link boost--error
INCLUDE_DIRECTORIES(/export/home/hh/hh/boost/include)
LINK_DIRECTORIES(/export/home/hh/hh/boost/lib)
find_package(MPI REQUIRED)
IF(MPI_FOUND)
MESSAGE(STATUS "MPI IS USED")
INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
ELSE()
MESSAGE("MPI IS NOT FOUND")
ENDIF(MPI_FOUND)
aux_source_directory(. DIR_SRCS)
ADD_EXECUTABLE(test ${DIR_SRCS})
#TARGET_LINK_LIBRARIES(iRoot)
# set location of binary generated by the program,
# here PROJECT_BINARY_DIR = DIR OF build
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# set location of lib generated by the program
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
install(TARGETS test DESTINATION bin)
CMake could not find the alternative SQLite3, and could find the old version:
-- /usr/include
-- /usr/lib64/libsqlite3.so
but the new version is located at:
/export/home/hh/hh/sqlite/include
/export/home/hh/hh/sqlite/lib/libsqlite3.so
I am very new to CMAKE, please help me, thank you in advance!
I will explain this using boost as an example. This is how I have it done in my setup.
Let's assume the newer boost version is installed in:
/export/home/hh/hh/Boost/boost-1_60/boost/include/
/export/home/hh/hh/Boost/lib
Now in CMakeLists.txt add these paths to CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH:
LIST (APPEND CMAKE_INCLUDE_PATH "/export/home/hh/hh/Boost/boost-1_60")
LIST (APPEND CMAKE_LIBRARY_PATH "/export/home/hh/hh/Boost/lib)
Then call FindPackage mentioning the minimum required version and optionally the required library components which are built into .so:
FIND_PACKAGE (Boost 1.60 COMPONENTS "program_options" "log" "system" "filesystem" "thread" "python" REQUIRED)
This should work similarly for other libraries too.
Update:
Add to CMakeLists.txt paths to your custom cmake modules, for example the path where FindSQLite3.cmake is located:
LIST (APPEND CMAKE_MODULE_PATH "${MAINFOLDER}/tools/share/cmake")
Then call: FIND_PACKAGE(SQLite3 REQUIRED)
Also remove: /export/home/hh/hh/sqlite/include and /export/home/hh/hh/sqlite/lib from FindSQLite3.cmake but have them added in a similar to boost way.
Instead of hardcoding these settings in the CMakeLists.txt you should change appropriate value in the cache (builddir/CMakeCache.txt). You can do this
manually
with cmake -D VARNAME=value .
with cmake GUI app

How to use CMake RPath for boost.Python

I'm writing a Python extension module in C++ using Boost.Python. However, I
would like to use a newer version of the Boost library than the system
installation offers. This newer version of boost is contained in
BOOST_ROOT=$HOME/opt/boost/1.55.0.
Following this guide on how
to use RPath in CMake I came up with the following CMakeLists.txt.
cmake_minimum_required(VERSION 2.8)
project("test")
set(PROJECT_DESC "Test Boost.Python")
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_definitions(-std=c++11 -Wall -Wextra -pedantic)
find_package(PythonInterp REQUIRED)
find_package(PythonLibsNew REQUIRED)
find_package(Boost COMPONENTS python REQUIRED)
message(STATUS "Using Boost installation in:")
message(STATUS " INCLUDE: ${Boost_INCLUDE_DIRS}")
message(STATUS " LIB: ${Boost_LIBRARIES}")
include_directories(
${PROJECT_SOURCE_DIR}
${PYTHON_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
macro(add_python_module _name _srccpp)
PYTHON_ADD_MODULE(${_name} ${_srccpp})
target_link_libraries(${_name} ${Boost_LIBRARIES})
endmacro()
add_python_module(ownership ownership.cpp)
Then I run the following commands to build the module
mkdir build; cd build
cmake -DCMAKE_INSTALL_PATH="$BOOST_ROOT/lib" ..
make
The status message after running cmake points to the right boost
installation. (The CMake boost module picks up the environment variable
$BOOST_ROOT) I.e. the CMake variable Boost_LIBARIES points to
$BOOST_ROOT/lib/libboost_python.so.
But, if I check which libraries would actually be used, the system libraries
are listed:
$ ldd ownership.so
# ...
libboost_python.so.1.53.0 => /usr/lib64/libboost_python.so.1.53.0 (0x00007f09abfc1000)
# ...
This is version 1.53, even though the status message above explicitely pointed
to 1.55.
What am I doing wrong? How can I get ldd to pick the library in
$BOOST_ROOT/lib/libboost_python.so.1.55.0?
First of all as I already mentioned in commens you don't need to use CMake RPATH-manipulations
options. Example: http://pastebin.com/UDyYbQ1d, output: standard and custom
Do you know of a way of convincing CMake otherwise even if LIBRARY_PATH is set
This issue is not related to CMake, it's compiler responsibility. Read this discussion.
Solution
You can clear LIBRARY_PATH if you set BOOST_ROOT variable explicitly. And you can check
environment variable in CMakeLists.txt to avoid this problem in future:
string(COMPARE NOTEQUAL "$ENV{LIBRARY_PATH}" "" library_path_warning)
if(library_path_warning)
message(
WARNING
"LIBRARY_PATH environment variable is not empty ($ENV{LIBRARY_PATH}) "
"This may cause dynamic linking errors!"
)
endif()

MRPT error: cannot find -lmrpt- base

I am trying to run an example from the MRPT library but I am getting the error:
cannot find -lmrpt- base
I am running ubunut 12.04 64-bit on a laptop. I am using Code::Blocks IDE with the GNU GCC compiler.
The CMakeLists.txt file had this code:
SET(sampleName geometry3D) SET(PRJ_NAME "EXAMPLE_${sampleName}")
PROJECT(${PRJ_NAME})
CMAKE_MINIMUM_REQUIRED(VERSION 2.4) if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy)
SET(EXECUTABLE_OUTPUT_PATH ".")
FIND_PACKAGE(MRPT REQUIRED base)
ADD_EXECUTABLE(${sampleName} test.cpp )
SET_TARGET_PROPERTIES( ${sampleName} PROPERTIES PROJECT_LABEL
"(EXAMPLE) ${sampleName}")
SET(MY_DEFS ) IF(MY_DEFS) # If not empty
ADD_DEFINITIONS("-D${MY_DEFS}") ENDIF(MY_DEFS)
TARGET_LINK_LIBRARIES(${sampleName} ${MRPT_LIBS} "" )
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES
"Debug")
IF("${CMAKE_PROJECT_NAME}" STREQUAL "MRPT")
DeclareAppDependencies(${sampleName} mrpt-base)
ENDIF("${CMAKE_PROJECT_NAME}" STREQUAL "MRPT")
the example can be found here http://www.mrpt.org/tutorials/programming/maths-and-geometry/2d_3d_geometry/ at the end of the page
how do I link the lmrpt to my project? what files am I looking for?
SO the problem was I did not install the drivers correctly :P. When I was installing I did the "cmake" and "make" command but dint do the "sudo make install" so the files dint go to the correct place. Silly me :P

Resources