According to docs, I have following cmake project
cmake_minimum_required(VERSION 3.5)
project(teeest LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(LLVM REQUIRED)
find_package(Clang REQUIRED)
add_executable(teeest main.cpp)
target_link_libraries(teeest
PRIVATE
clangAST
clangFrontend
clangTooling
)
but when I try to build the project, I get follwing error
/usr/bin/ld: cannot find -lclangAST
/usr/bin/ld: cannot find -lclangFrontend
/usr/bin/ld: cannot find -lclangTooling
I have install llvm package from archlinux's repository
Following helped me resolve the error:
find_package( LLVM REQUIRED CONFIG )
find_package( Clang REQUIRED CONFIG )
Related
Im having trouble changing my project from Sfml to SDL2+opengl3 rendering. The error im getting with my current CMake setup is ImGui not linking to a subfolder of mine in which i create a SHARED library: UserInterface.
Now i have tried declaring UserInterface a dependency of ImGui library:
(target_link_libraries(UserInterface imgui))
and without it.
I get a few different errors depending on how i set up CMake, but all of them must be wrong:
Without the line i get a bunch of undefined references:
/usr/bin/ld: UserInterface/libUserInterface.so: undefined reference to `ImGui_ImplOpenGL3_Init(char const*)'
/usr/bin/ld: UserInterface/libUserInterface.so: undefined reference to `ImGui::ShowDemoWindow(bool*)'
With that line i get:
/usr/bin/ld: ../libimgui.a(imgui_demo.cpp.o): relocation R_X86_64_PC32 against symbol `GImGuiDemoMarkerCallback' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
If i then change my UserInterface, and imgui to STATIC libraries i get this error:
/usr/bin/ld: libimgui.a(imgui_impl_opengl3.cpp.o): undefined reference to symbol 'dlclose##GLIBC_2.2.5'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Just to clarify, all these are linking errors when linking CXX executable digitus,
which is my application.
project:
build
CMakeLists.txt
src (folder)
CMakeLists.txt
main.cpp
(all required imgui files)
UserInterface (folder)
CMakeLists.txt
[...]
Action (folder)
[...]
My topmost CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
set (CMAKE_CXX_STANDARD 17)
project(digitus)
set(CMAKE_MODULE_PATH "/usr/local/lib/cmake") # tell cmake where to find find.cmake and config.cmake files
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
find_package(GLEW REQUIRED)
find_package(glm REQUIRED)
#include_directories(${SDL2_INCLUDE_DIR}) # add sdl2's include dir
add_subdirectory(src)
This is my CMakeLists.txt inside the src folder:
SET(SOURCES
main.cpp
ApplicationManager.cpp
ApplicationManager.h
[...]
)
SET( IMGUISOURCE
imconfig.h
imgui_demo.cpp
imgui_draw.cpp
imgui_impl_opengl3_loader.h
imgui_impl_opengl3.cpp
imgui_impl_opengl3.h
imgui_impl_sdl.cpp
imgui_impl_sdl.h
imgui_internal.h
imgui_tables.cpp
imgui_widgets.cpp
imgui.cpp
imgui.h
)
add_executable(digitus ${SOURCES})
target_link_libraries(digitus glm::glm )
target_link_libraries(digitus ${CMAKE_DL_LIBS})
add_library(imgui ${IMGUISOURCE})
target_link_libraries(digitus imgui)
add_subdirectory(Action)
add_subdirectory(UserInterface)
#target_link_libraries(UserInterface imgui)
target_link_libraries(digitus UserInterface)
target_link_libraries(digitus Action)
target_link_libraries(digitus SDL2)
target_link_libraries(digitus GLEW::glew)
target_link_libraries(digitus OpenGL::GL )
The CMakeLists.txt inside UserInterface:
Set(USERINTERFACESOURCE
UserInterface.h
UserInterface.cpp
CircuitWindow.h
CircuitWindow.cpp
)
add_library(UserInterface STATIC ${USERINTERFACESOURCE})
I'm totally new to cmake, I'm on MacOs and I'm trying to build a c++ library and I need to link my executables to mpfr in order to make it work
This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.19)
project(my_project)
set(CMAKE_CXX_STANDARD 14)
add_executable(my_project main.cpp)
find_package(GSL REQUIRED)
target_link_libraries(my_project GSL::gsl GSL::gslcblas)
find_package(Boost REQUIRED)
target_link_libraries(my_project Boost::boost)
find_package(MPFR REQUIRED) # <- It fails here!
target_link_libraries(my_project MPFR::mpfr)
When I try to build my project with CLion I get the following error:
CMake Error at CMakeLists.txt:13 (find_package):
By not providing "FindMPFR.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "MPFR", but
CMake did not find one.
Could not find a package configuration file provided by "MPFR" with any of
the following names:
MPFRConfig.cmake
mpfr-config.cmake
Add the installation prefix of "MPFR" to CMAKE_PREFIX_PATH or set
"MPFR_DIR" to a directory containing one of the above files. If "MPFR"
provides a separate development package or SDK, be sure it has been
installed.
After some research I found out that Cmake was linking correctly both GSL and Boost because there are both a /usr/local/share/cmake/Modules/FindGSL.cmake and a /usr/local/share/cmake/Modules/FindBoost.cmake file, So I looked online for a FindMPFR.cmake file to insert into the /usr/local/share/cmake/Modules/ directory, I tried with this one but the error remains the same. What am I doing wrong?
Edit:
Ok now my CMakeLists.txt file looks like this:
cmake_minimum_required(VERSION 3.19)
project(my_project)
set(CMAKE_CXX_STANDARD 14)
add_executable(my_project main.cpp )
# Append the cmake/ directory to the CMAKE_MODULE_PATH
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(GSL REQUIRED)
message(STATUS "GSL Found: ${GSL_FOUND}")
target_link_libraries(my_project GSL::gsl GSL::gslcblas)
find_package(Boost REQUIRED)
message(STATUS "Boost Found: ${Boost_FOUND}")
target_link_libraries(my_project Boost::boost)
find_package(MPFR REQUIRED)
message(STATUS "MPFR Found: ${MPFR_FOUND}")
target_link_libraries(my_project ${MPFR_LIBRARIES})
And it works fine :)
So I am using clion, trying to build a project with wxwidgets. But I get this error:
CMake Error at C:/Program Files/JetBrains/CLion 2020.1/bin/cmake/win/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS core)
Here is my cmake file:
cmake_minimum_required(VERSION 3.16)
project(BedrockFinderCpp)
set(wxWidgets_ROOT_DIR <c:/Program Files/wxWidgets-3.1.4>)
set(wxWidgets_CONFIGURATION mswu)
find_package(wxWidgets REQUIRED COMPONENTS core)
include(${wxWidgets_USE_FILE})
find_package(OpenCL REQUIRED)
add_executable(${PROJECT_NAME}
BFFApp.cpp
BFFGui.cpp
PrecomputedRandAdvance.cpp
)
target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCL_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES} ${OpenCL_LIBRARIES})
I found a "fix" by myself. It can be done with this code:
NOTE: wxWidgets is a subdirectory that contains files from the wxWidgets-3.1.4 directory
cmake_minimum_required(VERSION 3.16)
project(BedrockFinderCpp)
add_subdirectory(wxWidgets)
find_package(OpenCL REQUIRED)
add_executable(${PROJECT_NAME}
BFFApp.cpp
BFFGui.cpp
PrecomputedRandAdvance.cpp
)
target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCL_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} wx::core ${OpenCL_LIBRARIES})
I am building a python extension from c++ shared library.
This library is using some openmp pragma.
I would like to know how to configure CMakeLists.txt in order to include openmp ?
I have added the openmp flag -fopenmp
But I still have this error : undefined symbol: GOMP_critical_end
here is my CMakeLists.txt file
cmake_minimum_required(VERSION 3.10)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++lastest -pthread -fopenmp")
project (py_interface)
#find_library('gomp')
find_package(OpenMP REQUIRED)
find_package(Boost REQUIRED)
include_directories(/usr/include/python3.6/)
link_directories(/usr/local/lib)
set(SRC interface.cpp)
add_library(py_interface SHARED ${SRC})
target_link_libraries(py_interface PRIVATE OpenMP::OpenMP_CXX ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
set_property(TARGET py_interface PROPERTY POSITION_INDEPENDENT_CODE ON)
Hello I am trying to use ImageMagick++ in one of my applications. I am trying to build my program from CMakeList. When I try to include Magick++.h in my main program it is showing an error saying that it cannot be found.
I tried to install like it is mentioned in the link.
Link for installation.
CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(...)
set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/local/lib/pkgconfig")
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/local/lib")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
find_package(libhpdf REQUIRED)
find_package(ImageMagick REQUIRED)
message(STATUS "${CMAKE_MODULE_PATH}")
include_directories(${LIBHPDF_INCLUDE_DIRS} src/include)
include_directories(${ImageMagick_INCLUDE_DIRS})
message(Verification "${ImageMagick_LIBRARIES} ${ImageMagick_INCLUDE_DIRS}")
set(SOURCE_FILES src/main.cpp src/base64.cpp src/base64.h)
add_executable(pdfgen ${SOURCE_FILES})
target_link_libraries(pdfgen ${LIBHPDF_LIBRARIES} ${ImageMagick_LIBRARIES})
Can someone help me to resolve this issue
This is the CMake output
Cmake output
Message for ImageMagickLibraries is null