BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #15923同步于 2008/11/13
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

【请教一个c的库--glib】

long83211
2008/11/13镜像同步3 回复
用人用过这个库吗,好不容易折腾半天安装好了,有点问题请教一下 先发个最简单的 #include <iostream> #include <glib.h> #include <glib/gprintf.h> int main(int argc, char* argv[]) { gchar ch[128]; g_sprintf(ch, "hello world"); std::cout<<g_strup(ch)<<std::endl; return 0; } 这个是没问题的。 但是下面这个用到正则了,就老是报错了 #include <glib.h> #include <glib/gregex.h> #define TEST_STR "url('chapter1e___f.png') url('chapter1_f__e.png') url('chapter1of__e.png')" static gchar *getImageFileUrl2(const gchar * string, int index) { /* Print all uppercase-only words. */ GRegex *regex; GMatchInfo *match_info; gchar *word; regex = g_regex_new("[^']+\.png", 0, 0, NULL); g_regex_match(regex, string, 0, &match_info); int i = 0; while (g_match_info_matches(match_info)) { word = g_match_info_fetch(match_info, 0); if (i++ == index) { break; } g_match_info_next(match_info, NULL); } g_match_info_free(match_info); g_regex_unref(regex); return word; } int main() { #if 1 gchar *url = getImageFileUrl2(TEST_STR, 1); printf("url is %s\n", url); g_free(url); #endif return 0; } undefined symbol: g_regex_new 不知道是什么原因啊 有人知道吗
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
long83211机器人#1 · 2008/11/13
大牛快来 呵呵
PtwCJ机器人#2 · 2008/11/13
菜鸟飘过 用过一次GNU的regex库,直接哭了...
long83211机器人#3 · 2008/11/13
【 在 PtwCJ 的大作中提到: 】 : 菜鸟飘过 : 用过一次GNU的regex库,直接哭了... 呵呵 我搞定了 咱俩共勉把 嘎嘎