Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS下点击app报错bpf.mkf无法找到的fix. #88

Closed
sudormroot opened this issue Jun 1, 2018 · 2 comments
Closed

macOS下点击app报错bpf.mkf无法找到的fix. #88

sudormroot opened this issue Jun 1, 2018 · 2 comments

Comments

@sudormroot
Copy link

在macOS下编译后,如果直接./Pal不会有错
但是点击app图标或者在别的路径执行Pal会报告错误。

错误的原因是通过"./"来访问资源文件的话如果Pal的工作路径不是Pal所在位置会导致无法定位。

解决方法是在main.c大约490行之后PAL_Init()之前加入代码:
495
496 //fix a bug on macOS
497
498 char *work_path = strdup(argv[0]);
499
500 int len = strlen(work_path);
501
502
503 while(--len) {
504 if(work_path[len] == '/') {
505 work_path[len] = '\0';
506 break;
507 }
508 }
509
510 //printf("work_path=%s\n", work_path);
511
512 chdir(work_path);
513
514
515 //
516 // Initialize everything
517 //
518 PAL_Init();

我预编译了一个版本:在我的(sudormroot)下的SDLPal-prebuild-macOS

@louyihua
Copy link
Member

louyihua commented Jun 1, 2018

这个修改配置文件就可以了,不需要改代码

@palxex
Copy link
Member

palxex commented Jun 1, 2018

在Mac下想编译app后直接双击启动,请注意作release编译。当前代码里debug编译为方便xcode调试作了特化,不能直接拷到资源文件夹里使用。
编辑:新提交( 29c8943 )从另一个方向解决了这个问题,现在Debug/Release包都可以从资源文件夹直接双击启动了。

@palxex palxex closed this as completed Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants