Where does the CLion IDE look for header files? - c++

I'm using the CLion IDE and need to put some OpenGL files in. In the JetBrains/CLion folder there's a bin and lib folder. In the lib folder theres jar files, do I put the header and dlls in here?
get this error:
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutInit_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:486: undefined reference to `__glutInitWithExit'
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutCreateWindow_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:503: undefined reference to `__glutCreateWindowWithExit'
CMakeFiles\GL.dir/objects.a(main.cpp.obj): In function `glutCreateMenu_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:549: undefined reference to `__glutCreateMenuWithExit'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\GL.dir\build.make:86: recipe for target 'GL.exe' failed
mingw32-make.exe[3]: *** [GL.exe] Error 1
CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/GL.dir/all' failed
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/GL.dir/rule' failed
mingw32-make.exe[2]: *** [CMakeFiles/GL.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/GL.dir/rule] Error 2
Makefile:109: recipe for target 'GL' failed
mingw32-make.exe: *** [GL] Error 2

From the FAQ here:
At present CLion supports GCC and Clang compilers and is guided by these two to get the libraries and headers paths.
So it depends on the compiler CLion is using where it looks for the header files.

Related

How to link OpenCl library to Clion IDE

I am writing a HellowWorld example using opencl library in Clion.
My problem is problem is that i get the error message
[ 50%] Linking CXX executable HelloWorldOpencl
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/HelloWorldOpencl.dir/main.cpp.o: in function `main':
/home/belkacem/CLionProjects/HelloWorldOpencl/main.cpp:11: undefined reference to `clGetPlatformIDs'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/HelloWorldOpencl.dir/build.make:84: HelloWorldOpencl] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/HelloWorldOpencl.dir/all] Error 2
gmake: *** [Makefile:84: all] Error 2
my opencl is installed correctly in the following directiries
libOpenCL1 - OpenCL ICD Bindings
/etc/alternatives/libOpenCL.so.1
/usr/lib64/libOpenCL.so.1
/usr/lib64/ocl-icd
/usr/lib64/ocl-icd/libOpenCL.so.1
/usr/lib64/ocl-icd/libOpenCL.so.1.0.0
/usr/share/doc/packages/libOpenCL1
/usr/share/doc/packages/libOpenCL1/README
7 files total
How i can link the library with Clion IDE?
Your OpenCL installation might be incomplete - you should have a library libOpenCL.so somewhere, and also at least one ICD file in the /etc/OpenCL/vendors directory.

linking error cxx: cannot find -lvulkan

