我无法使用 apop_estimate(data, model) 函数运行任何程序。
如果我在编译命令中不包含 -fopenmp 选项,我会收到错误消息:
$ gcc census.c -std=gnu99 -lapophenia -lgsl -lgslcblas -lsqlite3 -o 人口普查 /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/local/lib/../lib/libapophenia .a(libapopkernel_la-apop_mapply.o):在函数`rowloop._omp_fn.0'中:
/apophenia-pkg/apop_mapply.c:248: 未定义对 `omp_get_num_threads' 的引用
...
...
/apophenia-pkg/apop_mcmc.c:175: 未定义引用
GOMP_critical_name_start' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /apophenia-pkg/apop_mcmc.c:175: undefined reference to
GOMP_critical_name_end'
collect2:错误:ld 返回 1 退出状态
如果我使用选项 -fopenmp 进行编译,则编译成功。但是在执行时我得到错误:
$ ./人口普查 gsl: ../gsl/gsl_vector_double.h:180: 错误:索引超出范围
调用默认 GSL 错误处理程序。
中止(核心转储)
当我运行 gdb 时,我得到以下信息:
从人口普查中读取符号...
(gdb)r
启动程序:/home/Colin/Documents/intro-apophenia/census
[新线程 19156.0x4584]
[新线程 19156.0x43f4]
[新线程 19156.0x49ac]
[新线程 19156.0x4904]
gsl: ../gsl/gsl_vector_double.h:180: 错误:索引超出范围
调用默认 GSL 错误处理程序。
线程 1“人口普查”收到信号 SIGABRT,中止。
0x0000000077c297ea in ntdll!ZwWaitForSingleObject () from /cygdrive/c/Windows/SYSTEM32/ntdll.dll
(gdb)bt
#0 0x0000000077c297ea in ntdll!ZwWaitForSingleObject () from /cygdrive/c/Windows/SYSTEM32/ntdll.dll
#1 0x000007fefda110dc 在 WaitForSingleObjectEx () 来自 /cygdrive/c/Windows/system32/KERNELBASE.dll
#2 0x000007feb97300d0 in sigfillset () from /usr/bin/cygwin1.dll
#3 0x000007feb972bbbb in sched_getscheduler () from /usr/bin/cygwin1.dll
#4 0x000007feb972bfc5 in sched_getscheduler () from /usr/bin/cygwin1.dll
#5 0x000007feb98868d8 in cygwin1!abort () from /usr/bin/cygwin1.dll
#6 0x00000003eef65ba7 in gsl_error () from /usr/bin/cyggsl-19.dll
#7 0x00000003ef0b259f in gsl_vector_get () from /usr/bin/cyggsl-19.dll
#8 0x00000001004296d4 in ols_log_likelihood (d=0xa00036c50, p=) at apop_ols.c:166
#9 0x000000010041a336 在 apop_log_likelihood (d=, m=) at apop_model.c:268
#10 0x000000010042ae23 in apop_estimate_OLS (inset=, ep=0xa00030300) at apop_ols.c:341
#11 0x000000010041a19f in apop_estimate (d=0xa00036c50, m=) at apop_model.c:240
#12 0x0000000100401180 在主要()
census.c 程序完全按照 opophenia 网站,一个温和的介绍部分:
#include <apop.h>
int main(){
apop_text_to_db(.text_file="ss08pdc.csv", .tabname="dc");
apop_data *data = apop_query_to_data("select log(pincp+10) as log_income, agep, sex "
"from dc where agep+ pincp+sex is not null and pincp>=0");
apop_model *est = apop_estimate(data, apop_ols);
apop_model_print(est);
}
我尝试注释掉调用错误的 gsl_vector_double.h 中的代码。
INLINE_FUN
double
gsl_vector_get (const gsl_vector * v, const size_t i)
{
#if GSL_RANGE_CHECK
if (GSL_RANGE_COND(i >= v->size))
{
GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0);
}
#endif
return v->data[i * v->stride];
}
在上面的代码主体中除了返回行之外的所有注释之后,重新编译并调用我得到的可执行文件
关于索引超出范围的完全相同的错误。
我尝试在调用 apop_estimate 时使用非常小的数据集。没有效果。
我尝试运行 gdb 并调查框架中的局部变量。无法找到问题的根本原因。
我尝试在程序中添加#include