C 可执行文件不从文件夹工作,而是在Mac上从控制台上工作
C++ Executable not working from folder, but working from console on Mac
我与Allegro一起在C 中制作的游戏有一个奇怪的问题。
游戏的一部分使用源文件夹中的一些图像。
我通过gcc
编译并创建可执行文件main
,当我从终端调用./main
时,它可以正常工作...游戏加载每个图像并正常工作。
但是,如果我打开Finder,导航并双击相同的main
,则它会崩溃,因为它无法成功地从源加载图像。如果我也尝试从乐器中打开它,也会发生同样的事情。
源代码文件夹结构是:
project:
| main //the executable is in the root of the project folder
| /src //Where all the cpp and h files are stored
| /obj //Where the .o files are stored
| item.png //images are also in the root of the project folder
,图像加载函数是Allegro的基本函数
al_load_bitmap("item.png");
这是MacOS上的预期行为。您需要一个捆绑包才能正常工作。它在MacOS官方常见问题中:
http://liballeg.org/stabledocs/en/build/macosx.html
ues一种称为 fixbundle
的工具。
相关文章:
- QSqlquery prepare()和bindvalue()不工作
- C++:将控制台输出存储在宏中更好吗
- 导入库可以跨dll版本工作吗
- 以螺旋方式打印矩阵的程序.(工作不好)
- 对象指针在c++中是如何工作的
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- Visual Studio 2017 停止工作,并在打开后显示许多控制台窗口
- C++控制台应用,其中有两个冲突的对象不工作
- 从 WebAPI 项目运行静态类时出现 StackOverflow 异常 - 从控制台应用程序运行时工作正常
- qDebug() 在升级到 ubuntu 17.10(和 Fedora)后停止工作(不再打印到控制台)
- C 中的控制台计算器程序无法正常工作
- GetAsyncKeyState() 不工作,制作控制台游戏
- 用Windows taskschd.msc编程C++Win32非控制台应用程序,无法工作
- DLL 导致"Microsoft Excel has stopped working"但它在 Win32 控制台应用中工作正常
- 如何获取绑定到我正在运行的控制台窗口的进程列表,这些进程也可以在 Windows 2000 中工作?
- c++控制台应用程序不能在其他计算机上工作
- 当从控制台获取该行作为输入但处理文件时,Istringstream不工作
- 利用英特尔Vtune放大器XE2016对一个无法工作的VS2015控制台应用程序进行高级热点分析
- 定时器在控制台应用程序中工作
- Qt程序在qtcreator中启动时工作,但如果从控制台启动则会出现段错误