When I tried to compile example from Anvil framework for Vulkan I get following errors:
[ 97%] Linking CXX executable OutOfOrderRasterization
/usr/bin/ld: cannot find -lvulkan
collect2: error: ld returned 1 exit status
CMakeFiles/OutOfOrderRasterization.dir/build.make:126: recipe for target 'OutOfOrderRasterization' failed
make[2]: *** [OutOfOrderRasterization] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/OutOfOrderRasterization.dir/all' failed
make[1]: *** [CMakeFiles/OutOfOrderRasterization.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
How i need to configure Vulkan to resolve it? (Ubuntu)
Check you LIBRARY paths. You might need to download and install vulkan. There should a .so file in one your library paths(/usr/lib{,64},/lib{,64}, /usr/share/lib{,64}) named to the effect of libvulkan.numbers.so.
See this ask ubuntu question: https://askubuntu.com/questions/796442/ld-cannot-find-lvulkan
CMake versions 3.7 and later ship with a FindVulkan.cmake module that finds the Vulkan includes and library for you if you have a Vulkan SDK installed and the VULKAN_SDK environment variable set. The CMake module also finds the includes and library if you have installed a Vulkan package to your system directories. The Getting Started guide on the LunarXchange website has some additional detail.

Building Google glog with CMake on Windows (failed)

I need the glog library (https://github.com/google/glog) for a C++ project (Windows 10, Qt 5.10) and try to build it from sources using CMake. The CMake configuration process was succesful, the path to gflags is also set correctly.
After configurating glog with CMake, I tried to compile it with MinGW (command mingw32-make in the build folder). After 64%, the building process stopped with an error:
[ 64%] Linking CXX executable utilities_unittest.exe
libglog.a(symbolize.cc.obj):symbolize.cc:(.text+0x15f): undefined reference to `_imp__SymFromAddr#20'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerC1Ev[__ZN6google14SymInitializerC1Ev]+0x2f): undefined reference to `_imp__SymSetOptions#4'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerC1Ev[__ZN6google14SymInitializerC1Ev]+0x51): undefined reference to `_imp__SymInitialize#12'
libglog.a(symbolize.cc.obj):symbolize.cc:(.text$_ZN6google14SymInitializerD1Ev[__ZN6google14SymInitializerD1Ev]+0x12): undefined reference to `_imp__SymCleanup#4' libglog.a(demangle.cc.obj):demangle.cc:(.text+0x9e): undefined reference to `_imp__UnDecorateSymbolName#16'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\utilities_unittest.dir\build.make:98: recipe for target 'utilities_unittest.exe' failed
mingw32-make[2]: *** [utilities_unittest.exe] Error 1
CMakeFiles\Makefile2:482: recipe for target 'CMakeFiles/utilities_unittest.dir/all' failed
mingw32-make[1]:
*** [CMakeFiles/utilities_unittest.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Do you have any idea how to fix it?
I already tried to enable the
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
option, but this did not solve the problem.
Thank you for your help!

Undefined Reference but Library Linked

I'm currently trying to add the RaspiCam library found here:
https://sourceforge.net/projects/raspicam/?source=typ_redirect
To the Apriltags library found here:
http://people.csail.mit.edu/kaess/apriltags/
I unzipped the RaspiCam library and built it separately, then just copied and pasted it into the AprilTags folder. My AprilTags folder looks like this now:
AprilTags build cmake CMakeLists.txt example LICENSE Makefile pod-build raspicam-0.1.6 README.txt src systems.txt tags
Inside the raspicam-0.1.6 folder is this:
build Changelog CMakeLists.txt CMakeLists.txt.user cmake_uninstall.cmake.in dependencies README src utils
I add the library from raspicam to the top of my code in AprilTags as:
#include <raspicam/raspicam_cv.h>
and it detects it when I build. I know this because I purposefully wrote the library wrong, ex. raspicam_cvv.h, and it gave me an error because there is no library like that. So it definitely links. However, when I try to use the library in code with for example:
raspicam::RaspiCam_Cv Camera;
It gives this error:
CMakeFiles/apriltags_demo.dir/apriltags_demo.cpp.o: In function `main':
apriltags_demo.cpp:(.text.startup+0x2d4): undefined reference to `raspicam::RaspiCam_Cv::RaspiCam_Cv()'
apriltags_demo.cpp:(.text.startup+0x324): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
apriltags_demo.cpp:(.text.startup+0x384): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
collect2: error: ld returned 1 exit status
example/CMakeFiles/apriltags_demo.dir/build.make:139: recipe for target 'bin/apriltags_demo' failed
make[3]: *** [bin/apriltags_demo] Error 1
CMakeFiles/Makefile2:193: recipe for target 'example/CMakeFiles/apriltags_demo.dir/all' failed
make[2]: *** [example/CMakeFiles/apriltags_demo.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make[1]: *** [all] Error 2
Makefile:27: recipe for target 'all' failed
make: *** [all] Error 2
as an undefined reference. I did some research online and found a similar query here: library is linked but reference is undefined where the solution is to change the order in which you link. However, because both projects are built using CMake, I don't know how you would change the order of linking.
NOTE - I would make this a comment if I could, need more rep:
Have you tried "" over <> for your include? <> is for predefined directories while "" follows a relative path
This may seem like an excess check, but did you make sure you have both the .lib and corresponding .h file for the library in the same directory? Lot of people have the .lib but are missing the .h for the lib
I come across this problem when I forget to do either of these two, whether in cmake or in visual c++ through vstudio

undefined reference linking yaml-cpp program with mingw-w64 + cmake

I'm using mingw-w64 (4.8.0) + cmake to build shared libraries for yaml-cpp (0.5.1). The project has a few build targets in the CMakeLists.txt that comes with it: the main library yaml-cpp and some test programs e.g. parse, which links the library.
The library target yaml-cpp itself built without error but it is followed by this error when parse is built:
Linking CXX executable parse.exe
CMakeFiles\parse.dir/objects.a(parse.cpp.obj):parse.cpp:(.text+0x1a3): undefined reference to `YAML::Load(std::istream&)'
CMakeFiles\parse.dir/objects.a(parse.cpp.obj):parse.cpp:(.text+0x1b2): undefined reference to `YAML::operator<<(std::ostream&, YAML::Node const&)'
c:/work/mingw64-4.8/bin/../lib/gcc/x86_64-w64-mingw32/4.8.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\parse.dir/objects.a(parse.cpp.obj): bad reloc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit status
util\CMakeFiles\parse.dir\build.make:90: recipe for target 'util/parse.exe' failed
mingw32-make[3]: *** [util/parse.exe] Error 1
CMakeFiles\Makefile2:228: recipe for target 'util/CMakeFiles/parse.dir/all' failed
mingw32-make[2]: *** [util/CMakeFiles/parse.dir/all] Error 2
CMakeFiles\Makefile2:240: recipe for target 'util/CMakeFiles/parse.dir/rule' failed
mingw32-make[1]: *** [util/CMakeFiles/parse.dir/rule] Error 2
makefile:211: recipe for target 'parse' failed
mingw32-make: *** [parse] Error 2
I run into similar errors when I try to write small test programs using the library, and I don't know what is wrong. What might be the issue here?
Jesse Beder's comment points to the exact issue causing the error described in the question. A quick fix while this gets fixed in a follow-up release is to apply the patch (https://code.google.com/p/yaml-cpp/issues/detail?id=216#c4) to a clean copy of yaml-cpp 0.5.1. There is also a line that declares std::string node_data::empty_scalar in the source file src/node_data.cpp that should be commented out. After making these changes, the shared libraries and utilities build without error.