[英]Using Allegro 5 library with Jetbrains CLion
I am using CLion on Windows with MinGW (gcc/g++). 我在Windows上使用MinGW(gcc / g ++)的CLion。 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. 我试图结合所有在Internet上找到的解决方案,并应用了对其他人有所帮助的更改。
Here is my main.cpp: 这是我的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: 和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 我已经下载了Allegro 5 x64版本,并从此处尝试过allegro-mingw-gcc5.3.0-x64-dynamic和static: https : //github.com/liballeg/allegro5/releases
Thank you 谢谢
You must use the same version of compiler as was used to build the allegro binaries. 您必须使用与构建Allegro二进制文件相同的编译器版本。 Otherwise it just won't work right.
否则,它将无法正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.