我正在开发一个以前使用平面文件文本格式来存储其首选项的程序,但是我希望切换到使用库来卸载所有自定义代码。对json情有独钟,一直在看jansson。
虽然我运气不佳,但我所做的是首先检查我的 configure.ac 文件,检查 libjansson 包中的 json_string 函数。
...
checking for a BSD-compatible install... /usr/bin/install -c
checking for vte_terminal_fork_command in -lvte... yes
checking for json_string in -ljansson... yes
...
如您所见,这是有效的,问题是当我运行 make 时出现以下错误:
/home/niadh/Projects/x2/code/src/libX2.h:22: undefined reference to `json_string'
我正在运行最新的 Ubuntu 并安装了 libjansson4 和 libjansson-dev 软件包,如果有人可以帮助我启动并运行它,我将不胜感激。如果我未能提供关键信息,请告诉我,我会尽力提供更多信息。我也非常期待它是我错过的简单的东西,如果是这样我提前道歉。
为方便起见,这里给出错误发生的libX2.h文件。
#include <jansson.h>
static gchar *getConfigDir() {
return g_build_filename(g_get_home_dir(), ".config", "X2", NULL);
}
static gchar *getConfigFile() {
return g_build_filename(getConfigDir(), "X2.conf", NULL);
}
static gchar *getTemplatesDir() {
return g_build_filename(getConfigDir(), "templates", NULL);
}
static gchar *getTemplate(gchar *template) {
return g_build_filename(getTemplatesDir, template, NULL);
}
static gchar *getDefaultPreferences() {
const gchar *font = "Sans 10";
const gchar *tabs = "bottom";
json_t *nothing = json_string("testing");
/*json_t *programmingFeatures = json_boolean(1);
json_t *syntaxHighlighting = json_boolean(1);
json_t *lineNumbering = json_boolean(1);
json_t *highlightLine = json_boolean(1);
json_t *terminal = json_boolean(1);
json_t *searchInWords = json_boolean(1);
json_t *caseSensitiveSearch = json_boolean(1);
json_t *lineWrapping = json_boolean(1);
json_t *fontInfo = json_string(font);
json_t *tabsPosition = json_string(tabs);*/
return "";
}
最佳答案
事实证明这是一个构建问题,我没有正确编辑我的 make 文件,所以我没有回答这个问题,以免让 future 的潜在读者感到沮丧。
关于C、JSON (Jansson) 和一些 autotools 构建问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16950375/