Adding GTK library to CLion - gtk3

I'm new to GTK and I'm using CLion IDE to code.
I'm on Ubuntu and I've installed libgtk-3.0-dev .
The headers I've added to my code is:
gtk-3.0
gtk-3.0/gtk/gtk.h
but when I want to build the project I get this error :
fatal error: gtk-3.0: No such file or directory

I edited the CMakeLists file as as mentioned here and it worked.
Here is my CMakelists.txt:
cmake_minimum_required(VERSION 3.3)
project(gtk_test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(gtk_test ${SOURCE_FILES})
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})
target_link_libraries(gtk_test ${GTK3_LIBRARIES})
I'm using Clion 2016 and libgtk-3.0-dev on Ubuntu 15.04.

For GTK2, there is already a module call FindGTK2 defined under clion-2016.1.2/bin/cmake/share/cmake-3.5/Modules/FindGTK2.cmake. So just include it in your CMakeLists.txt.
include(FindGTK2)
if (GTK2_FOUND)
include_directories(${GTK2_INCLUDE_DIRS})
link_directories(${GTK2_LIBRARY_DIRS})
link_libraries(${GTK2_LIBRARIES})
endif (GTK2_FOUND)

Related

VS Code: Include External OpenCV Install with CMake Tools

I am trying to set up an OpenCV C++ project using VS Code. I am able to compile the project just fine from the command line, by manually generating CMakeLists.txt:
# CMakeLists.txt
cmake_minimum_required(VERSION "3.17")
project(simple-demo)
# set OpenCV_DIR variable equal to the path to the cmake install
set(OpenCV_DIR /Users/tstoff/git/opencv/install/lib/cmake/opencv4)
# Tell compiler to use C++ 14 features
set(CMAKE_CXX_STANDARD 14)
# configure the necessary common CMake environment variables
# needed to include and link the OpenCV program into this
# demo project, namely OpenCV_INCLUDE_DIRS and OpenCV_LIBS
find_package( OpenCV REQUIRED )
# tell the build to include the headers from OpenCV
include_directories( ${OpenCV_INCLUDE_DIRS} )
# specify the executable target to be built
add_executable(simple-demo main.cpp)
# tell it to link the executable target against OpenCV
target_link_libraries(simple-demo ${OpenCV_LIBS} )
which I can build using make and cmake .. from a build directory. But I want to use the power of the VS Code CMake Tools library! How do I add external libraries to VS Code projects, preferably using CMake Tools? Many thanks!

CMake Couldn't find OPENMP(Mingw,Win10,VSCODE)

I'm struggling in compiling a project using OpenMP on Win10. My c++ project is on VSCODE, and I use MINGW32.
The error is :
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
-- Configuring done
-- Generating done
-- Build files have been written to:F:.../build
The CMakeLists file associated to the search of OpenMP in the project is the following:
cmake_minimum_required(VERSION 3.10)
project(RayTracing)
set(CMAKE_CXX_STANDARD 17)
set (CMAKE_FIND_ROOT_PATH C:/MinGW)
message(STATUS "Checking OpenMP")
find_package(OpenMP)
IF(OPENMP_FOUND)
message("Found OpenMP! ^_^")
# add flags for OpenMP
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}  ${OpenMP_EXE_LINKER_FLAGS}")
target_link_libraries(RayTracing PUBLIC OpenMP::OpenMP_CXX)
ELSE()
message("Missed OpenMP! x_x")
ENDIF()
set(SOURCE_FILES main.cpp)
add_executable(RayTracing ${SOURCE_FILES})
Yes, I have searched almost all the posts on Internet. But they are all about MacOS and clang. I cannot find a solution for my case. Any ideas? Please, I really need help.
Are you still using the old MinGW? You should really use MinGW-w64 instead.
The MinGW-w64 build from http://winlibs.com/ comes with OpenMP.

error while loading shared libraries: libopencv_core.so.3.1

A bit confused. I set up all required lib paths and still have loading shared libraries error.
From the terminal when I type
>>pkg-config --libs opencv
-L/usr/local/lib -lopencv_cudabgsegm -lopencv_cudaobjdetect -lopencv_cudastereo -lopencv_shape -lopencv_stitching -lopencv_cudafeatures2d -lopencv_superres -lopencv_cudacodec -lopencv_videostab -lopencv_cudaoptflow -lopencv_cudalegacy -lopencv_calib3d -lopencv_features2d -lopencv_objdetect -lopencv_highgui -lopencv_videoio -lopencv_photo -lopencv_imgcodecs -lopencv_cudawarping -lopencv_cudaimgproc -lopencv_cudafilters -lopencv_video -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_cudaarithm -lopencv_core -lopencv_cudev
Inside the file
sudo gedit /etc/ld.so.conf.d/opencv.conf
I have /usr/local/lib
Then in Eclipse, I set up all include and lib paths as shown in the attached images.
Then build the project has no error.
But when I debug, the error is
error while loading shared libraries: libopencv_core.so.3.1: cannot open shared object file: No such file or directory
What could be wrong?
Thanks
As batuman posted on Feb 2 at 10:10, run at terminal:
sudo ldconfig
Verified 9 Sept 2016, Ubuntu 16.04.1, Eclipse Luna and Opencv 3.1

log4c link error in eclipse

Been trying to use log4c in an eclipse IDE. No matter what I try, I can't seem to resolve the __log4c_category_vlog reference in my link.
I can see __log4c_category_vlog via an objdump of the liblog4c.a file, I've tried modifying some of the code in the category.c/category.h files before I do the make/make install, all to no avail. I've set my linker to point to the proper lib64 folder, added proper include etc in Eclipse.
The sample programs that come with log4c compile/link/run ok, so I must be missing something obvious. Any help/heads up appreciated!
log4c version:1.2.4
Eclipse version:luna
Linux: Opensuse 13.2
gcc version: 4.8.3 20140627
/home/david/build3/include/log4c/category.h:359: undefined reference to __log4c_category_vlog'
makefile:30: recipe for target 'testLog4c' failed
./src/testLog4c.o: In functionlog4c_category_log':

cmake to eclipse project conversion issue

I am trying to create an eclipse project from a cmake project .
I used the following command
cmake -G "Eclipse CDT4 - Unix Makefiles" ./`
it gives the following error
CMake Error at CMakeLists.txt:119 (find_package):
By not providing "FindGlib.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Glib", but
CMake did not find one.
Could not find a package configuration file provided by "Glib" (requested
version 2.28) with any of the following names:
GlibConfig.cmake
glib-config.cmake
Add the installation prefix of "Glib" to CMAKE_PREFIX_PATH or set
"Glib_DIR" to a directory containing one of the above files. If "Glib"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
I have glib installed . actually it couldn't resolve the path i guess. wherever find is there in cmake file , it is giving the smiler errors. please i suggest a way out, i badly need to load this project in cmake. Thanks.
Here is line 119 where error message is pointing
find_package(Glib 2.28 REQUIRED)
include_directories(${Glib_INCLUDE_DIRS})
list(APPEND LIBS ${Glib_LIBRARIES})
add_definitions(${Glib_DEFINITIONS})
When you call find_package(MyPackage) in a CMake file, it tries to find a FindMyPackage.cmake configuration in its system path (/usr/share/cmake-2.8/Modules on my Ubuntu box), or in the directory you did specify as CMAKE_MODULE_PATH).
The solution to your problem is to create a directory for modules in your source tree (e.g. CMakeModules), put in it a FindGlib.cmake file that you can find using Google, and add
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
in your CMakeLists.txt before the actual call to find_package.
(your problem is not related to the Eclipse generator, you could remove that from the title of the question).