Undefined reference to LibConfuse internal functions on Code::Blocks


6 days ago


8 time


I am testing LibConfuse on Code::Blocks trying to build the simplest first example on the tutorial:

#include <stdio.h>
#include <confuse.h>

int main(void)
    cfg_opt_t opts[] =
        CFG_STR("target", "World", CFGF_NONE),
    cfg_t *cfg;

    cfg = cfg_init(opts, CFGF_NONE);
    if(cfg_parse(cfg, "hello.conf") == CFG_PARSE_ERROR)
        return 1;

    printf("Hello, %s!\n", cfg_getstr(cfg, "target"));

    return 0;

But I get the below errors when compiling:

Undefined reference to "cfg_init".
Undefined reference to "cfg_parse".
Undefined reference to "cfg_getstr".
Undefined reference to "cfg_free".

Note that there are no errors about the #include <confuse.h> line nor about the constans, like CFGF_NONE.

I installed LibConfuse with:

# sudo apt-get update
# sudo apt-get install libconfuse*

What is going on here and how can I solve it?

Further Data:

  • Operating System: Ubuntu 16.04 .
  • Tested on two different PC computers.
  • Tested on RaspBerry Pi running RaspBian.
  • Code::Blocks version 17.12 .

0 answers