将 Allegro 5 库与 Jetbrains CLion 结合使用
Using Allegro 5 library with Jetbrains CLion
我在 Windows 上使用 CLion 和 MinGW (gcc/g++(。我花了几个小时弄清楚为什么我不能编译简单的程序,因为我在链接所有内容时遇到问题。
我试图结合互联网上找到的所有解决方案,应用帮助其他人的更改。我仍然带着问题离开。
这是我的主要.cpp:
#include <iostream>
#include "allegro5/allegro.h"
using namespace std;
int main(int argc, char **argv) {
cout << "Hello, World!" << endl;
al_init();
return 0;
}
和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})
这就是构建过程弹出的内容:
"C:Program Files (x86)JetBrainsCLion 2016.3.3bincmakebincmake.exe" --build C:UsersAdrianCLionProjectsuntitledcmake-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
CMakeFilesuntitled.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
项目结构为:
└───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
我已经下载了 Allegro 5 x64 版本,从这里尝试了 allegro-mingw-gcc5.3.0-x64-dynamic 和静态:https://github.com/liballeg/allegro5/releases
谢谢
您必须使用与构建 allegro 二进制文件相同的编译器版本。否则它将无法正常工作。
相关文章:
- 无法在 CLion 中构建 C++ 项目
- 多态性和功能结合
- C++:如何在CLion IDE中安装Boost
- 如何使用CLion在Mac上创建一个新的.txt文件
- IDE (CLion) 无法解析C++模板类型
- 将 Vulkan 与 SFML 结合使用?
- Clion显示错误,但可以使用Cmake成功构建代码
- 如何将 CLion C++ 项目导入 Visual Studio?
- Boost.TEST with CLion: "Test framework quit unexpectedly"
- clion 无法解析 std 类型
- 将 c++ 生成器应用程序与外部 dll 结合使用
- 在装有 CLion 的 Mac 上使用 C++ 连接到 MySQL 数据库时出现问题
- 如何将增强MSM与增强信号结合使用?
- MS Visual Studio 解决方案结合了非托管C++项目和 C# 项目
- 如何让 CLion 显示异常?
- CLion 无法在 macOS 上找到 Eigen3
- 函数未在作用域中声明 / 如何结合使用 header.h、header.cpp 和 main.cpp?
- 如何将 OpenMP 和 MPI 导入到大型 CLion CMake 项目中?
- 当我在 CLion 中读取数组中的 txt 文件时C++编码问题
- 将 Allegro 5 库与 Jetbrains CLion 结合使用