如何在使用 SDL2 的 Eclipse 中构建 c++ 程序

How to build a c++ program in Eclipse which uses SDL2

本文关键字:Eclipse 构建 c++ 程序 SDL2      更新时间:2023-10-16

我在 Eclipse C++中制作了一个程序。如果我构建它并在我的机器上运行它,它可以正常工作。但是,如果我将其发送给没有 SDL 框架的人,它不起作用。我的机器和另一台不使用它的机器是Mac。我需要更改什么才能构建我的程序?

Eclipse 中的构建控制台只是这样说:

00:14:23 **** Incremental Build of configuration Release for project     Salsa Kit ****
make all 
Building file: ../src/main.cpp
Invoking: Cross G++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/main.d" -MT"src/main.o" -o "src/main.o" "../src/main.cpp"
Finished building: ../src/main.cpp
Building target: Salsa Kit.app
Invoking: Cross G++ Linker
g++ -L/Library/Frameworks/SDL2.framework -L/Library/Frameworks/SDL2_image.framework -framework SDL2 -framework Cocoa -framework          SDL2_image -o "Salsa Kit.app"  ./src/engine/SE.o ./src/engine/SE_Audio.o ./src/engine/SE_Graphics.o ./src/engine/SE_Input.o  ./src/main.o   
Finished building target: Salsa Kit.app

00:14:26 Build Finished. 0 errors, 0 warnings. (took 3s.139ms)

您需要在应用程序中包含所需的运行时库(例如 SDL、Visual Studio 可再发行组件等,您使用的任何内容(。

通常,您需要将所需的库添加到应用程序安装程序/包中 - 您还需要构建这些库。

对于Windows,这通常是一个MSI文件。对于Linux,RPM或DEB包很常见。