没有权限?执行 example.o 时(gsl 统计样本)
我在我的 Mac 上下载、编译并安装了 GNU Scientific Library (gsl),默认位置为 /usr/local/include/gsl。
为了测试它,我尝试编译并执行示例 C 程序(从 gsl 文档中找到)。
#include <stdio.h>
#include <gsl/gsl_statistics.h>
int
main(void)
{
double data[5] = {17.2, 18.1, 16.5, 18.3, 12.6};
double mean, variance, largest, smallest;
mean = gsl_stats_mean(data, 1, 5);
variance = gsl_stats_variance(data, 1, 5);
largest = gsl_stats_max(data, 1, 5);
smallest = gsl_stats_min(data, 1, 5);
printf ("The dataset is %g, %g, %g, %g, %g\n",
data[0], data[1], data[2], data[3], data[4]);
printf ("The sample mean is %g\n", mean);
printf ("The estimated variance is %g\n", variance);
printf ("The largest value is %g\n", largest);
printf ("The smallest value is %g\n", smallest);
return 0;
}
要编译它,
$ gcc -I /usr/local/include -c example.c
$ ls
example.c example.o
并且要执行它,
$ ./example.o
-bash: ./example.o: Permission returned
发生什么事了?除了我之外还有谁可以运行它?
I downloaded, compiled, and installed the GNU Scientific Library (gsl) on my mac, which locates /usr/local/include/gsl as default.
To test it, I have tried to compile and execute the example C program (found from gsl document).
#include <stdio.h>
#include <gsl/gsl_statistics.h>
int
main(void)
{
double data[5] = {17.2, 18.1, 16.5, 18.3, 12.6};
double mean, variance, largest, smallest;
mean = gsl_stats_mean(data, 1, 5);
variance = gsl_stats_variance(data, 1, 5);
largest = gsl_stats_max(data, 1, 5);
smallest = gsl_stats_min(data, 1, 5);
printf ("The dataset is %g, %g, %g, %g, %g\n",
data[0], data[1], data[2], data[3], data[4]);
printf ("The sample mean is %g\n", mean);
printf ("The estimated variance is %g\n", variance);
printf ("The largest value is %g\n", largest);
printf ("The smallest value is %g\n", smallest);
return 0;
}
To compile it,
$ gcc -I /usr/local/include -c example.c
$ ls
example.c example.o
And, to execute it,
$ ./example.o
-bash: ./example.o: Permission denied
What's happening? Who can run it other than me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
example.o
是一个目标文件,而不是可执行文件。根据文档(
info gsl-ref
阅读它),这应该可行(或者至少接近)。example.o
is an object file, not an executable.According to the documentation (
info gsl-ref
to read it), this should work (or at least it's close).