-
-
Notifications
You must be signed in to change notification settings - Fork 784
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
Linux下使用QtCreator构建任务问题 #73
Comments
为什么不直接设置
|
直接用xmake和/usr/sbin/xmake效果相同
2017年4月15日 20:17,"ruki" <notifications@github.com>写道:
… 为什么不直接设置xmake而要写全绝对路径呢?qt不支持? 通过 XMAKE_PROGRAM_DIR 分离
- 一个原因是暂时没找到方便靠谱的方式在程序中获取自身的绝对路径
- 还有个原因是,有时候不安装的情况下使用xmake,这个可执行程序和脚本目录 是分离的,这样通过环境变量设置也可以正常运行
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#73 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AGpFTELxTke6X9Je424biVHA-2htPUADks5rwLVNgaJpZM4M-Uyu>
.
|
这个我之后可以再改进下,在源码编译安装的时候把它写入进去,作为默认路径,这个版本你就先暂时通过环境变量的方式。这么用吧。。 |
@waruqi 非常感谢!
针对这个问题可以参考下面的实现方式 /***********************************************************************
* Code listing from "Advanced Linux Programming," by CodeSourcery LLC *
* Copyright (C) 2001 by New Riders Publishing *
* See COPYRIGHT for license information. *
***********************************************************************/
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
/* Finds the path containing the currently-running program executable.
The path is placed into BUFFER, which is of length LEN. Returns
the number of characters in the path, or -1 on error. */
size_t get_executable_path (char* buffer, size_t len)
{
char* path_end;
/* Read the target of /proc/self/exe. */
if (readlink ("/proc/self/exe", buffer, len) <= 0)
return -1;
/* Find the last occurence of a forward slash, the path separator. */
path_end = strrchr (buffer, '/');
if (path_end == NULL)
return -1;
/* Advance to the character past the last slash. */
++path_end;
/* Obtain the directory containing the program by truncating the
path after the last slash. */
*path_end = '\0';
/* The length of the path is the number of characters up through the
last slash. */
return (size_t) (path_end - buffer);
}
int main ()
{
char path[PATH_MAX];
get_executable_path (path, sizeof (path));
printf ("this program is in the directory %s\n", path);
return 0;
} |
谢谢,这种方式只对 linux下有效,没法支持macOS,但我可以在下个版本中,对linux平台先尝试处理下。。 |
http://stackoverflow.com/questions/1528298/get-path-of-executable 这里面看似有个不错的跨平台解决方式,针对不同平台进行处理,但是我觉得还是没法保证完全的跨平台化,因此这个环境变量的设置还是需要的,毕竟这种方式是最稳定有效,也是最便捷的。。 我觉得可以通过如下的方式进行一些改进:
|
我在dev分支上,已经对其进行改进,在下个版本中,只需要执行: |
OS: Arch Linux x86_64
XMake Version:
v2.1.3.201704160314
installed from AUR在终端中通过xmake构建项目无问题。
在QtCreator IDE中配置项目如下
执行构建命令QtCreator抱怨如下
通过查看
/usr/sbin/xmake
的内容得到启示,修改构建配置为如下所示后可以正常通过IDE构建和清理项目
想问一下
XMAKE_PROGRAM_DIR
这个环境变量的值是否可在xmake实现中获取到,然后/usr/sbin/xmake
则可以建立文件软链接到/usr/share/xmake/xmake
,这样应该可以解决这个问题吧。The text was updated successfully, but these errors were encountered: