I am using CLion on Windows with MinGW (gcc/g++). I spend few hours working out why I cannot compile simple program, because I have issues with linking everything.
I tried to combine all found solutions on the Internet, applied changes which helped other people.. Still I am leaving with problems.
Here is my main.cpp:
#include <iostream>
#include "allegro5/allegro.h"
using namespace std;
int main(int argc, char **argv) {
cout << "Hello, World!" << endl;
al_init();
return 0;
}
And CmakeList.txt:
cmake_minimum_required(VERSION 3.6)
project(untitled)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
LINK_DIRECTORIES(allegro/lib)
INCLUDE_DIRECTORIES(allegro/include)
add_executable(untitled ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(untitled allegro_acodec
allegro_audio
allegro_color
allegro_dialog
allegro_image
allegro_main
allegro_memfile
allegro_physfs
allegro_primitives
allegro_ttf
allegro_font
allegro)
file(GLOB LIBRARIES "allegro/lib/*.dll.a")
message("LIBRARIES = ${LIBRARIES}")
TARGET_LINK_LIBRARIES(untitled ${LIBRARIES})
That is what build process pops out:
"C:\Program Files (x86)\JetBrains\CLion 2016.3.3\bin\cmake\bin\cmake.exe" --build C:\Users\Adrian\CLionProjects\untitled\cmake-build-debug --target untitled -- -j 8
-- Configuring done
LIBRARIES = C:/Users/Adrian/CLionProjects/untitled/allegro/lib/liballegro-debug.dll.a;C:/Users/Adrian/CLionProjects/untitled/allegro/lib/liballegro.dll.a;C:/Users/Adrian/CLionProjects/untitled/allegro/lib/liballegro_acodec-debug.dll.a; [... and more....]
-- Generating done
-- Build files have been written to: C:/Users/Adrian/CLionProjects/untitled/cmake-build-debug
Scanning dependencies of target untitled
[ 50%] Linking CXX executable untitled.exe
CMakeFiles\untitled.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/Adrian/CLionProjects/untitled/main.cpp:9: undefined reference to `al_install_system'
collect2.exe: error: ld returned 1 exit status
Project structure is:
└───untitled
├───.idea
├───allegro
│ ├───bin
│ ├───include
│ │ └───allegro5
│ │ ├───inline
│ │ ├───internal
│ │ ├───opengl
│ │ │ └───GLext
│ │ └───platform
│ └───lib
└───cmake-build-debug
└───CMakeFiles
├───3.6.3
│ ├───CompilerIdC
│ └───CompilerIdCXX
├───arkanoid.dir
├───CMakeTmp
├───Progress
└───untitled.dir
I have downloaded Allegro 5 x64 version, tried both allegro-mingw-gcc5.3.0-x64-dynamic and static from here: https://github.com/liballeg/allegro5/releases
Thank you
You must use the same version of compiler as was used to build the allegro binaries. Otherwise it just won't work right.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.