Files
old-core/README.md
2018-11-07 22:01:39 +01:00

3.6 KiB

Basic C SDL project

This project is a basic C SDL project that uses CMake as a build system.

Dependencies

On Debian/Ubuntu based distributions, use the following command:

sudo apt install git-core build-essential pkg-config cmake cmake-data libsdl2-dev

Optional packages:

sudo apt install libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev

Build instructions

# Clone this repo
git clone https://gitlab.com/aminosbh/basic-c-sdl-project.git
cd basic-c-sdl-project

# Create a build folder
mkdir build
cd build

# Build
cmake ..
make

# Run
./basic-c-sdl-project

Note: To use SDL2_image, SDL2_ttf or SDL2_gfx, you should uncomment some instructions in the CMakeLists.txt file and re-execute cmake .. and make

Open the project with an IDE under Linux

Open with Qt Creator

Qt Creator is a cross-platform C/C++ IDE, originally dedicated for the Qt framework. It handle natively CMake projects and provide an efficient code completion.

Install Qt creator:

Install from Debian/Ubuntu repo:

sudo apt install qtcreator

Online installer: https://www.qt.io/download-thank-you?hsLang=en
Offline installer: https://www.qt.io/offline-installers

Open the project:
Run Qt Creator, use Open Files or Project ... and select the CMakeLists.txt file of the cloned project.
Finally, build and run the project.

Open with Code::blocks

Code::Blocks is a well-known cross-platform C/C++ and Fortran IDE. It handle CMake projects by wrapping them into native Code::Blocks projects.

Install Code::Blocks

sudo apt install codeblocks

Prepare the Code::Blocks project:

# Create a folder for the Code::Blocks project
cd basic-c-sdl-project
mkdir -p build/codeblocks
cd build/codeblocks

# Generate a Code::Blocks project
cmake ../.. -G "CodeBlocks - Unix Makefiles"

Open the project:
Run Code::Blocks, and open the project in basic-c-sdl-project/build/codeblocks.
Finally, build and run the project.

Open with Eclipse C/C++

Eclipse is a well-known IDE, widely used in Java projects development, but it also supports other programming languages, like in this case C/C++. It handle CMake projects by wrapping them into native Eclipse projects.

Download Eclipse C/C++:

Online installer: https://www.eclipse.org/downloads
Offline package: https://www.eclipse.org/downloads/packages

Prepare the Eclipse project:

# Create a folder for the Eclipse project outside this project
cd basic-c-sdl-project
mkdir ../eclipse-basic-c-sdl-project
cd ../eclipse-basic-c-sdl-project

# Generate an Eclipse project
cmake ../basic-c-sdl-project -G "Eclipse CDT4 - Unix Makefiles"

Open the project:
Run Eclipse, and open the project in eclipse-basic-c-sdl-project.
Create a new run configuration: Go to Run > Run configurations > C\C++ Application and specify the C/C++ Application using Search Project...
Finally, build and run the project.

License

This project is distributed under the terms of the MIT license <LICENSE>.