I have issue with OpenCV. This is my first time, when i use this. I did download the openCV with Homebrew (Macos 13.2 Ventura) and i make a simple cmake project with this cmakelist:
`cmake_minimum_required(VERSION 3.0.0)
project(PROJEKTTEST1)
include(CTest)
enable_testing()
set(OpenCV_DIR /opt/homebrew/Cellar/opencv/4.7.0_1/..)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(PROJEKTTEST1 main.cpp)
target_link_libraries(PROJEKTTEST1 ${OpenCV_LIBS})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)`
And when i run this project i got this error:
szaboattila#Szabo-MacBook-Air projekttest1 % cd "/Users/szaboattila/Desktop/Programozás/projekttest1/" && g++ main.cpp -o main && "/Users/szaboattila/Desktop/Pr
ogramozás/projekttest1/"main
main.cpp:1:10: fatal error: 'opencv2/opencv.hpp' file not found
#include <opencv2/opencv.hpp>
Can help me what should i do?
The opencv path is: /opt/homebrew/Cellar/opencv/4.7.0_1/**
I added the path in cmakelist and the jsone file and it doesnt work...
Related
i'm trying to run a C game i found on youtube using CLion but i keep getting this error: fatal error: SDL2_gfxPrimitives.h: No such file or directory. i downloaded the SDL2_gfx library but seems like there's something wrong with the CMakeList.txt that can't find the file.
cmake_minimum_required(VERSION 3.0)
project(untitled C)
set(CMAKE_C_STANDARD 99)
set(SDL2_INCLUDE_DIR C:/SDL2/include)
set(SDL2_LIB_DIR C:/SDL2/lib/x86)
set(SDL2_GFX C:/SDL2_gfx)
include_directories(${SDL2_INCLUDE_DIR})
link_directories(${SDL2_LIB_DIR})
find_package(PkgConfig)
pkg_check_modules(SDL2_GFX SDL2_gfx)
include_directories(${SDL2_GFX_INCLUDE_DIRS})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -Wall -Werror -fdump-rtl-expand")
# add_executable(untitled main.c)
set(SRCS
main.c
logic.c
rendering.c
)
set(HEADERS
logic.h
rendering.h
game.h
)
add_executable(untitled ${SRCS} ${HEADERS})
target_link_libraries(${PROJECT_NAME} SDL2main SDL2 ${SDL2_GFX_LIBRARIES})
If someone knows how to fix it, thanks in advance!!
Your question does not provide many importing bits of information, like the OS and Minimum Reproducible Example, but I'll to help you anyway.
If you use Linux, you need to install the sdl2_gfx package.
/usr/include/SDL2/SDL2_framerate.h
/usr/include/SDL2/SDL2_gfxPrimitives.h
/usr/include/SDL2/SDL2_imageFilter.h /usr/include/SDL2/SDL2_rotozoom.h
/usr/lib/libSDL2_gfx-1.0.so.0 /usr/lib/libSDL2_gfx-1.0.so.0.0.2
/usr/lib/libSDL2_gfx.so /usr/lib/pkgconfig/SDL2_gfx.pc
/usr/share/licenses/sdl2_gfx/LICENSE
I'm trying to read and display an image using OpenCV c++ version in vscode but I keep getting this error:
libpng warning: Application built with libpng-1.4.12 but running with 1.6.37 libc++abi: terminating with uncaught exception of type cv::Exception: OpenCV(4.5.3) /Users/aniekan/opencv/opencv-4.5.3/modules/highgui/src/window.cpp:1006: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
This is my CmakeLists:
cmake_minimum_required(VERSION 3.0.0)
project(C++ VERSION 0.1.0)
include(CTest)
include(FindPkgConfig)
enable_testing()
pkg_check_modules(LIBPNG libpng16 REQUIRED)
if (NOT LIBPNG_FOUND)
message(FATAL ERROR "libpng16 development libaries not installed")
endif()
message(PNG_LIBRARIES = "${LIBPNG_LIBRARIES}")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS} ${LIBPNG_INCLUDE_DIRS})
link_directories(${LIBPNG_LIBRARY_DIRS})
add_executable(C++ main.cpp)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${LIBPNG_LIBRARIES})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
The make file builds without error and finds the required but I still get the error.
This is the build output:
build_output
Any suggestions on this issue?
In my case I was running the build on a Github Action and a preinstalled Mono was cluttering the build with many unwanted libraries. I fixed by passing -DCMAKE_FIND_FRAMEWORK=NEVER to cmake, as discussed here.
I am using CLion cmakelist.txt to compile but receive the following error. The program compiled with g++ but somehow lacks dependency when I am using cmake. anyone know how to solve this?
cmake_minimum_required(VERSION 3.19)
project(CTCWordBeamSearch_master)
find_package(PkgConfig)
pkg_check_modules(TensorFlow REQUIRED tensorflow)
link_directories(${TensorFlow_LIBRARY_DIRS})
include_directories(${TensorFlow_INCLUDE_DIRS})
add_compile_definitions(${TensorFlow_CFLAGS_OTHER})
set(CMAKE_CXX_STANDARD 14)
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(.)
include_directories(cpp)
include_directories(cpp/proj)
include_directories(cpp/src)
include_directories(cpp/src/pybind)
include_directories(cpp/src/pybind/pybind11)
include_directories(cpp/src/pybind/pybind11/detail)
include_directories(cpp/src/utfcpp)
include_directories(cpp/src/utfcpp/utf8)
include_directories(data)
include_directories(doc)
include_directories(np)
include_directories(py)
include_directories(tf)
add_executable(CTCWordBeamSearch_master
...
)
target_link_libraries(CTCWordBeamSearch_master ${PYTHON_LIBRARIES})
target_link_libraries(CTCWordBeamSearch_master ${TensorFlow_LIBRARIES})
I'm attempting to set up an environment in which I can use gtkmm for C++ development. My CMakeLists.txt file looks like this:
cmake_minimum_required(VERSION 3.0.2)
project(program)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)
link_directories(${GTKMM_LIBRARY_DIRS})
include_directories(include ${GTKMM_INCLUDE_DIRS})
file(GLOB SOURCES "*.cpp")
add_executable(program ${SOURCES})
target_link_libraries(program ${GTKMM_LIBRARIES})
Yet when I try to include the line include <gtkmm.h> in main I am met with this error from CMake:
fatal error: 'gtkmm.h' file not found
#include <gtkmm.h>
I installed gtkmm with brew using the command brew install gtkmm and brew install gtkmm3 to insure versions were not the issue. What can I do to get this working?
Be sure to install pkg-config (using brew).
Here is a CMakeLists.txt file that will work:
cmake_minimum_required(VERSION 3.16)
project(program LANGUAGES CXX)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)
add_executable(program)
target_compile_features(program PRIVATE cxx_std_17)
target_sources(program PRIVATE main.cpp)
target_include_directories(program PRIVATE ${GTKMM_INCLUDE_DIRS})
target_link_directories(program PRIVATE ${GTKMM_LIBRARY_DIRS})
target_link_libraries(program PRIVATE ${GTKMM_LIBRARIES})
I am trying to compile an opencv project using cmake on Mac. When I try to compile, I am presented with this error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:301:10: fatal error: 'math.h' file not found
Telling me math.h is not found. The library definitely exists because when I compile without cmake, it works fine.
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project( Optimotive )
find_package( OpenCV )
file(GLOB_RECURSE Optimotive_SOURCES "../Optimotive/*.cpp")
file(GLOB_RECURSE Optimotive_HEADERS "../Optimotive/*.h")
set(Optimotive_INCLUDE_DIRS "")
foreach(_headerFile ${Optimotive_HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list(APPEND Optimotive_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES Optimotive_INCLUDE_DIRS)
include_directories(${Optimotive_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
add_executable(Optimotive ${Optimotive_SOURCES})
target_link_libraries(Optimotive ${OpenCV_LIBS})