vc 中的链接时间错误++使用混淆库时

发布于 2024-08-09 18:36:52 字数 12109 浏览 8 评论 0原文

我正在尝试在 Windows 上使用混淆库。在 vc++ 中编译混淆时出现链接时间错误。如何解决。请注意 libConfuse 是一个配置文件解析器库,用 C 语言编写。

1>Linking...
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_getnint referenced in function "void __cdecl print_ask(struct cfg_opt_t *,unsigned int,struct _iobuf *)" (?print_ask@@YAXPAUcfg_opt_t@@IPAU_iobuf@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_title referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark@@YAHPAUcfg_t@@PAUcfg_opt_t@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getstr referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark@@YAHPAUcfg_t@@PAUcfg_opt_t@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_getnsec referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark@@YAHPAUcfg_t@@PAUcfg_opt_t@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_size referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark@@YAHPAUcfg_t@@PAUcfg_opt_t@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_free referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_print referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_set_print_func referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnint referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnfloat referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnstr referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getsec referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getbool referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnsec referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_size referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_setstr referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getint referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_parse referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_set_validate_func referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_init referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_include referenced in function _main
1>F:\products\testconfuse\testconfuse\Debug\testconfuse.exe : fatal error LNK1120: 21 unresolved externals
1>Build log was saved at "file://f:\products\testconfuse\testconfuse\testconfuse\Debug\BuildLog.htm"
1>testconfuse - 22 error(s), 0 warning(s)

该程序有两个文件 main.cpp 和 test.conf 。也不是说我们需要下载 http://bzero.se/confuse/confuse-2.6.zip 并给出使用库libConfuse.lib,该库存在于confuse-2.6\windows\msvc6\libConfuse中

///// main.cpp

extern "C"
{
    #include <confuse.h>
}
#include <string.h>

void print_func(cfg_opt_t *opt, unsigned int index, FILE *fp)
{
    fprintf(fp, "%s(foo)", opt->name);
}

void print_ask(cfg_opt_t *opt, unsigned int index, FILE *fp)
{
    int value = cfg_opt_getnint(opt, index);
    switch(value) {
        case 1:
            fprintf(fp, "yes");
            break;
        case 2:
            fprintf(fp, "no");
            break;
        case 3:
        default:
            fprintf(fp, "maybe");
            break;
    }
}

/* function callback
 */
int cb_func(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv)
{
    int i;

    /* at least one parameter is required */
    if(argc == 0) {
        cfg_error(cfg, "Too few parameters for the '%s' function",
                  opt->name);
        return -1;
    }

    printf("cb_func() called with %d parameters:\n", argc);
    for(i = 0; i < argc; i++)
        printf("parameter %d: '%s'\n", i, argv[i]);
    return 0;
}

/* value parsing callback
 *
 * VALUE must be "yes", "no" or "maybe", and the corresponding results
 * are the integers 1, 2 and 3.
 */
int cb_verify_ask(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result)
{
    if(strcmp(value, "yes") == 0)
        *(long int *)result = 1;
    else if(strcmp(value, "no") == 0)
        *(long int *)result = 2;
    else if(strcmp(value, "maybe") == 0)
        *(long int *)result = 3;
    else {
        cfg_error(cfg, "Invalid value for option %s: %s", opt->name, value);
        return -1;
    }
    return 0;
}

int cb_validate_bookmark(cfg_t *cfg, cfg_opt_t *opt)
{
    /* only validate the last bookmark */
    cfg_t *sec = cfg_opt_getnsec(opt, cfg_opt_size(opt) - 1);
    if(!sec)
    {
        cfg_error(cfg, "section is NULL!?");
        return -1;
    }
    if(cfg_getstr(sec, "machine") == 0)
    {
        cfg_error(cfg, "machine option must be set for bookmark '%s'",
                  cfg_title(sec));
        return -1;
    }
    return 0;
}

int main(int argc, char **argv)
{
    unsigned int i;
    cfg_t *cfg;
    unsigned n;
    int ret;
    static cfg_opt_t proxy_opts[] = {
        CFG_INT("type", 0, CFGF_NONE),
        CFG_STR("host", 0, CFGF_NONE),
        CFG_STR_LIST("exclude", "{localhost, .localnet}", CFGF_NONE),
        CFG_INT("port", 21, CFGF_NONE),
        CFG_END()
    };
    static cfg_opt_t bookmark_opts[] = {
        CFG_STR("machine", 0, CFGF_NONE),
        CFG_INT("port", 21, CFGF_NONE),
        CFG_STR("login", 0, CFGF_NONE),
        CFG_STR("password", 0, CFGF_NONE),
        CFG_STR("directory", 0, CFGF_NONE),
        CFG_BOOL("passive-mode", cfg_false, CFGF_NONE),
        CFG_SEC("proxy", proxy_opts, CFGF_NONE),
        CFG_END()
    };
    cfg_opt_t opts[] = {
        CFG_INT("backlog", 42, CFGF_NONE),
        CFG_STR("probe-device", "eth2", CFGF_NONE),
        CFG_SEC("bookmark", bookmark_opts, CFGF_MULTI | CFGF_TITLE),
        CFG_FLOAT_LIST("delays", "{3.567e2, 0.2, -47.11}", CFGF_NONE),
        CFG_FUNC("func", &cb_func),
        CFG_INT_CB("ask-quit", 3, CFGF_NONE, &cb_verify_ask),
        CFG_INT_LIST_CB("ask-quit-array", "{maybe, yes, no}",
                        CFGF_NONE, &cb_verify_ask),
        CFG_FUNC("include", &cfg_include),
        CFG_END()
    };

#ifndef _WIN32
    /* for some reason, MS Visual C++ chokes on this (?) */
    printf("Using %s\n\n", confuse_copyright);
#endif

    cfg = cfg_init(opts, CFGF_NOCASE);

    /* set a validating callback function for bookmark sections */
    cfg_set_validate_func(cfg, "bookmark", &cb_validate_bookmark);

    ret = cfg_parse(cfg, argc > 1 ? argv[1] : "test.conf");
    printf("ret == %d\n", ret);
    if(ret == CFG_FILE_ERROR) {
        perror("test.conf");
        return 1;
    } else if(ret == CFG_PARSE_ERROR) {
        fprintf(stderr, "parse error\n");
        return 2;
    }

    printf("backlog == %ld\n", cfg_getint(cfg, "backlog"));

    printf("probe device is %s\n", cfg_getstr(cfg, "probe-device"));
    cfg_setstr(cfg, "probe-device", "lo");
    printf("probe device is %s\n", cfg_getstr(cfg, "probe-device"));

    n = cfg_size(cfg, "bookmark");
    printf("%d configured bookmarks:\n", n);
    for(i = 0; i < n; i++) {
        cfg_t *pxy;
        cfg_t *bm = cfg_getnsec(cfg, "bookmark", i);
        printf("  bookmark #%u (%s):\n", i+1, cfg_title(bm));
        printf("    machine = %s\n", cfg_getstr(bm, "machine"));
        printf("    port = %d\n", (int)cfg_getint(bm, "port"));
        printf("    login = %s\n", cfg_getstr(bm, "login"));
        printf("    passive-mode = %s\n",
               cfg_getbool(bm, "passive-mode") ? "true" : "false");
        printf("    directory = %s\n", cfg_getstr(bm, "directory"));
        printf("    password = %s\n", cfg_getstr(bm, "password"));

        pxy = cfg_getsec(bm, "proxy");
        if(pxy) {
            int j, m;
            if(cfg_getstr(pxy, "host") == 0) {
                printf("      no proxy host is set, setting it to 'localhost'...\n");
                /* For sections without CFGF_MULTI flag set, there is
                 * also an extended syntax to get an option in a
                 * subsection:
                 */
                cfg_setstr(bm, "proxy|host", "localhost");
            }
            printf("      proxy host is %s\n", cfg_getstr(pxy, "host"));
            printf("      proxy type is %ld\n", cfg_getint(pxy, "type"));
            printf("      proxy port is %ld\n", cfg_getint(pxy, "port"));

            m = cfg_size(pxy, "exclude");
            printf("      got %d hosts to exclude from proxying:\n", m);
            for(j = 0; j < m; j++) {
                printf("        exclude %s\n", cfg_getnstr(pxy, "exclude", j));
            }
        } else
            printf("    no proxy settings configured\n");
    }

    printf("delays are (%d):\n", cfg_size(cfg, "delays"));
    for(i = 0; i < cfg_size(cfg, "delays"); i++)
        printf(" %G\n", cfg_getnfloat(cfg, "delays", i));

    printf("ask-quit == %ld\n", cfg_getint(cfg, "ask-quit"));

    /* Using cfg_setint(), the integer value for the option ask-quit
     * is not verified by the value parsing callback.
     *
     *
     cfg_setint(cfg, "ask-quit", 4);
     printf("ask-quit == %ld\n", cfg_getint(cfg, "ask-quit"));
    */

    /* The following commented line will generate a failed assertion
     * and abort, since the option "foo" is not declared
     *
     *
     printf("foo == %ld\n", cfg_getint(cfg, "foo"));
    */

    cfg_addlist(cfg, "ask-quit-array", 2, 1, 2);

    for(i = 0; i < cfg_size(cfg, "ask-quit-array"); i++)
        printf("ask-quit-array[%d] == %ld\n",
               i, cfg_getnint(cfg, "ask-quit-array", i));

    /* print the parsed values to another file */
    {
        FILE *fp = fopen("test.conf.out", "w");
        cfg_set_print_func(cfg, "func", print_func);
        cfg_set_print_func(cfg, "ask-quit", print_ask);
        cfg_set_print_func(cfg, "ask-quit-array", print_ask);
        cfg_print(cfg, fp);
        fclose(fp);
    }

    cfg_free(cfg);
    return 0;
}

//  test.conf
# test config file

# this is a one line comment

// this is a C++-style one line comment

/*
 * This is a C-style multi-line comment
 */

BackLog = 2147483647

bookmark heimdal {
    login = "anonymous"
    password = ${ANONPASS:-anonymous@}
    directory = "/pub/heimdal/src"
    machine = "ftp://ftp.pdc.kth.se:21"

    proxy {
      type = 1
      host = ${HOST:-localhost}   # environment variable substitution
      #port = 21
      #exclude = {"localhost"  , ".localnet" , "fu.bar.net"}
      exclude += {.aol.com , .sf.net}
    }
}

probe-device = "eth1"
# probe-device += "eth3"   # error, probe-device is not a list

bookmark gazonk {
 machine = "ssh://localhost"
 login = joe
 passive-mode = true
 directory = '/pub/dir with spaces/\
more'       # continued on next line
  port = 022 # in octal mode
 proxy {} /* use default proxy */
}

bookmark ftp.du.se {
 machine = "ftp.du.se"
// port = 0x21 /* hexadecimal */
 login = ftp
 proxy {
   exclude = {.com.net}
 }
}

/* functions can be called with variable number of arguments
 */
func( "one", "two", 'three',four )
func( 1, 2 )

//delays = {145.12345, .6,42, 4.987e2}
//delays += {0.1, 0.2, 0.3}

ask-quit = maybe

#ask-quit-array = {"maybe", "maybe", "maybe"}
ask-quit-array += {"no", "yes", "yes"}

include(inc.conf)

/////////////////////////////////

我已在链接器->输入->“附加依赖项”内添加了libconfuse.lib,并且还给出了lib链接器的路径->常规->“附加链接目录”


我已经添加了libconfuse 2.6并提取了它。我在其中使用了 lib 以及 src 目录中的 config.h 。然后我从 libconfuse 主页编译了示例程序。

I am trying to use confuse library on windows. I get a link time error when confuse is compiled in vc++. how to resolve it. Please note that libConfuse is a configuration file parser library and written in C.

1>Linking...
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_getnint referenced in function "void __cdecl print_ask(struct cfg_opt_t *,unsigned int,struct _iobuf *)" (?print_ask@@YAXPAUcfg_opt_t@@IPAU_iobuf@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_title referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark@@YAHPAUcfg_t@@PAUcfg_opt_t@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getstr referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark@@YAHPAUcfg_t@@PAUcfg_opt_t@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_getnsec referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark@@YAHPAUcfg_t@@PAUcfg_opt_t@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_size referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark@@YAHPAUcfg_t@@PAUcfg_opt_t@@@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_free referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_print referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_set_print_func referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnint referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnfloat referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnstr referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getsec referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getbool referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnsec referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_size referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_setstr referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getint referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_parse referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_set_validate_func referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_init referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_include referenced in function _main
1>F:\products\testconfuse\testconfuse\Debug\testconfuse.exe : fatal error LNK1120: 21 unresolved externals
1>Build log was saved at "file://f:\products\testconfuse\testconfuse\testconfuse\Debug\BuildLog.htm"
1>testconfuse - 22 error(s), 0 warning(s)

The program has two file main.cpp and test.conf . Also not that we need to download http://bzero.se/confuse/confuse-2.6.zip and give use library libConfuse.lib which is present inside confuse-2.6\windows\msvc6\libConfuse

///// main.cpp

extern "C"
{
    #include <confuse.h>
}
#include <string.h>

void print_func(cfg_opt_t *opt, unsigned int index, FILE *fp)
{
    fprintf(fp, "%s(foo)", opt->name);
}

void print_ask(cfg_opt_t *opt, unsigned int index, FILE *fp)
{
    int value = cfg_opt_getnint(opt, index);
    switch(value) {
        case 1:
            fprintf(fp, "yes");
            break;
        case 2:
            fprintf(fp, "no");
            break;
        case 3:
        default:
            fprintf(fp, "maybe");
            break;
    }
}

/* function callback
 */
int cb_func(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv)
{
    int i;

    /* at least one parameter is required */
    if(argc == 0) {
        cfg_error(cfg, "Too few parameters for the '%s' function",
                  opt->name);
        return -1;
    }

    printf("cb_func() called with %d parameters:\n", argc);
    for(i = 0; i < argc; i++)
        printf("parameter %d: '%s'\n", i, argv[i]);
    return 0;
}

/* value parsing callback
 *
 * VALUE must be "yes", "no" or "maybe", and the corresponding results
 * are the integers 1, 2 and 3.
 */
int cb_verify_ask(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result)
{
    if(strcmp(value, "yes") == 0)
        *(long int *)result = 1;
    else if(strcmp(value, "no") == 0)
        *(long int *)result = 2;
    else if(strcmp(value, "maybe") == 0)
        *(long int *)result = 3;
    else {
        cfg_error(cfg, "Invalid value for option %s: %s", opt->name, value);
        return -1;
    }
    return 0;
}

int cb_validate_bookmark(cfg_t *cfg, cfg_opt_t *opt)
{
    /* only validate the last bookmark */
    cfg_t *sec = cfg_opt_getnsec(opt, cfg_opt_size(opt) - 1);
    if(!sec)
    {
        cfg_error(cfg, "section is NULL!?");
        return -1;
    }
    if(cfg_getstr(sec, "machine") == 0)
    {
        cfg_error(cfg, "machine option must be set for bookmark '%s'",
                  cfg_title(sec));
        return -1;
    }
    return 0;
}

int main(int argc, char **argv)
{
    unsigned int i;
    cfg_t *cfg;
    unsigned n;
    int ret;
    static cfg_opt_t proxy_opts[] = {
        CFG_INT("type", 0, CFGF_NONE),
        CFG_STR("host", 0, CFGF_NONE),
        CFG_STR_LIST("exclude", "{localhost, .localnet}", CFGF_NONE),
        CFG_INT("port", 21, CFGF_NONE),
        CFG_END()
    };
    static cfg_opt_t bookmark_opts[] = {
        CFG_STR("machine", 0, CFGF_NONE),
        CFG_INT("port", 21, CFGF_NONE),
        CFG_STR("login", 0, CFGF_NONE),
        CFG_STR("password", 0, CFGF_NONE),
        CFG_STR("directory", 0, CFGF_NONE),
        CFG_BOOL("passive-mode", cfg_false, CFGF_NONE),
        CFG_SEC("proxy", proxy_opts, CFGF_NONE),
        CFG_END()
    };
    cfg_opt_t opts[] = {
        CFG_INT("backlog", 42, CFGF_NONE),
        CFG_STR("probe-device", "eth2", CFGF_NONE),
        CFG_SEC("bookmark", bookmark_opts, CFGF_MULTI | CFGF_TITLE),
        CFG_FLOAT_LIST("delays", "{3.567e2, 0.2, -47.11}", CFGF_NONE),
        CFG_FUNC("func", &cb_func),
        CFG_INT_CB("ask-quit", 3, CFGF_NONE, &cb_verify_ask),
        CFG_INT_LIST_CB("ask-quit-array", "{maybe, yes, no}",
                        CFGF_NONE, &cb_verify_ask),
        CFG_FUNC("include", &cfg_include),
        CFG_END()
    };

#ifndef _WIN32
    /* for some reason, MS Visual C++ chokes on this (?) */
    printf("Using %s\n\n", confuse_copyright);
#endif

    cfg = cfg_init(opts, CFGF_NOCASE);

    /* set a validating callback function for bookmark sections */
    cfg_set_validate_func(cfg, "bookmark", &cb_validate_bookmark);

    ret = cfg_parse(cfg, argc > 1 ? argv[1] : "test.conf");
    printf("ret == %d\n", ret);
    if(ret == CFG_FILE_ERROR) {
        perror("test.conf");
        return 1;
    } else if(ret == CFG_PARSE_ERROR) {
        fprintf(stderr, "parse error\n");
        return 2;
    }

    printf("backlog == %ld\n", cfg_getint(cfg, "backlog"));

    printf("probe device is %s\n", cfg_getstr(cfg, "probe-device"));
    cfg_setstr(cfg, "probe-device", "lo");
    printf("probe device is %s\n", cfg_getstr(cfg, "probe-device"));

    n = cfg_size(cfg, "bookmark");
    printf("%d configured bookmarks:\n", n);
    for(i = 0; i < n; i++) {
        cfg_t *pxy;
        cfg_t *bm = cfg_getnsec(cfg, "bookmark", i);
        printf("  bookmark #%u (%s):\n", i+1, cfg_title(bm));
        printf("    machine = %s\n", cfg_getstr(bm, "machine"));
        printf("    port = %d\n", (int)cfg_getint(bm, "port"));
        printf("    login = %s\n", cfg_getstr(bm, "login"));
        printf("    passive-mode = %s\n",
               cfg_getbool(bm, "passive-mode") ? "true" : "false");
        printf("    directory = %s\n", cfg_getstr(bm, "directory"));
        printf("    password = %s\n", cfg_getstr(bm, "password"));

        pxy = cfg_getsec(bm, "proxy");
        if(pxy) {
            int j, m;
            if(cfg_getstr(pxy, "host") == 0) {
                printf("      no proxy host is set, setting it to 'localhost'...\n");
                /* For sections without CFGF_MULTI flag set, there is
                 * also an extended syntax to get an option in a
                 * subsection:
                 */
                cfg_setstr(bm, "proxy|host", "localhost");
            }
            printf("      proxy host is %s\n", cfg_getstr(pxy, "host"));
            printf("      proxy type is %ld\n", cfg_getint(pxy, "type"));
            printf("      proxy port is %ld\n", cfg_getint(pxy, "port"));

            m = cfg_size(pxy, "exclude");
            printf("      got %d hosts to exclude from proxying:\n", m);
            for(j = 0; j < m; j++) {
                printf("        exclude %s\n", cfg_getnstr(pxy, "exclude", j));
            }
        } else
            printf("    no proxy settings configured\n");
    }

    printf("delays are (%d):\n", cfg_size(cfg, "delays"));
    for(i = 0; i < cfg_size(cfg, "delays"); i++)
        printf(" %G\n", cfg_getnfloat(cfg, "delays", i));

    printf("ask-quit == %ld\n", cfg_getint(cfg, "ask-quit"));

    /* Using cfg_setint(), the integer value for the option ask-quit
     * is not verified by the value parsing callback.
     *
     *
     cfg_setint(cfg, "ask-quit", 4);
     printf("ask-quit == %ld\n", cfg_getint(cfg, "ask-quit"));
    */

    /* The following commented line will generate a failed assertion
     * and abort, since the option "foo" is not declared
     *
     *
     printf("foo == %ld\n", cfg_getint(cfg, "foo"));
    */

    cfg_addlist(cfg, "ask-quit-array", 2, 1, 2);

    for(i = 0; i < cfg_size(cfg, "ask-quit-array"); i++)
        printf("ask-quit-array[%d] == %ld\n",
               i, cfg_getnint(cfg, "ask-quit-array", i));

    /* print the parsed values to another file */
    {
        FILE *fp = fopen("test.conf.out", "w");
        cfg_set_print_func(cfg, "func", print_func);
        cfg_set_print_func(cfg, "ask-quit", print_ask);
        cfg_set_print_func(cfg, "ask-quit-array", print_ask);
        cfg_print(cfg, fp);
        fclose(fp);
    }

    cfg_free(cfg);
    return 0;
}

//  test.conf
# test config file

# this is a one line comment

// this is a C++-style one line comment

/*
 * This is a C-style multi-line comment
 */

BackLog = 2147483647

bookmark heimdal {
    login = "anonymous"
    password = ${ANONPASS:-anonymous@}
    directory = "/pub/heimdal/src"
    machine = "ftp://ftp.pdc.kth.se:21"

    proxy {
      type = 1
      host = ${HOST:-localhost}   # environment variable substitution
      #port = 21
      #exclude = {"localhost"  , ".localnet" , "fu.bar.net"}
      exclude += {.aol.com , .sf.net}
    }
}

probe-device = "eth1"
# probe-device += "eth3"   # error, probe-device is not a list

bookmark gazonk {
 machine = "ssh://localhost"
 login = joe
 passive-mode = true
 directory = '/pub/dir with spaces/\
more'       # continued on next line
  port = 022 # in octal mode
 proxy {} /* use default proxy */
}

bookmark ftp.du.se {
 machine = "ftp.du.se"
// port = 0x21 /* hexadecimal */
 login = ftp
 proxy {
   exclude = {.com.net}
 }
}

/* functions can be called with variable number of arguments
 */
func( "one", "two", 'three',four )
func( 1, 2 )

//delays = {145.12345, .6,42, 4.987e2}
//delays += {0.1, 0.2, 0.3}

ask-quit = maybe

#ask-quit-array = {"maybe", "maybe", "maybe"}
ask-quit-array += {"no", "yes", "yes"}

include(inc.conf)

/////////////////////////////////

I have added libconfuse.lib inside linker->input->"additional depenendencies" and also given path of lib linker->General ->"additional link directory"


I have added libconfuse 2.6 and extracted it. I have used lib in it also config.h from its src dir. I have then compiled example program from libconfuse home page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绅刃 2024-08-16 18:36:52

我认为您没有添加对“confuselib”工作所需的库的引用。您可以检查您的编译器链接器包含并查看是否添加了所有相关的混淆库吗?

I think you didnt add a reference to a lib that is needed for the "confuselib" to work. Can you check your compiler linker includes and see if you added all the relevant confuse libraries ?

梅倚清风 2024-08-16 18:36:52

这些方法都在confuse.c中定义;您没有与混淆库或其他版本链接,或者您使用错误的配置构建了混淆库。

those methods are all defined in confuse.c; either you are not linking with the confuse library, or with another version, or you built the confuse library with an erroneous configuration.

网白 2024-08-16 18:36:52

该问题现已解决。当我给出从 F:\confuse-2.6\windows\msvc6\libConfuse 到 F:\confuse-2.6\windows\msvs.net\libConfuse\Release 的 lib 路径时,问题得到解决

The issue is fixed now . it was resolved when i gave lib path from F:\confuse-2.6\windows\msvc6\libConfuse to F:\confuse-2.6\windows\msvs.net\libConfuse\Release

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文