H
H
hobu4ok912016-07-17 15:54:31
C++ / C#
hobu4ok91, 2016-07-17 15:54:31

How to connect SDL2 to clion in ubuntu?

The cmakelist file looks like this
cmake_minimum_required(VERSION 3.5)
project(rpg)
# includes cmake/FindSDL2.cmake
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
set(CMAKE_CX{X_FLAGS "$ -std=c++11")
set(SOURCE_FILES main.cpp sdlfx.h)
add_executable(rpg ${SOURCE_FILES})
target_link_libraries(rpg ${SDL2_LIBRARY})
Main file - #include "SDL2/SDL.h"

#include "sdlfx.h"

using namespace std;

int main(int argc, char *argv[]) {
    SDL_Init(SDL_INIT_EVERYTHING);
    int a = SDL_INIT_EVERYTHING;
    cout << a;

    return 0;
}

When compiling, the following error occurs - undefined reference to `SDL_Init'
Moreover, int a = SDL_INIT_EVERYTHING;
cout << a; displays a number without problems
Tell me how to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Movchan, 2016-07-17
@Alexander1705

The library is not linked. Check what you have in ${SDL2_LIBRARY} .
PS You don't need to specify header files in the source list.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question