0

I actualy work on a openGL projet on my VM but i need openGL 4.5 so i have install ubuntu on my laptop with (GTX 870M) who is compatible 4.5 (i check with glxinfo). But my problem is after install gcc, build-essential, libglew-dev, freeglut3-dev, freeglut3 and SDL2. I can't make my projet i have error like undefined reference on « SDL_WasInit » , « glBegin », .... for all library installed...

i try with makefile like :

ifeq "$(shell uname)" "Darwin"
LIBGL=  -framework OpenGL
else
    LIBGL=  -lGLU -lGL
endif

CXXFLAGS += `pkg-config glew --cflags` `sdl2-config --cflags` -g -W -Wall -Wno-unused-parameter -Wno-deprecated-declarations
LDFLAGS += `pkg-config glew --libs` `sdl2-config --libs` $(LIBGL)

all : main.exe
run : main.exe
        ./main.exe
main.exe : main.cpp *.h
        $(CXX) $(CXXFLAGS) $(LDFLAGS) -o$@ main.cpp

sol : main_solution.exe
runs : main_solution.exe
        ./main_solution.exe
main_solution.exe : main_solution.cpp *.h
        $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ main_solution.cpp

clean :
        rm -f *.o *.exe

and with cmakefile like :

cmake_minimum_required(VERSION 3.3)
project(src)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lglut -lGLU -lGL -lGLEW -lm -lSDL2 -lSDL2main -Wall -g")

set(SOURCE_FILES
        """ALL SOURCE FILES"""")

add_executable(src ${SOURCE_FILES})

This projet (cmakefile and makefile) work fine on my virtual machine ...
I hope you can help me thx.

Timo
  • 497
  • 10
  • 21

1 Answers1

0

In CMake you use target_link_libraries to specify which libraries to use. In general you want to use find_package(…) to locate the configuration for a specific library, then use the variables introduced by it to link.

find_package(OpenGL)
add_executable(foo …)
target_link_libraries(foo ${OPENGL_gl_LIBRARY} …)

You should look into the cmake modules that are used by find_package to see what the names of the variables they configure are.

datenwolf
  • 159,371
  • 13
  • 185
  • 298