3
votes

Hello I am new to Linux development, and just recently switched from Windows MSVS c++ development to Linux-based vim+cmake+gcc. I am using Debian Sid(unstable).

I am trying to get code on subdivision, I have gotten from a friend to run. I am not really used to Cmake, and googling for help often is troublesome, since every other dist seems to have different packages and different solutions.

cmake_minimum_required (VERSION 2.6)
project (Benchmark)
Find_Package(Qt4 REQUIRED) Include(${QT_USE_FILE})

find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})

set(CORELIBS ${QT_LIBRARY} ${OPENGL_LIBRARY} )

File(GLOB SRC ".cpp")
File(GLOB HEAD "
.h")
add_executable(Benchmark ${SRC})
target_link_libraries(Benchmark ${CORELIBS})

That is my current Cmake, I want to use find_package(), GLOB etc to make it as dynamic as possible, and not use absolute paths.

I get the following error when trying to build.

subdivbench/Matrix4x4.h:4:19: fatal error: gl/GL.h: No such file or directory
#include gl/GL.h
compilation terminated. make[2]: [CMakeFiles/Benchmark.dir/Matrix4x4.cpp.o] Error 1 make[1]: [CMakeFiles/Benchmark.dir/all] Error 2

The code is fairly irrelevant, since it's working perfectly in windows, all I need to do is to make the include etc work for Linux.

2
Are you sure you have gl/GL.h installed on your machine?hanslovsky
I have installed and included openGL, I have installed libmesagl1-devel, I have installed and included X11, installed and included Glut. If I didn't have gl/GL.h on the machine I would've gotten error from cmake, not during compiling. The fault lies in my cmake, but might as well be I lack the package on my machine, but that is too early to tell. gl/Gl.h should be inside all of the ones I mentioned.Wertilq
This is strange. I have mesa installed on my system and made a small sample CMakeLists.txt: FIND_PACKAGE(OpenGL REQUIRED) MESSAGE("${OPENGL_INCLUDE_DIR}") The output is: /usr/include -- Configuring done -- Generating done -- Build files have been written to: /home/phil/local/tmp/opengl So your cmake code appears correct to me. What I found out: I need to include GL/gl.h, not gl/GL.h. edit: Sorry for that formatting, I did not know it does not work in comments.hanslovsky
okay! I'll try to edit the code then!Wertilq

2 Answers

9
votes

Include GL/gl.h instead of gl/GL.h

1
votes

From what hanslovsky said:

I have mesa installed on my system and made a small sample CMakeLists.txt: FIND_PACKAGE(OpenGL REQUIRED) MESSAGE("${OPENGL_INCLUDE_DIR}") The output is: /usr/include -- Configuring done -- Generating done -- Build files have been written to: /home/phil/local/tmp/opengl So your cmake code appears correct to me.

What I found out: I need to include GL/gl.h, not gl/GL.h. edit: Sorry for that formatting, I did not know it does not work in comments.

This worked. Thanks a tons hanslovsky, it was just a capitalization problem.