2016-05-31 4 views
1

Hi Ich versuche mit libConfuse auf eine Konfigurationsdatei zuzugreifen.libConfuse zu eclipse hinzufügen [c] [cross compilation]

Hier ist mein Code

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

#include "core.h" 
#include "readconfig.h" 

int read_config_file(const char * filename, struct damterm_socket *dt_sock){ 

    cfg_t *cfg; 

    cfg_opt_t socket_opts[] = { 
      CFG_STR("destination_ip", IP_ADDR_DEFAULT, CFGF_NONE), 
      CFG_INT("port", PORT_DEFAULT, CFGF_NONE), 
      CFG_END() 
     }; 
    cfg = cfg_init(socket_opts, CFGF_NONE); 
    if(cfg_parse(cfg, filename) == CFG_PARSE_ERROR) 
     printf("Błąd parsowania pliku!\n"); 
    else if(cfg_parse(cfg, filename) == CFG_FILE_ERROR) 
     printf("Bład odczytu pliku\n"); //!TODO check existing of the file if not create new one. 


    return -1; //!TODO Do nothing, return error. 
} 

Und Fehler von Eclipse-:

readconfig.c:(.text+0x68): undefined reference to `cfg_init' 
readconfig.c:(.text+0x78): undefined reference to `cfg_parse' 
readconfig.c:(.text+0x8c): undefined reference to `cfg_parse' 

füge ich haben/usr/local/lib in: Eigenschaften> Einstellungen> Includes (-I) und Eigenschaften> Einstellungen> Bibliotheken (-L) danach ist der Fehler:

/home/sylwek/iGT/OpenWrt-SDK-mr-mips-for-linux-i686-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: skipping incompatible /usr/local/lib/libconfuse.so when searching for -lconfuse 
makefile:29: polecenia dla obiektu 'mips' nie powiodły się 
/home/sylwek/iGT/OpenWrt-SDK-mr-mips-for-linux-i686-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: skipping incompatible /usr/local/lib/libconfuse.a when searching for -lconfuse 

/home/sylwek/iGT/OpenWrt-SDK-mr-mips-for-linux-i686-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: skipping incompatible /usr/lib/libconfuse.so when searching for -lconfuse 
/home/sylwek/iGT/OpenWrt-SDK-mr-mips-for-linux-i686-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lconfuse 
/home/sylwek/iGT/OpenWrt-SDK-mr-mips-for-linux-i686-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: skipping incompatible /usr/lib/libgcc_s.so.1 when searching for libgcc_s.so.1 
Hier

ist eine Notiz von Installationsdatei:

Libraries have been installed in: 
    /usr/local/lib 

If you ever happen to want to link against installed libraries 
in a given directory, LIBDIR, you must either use libtool, and 
specify the full pathname of the library, or use the '-LLIBDIR' 
flag during linking and do at least one of the following: 
    - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable 
    during execution 
    - add LIBDIR to the 'LD_RUN_PATH' environment variable 
    during linking 
    - use the '-Wl,-rpath -Wl,LIBDIR' linker flag 
    - have your system administrator add LIBDIR to '/etc/ld.so.conf' 

ich auch versucht Add zu (-l) zu verwechseln, haben aber Fehler, dass es nicht gefunden werden kann:

ls -l /usr/local/lib/libconfuse.so 
lrwxrwxrwx 1 root root 19 05-31 13:22 /usr/local/lib/libconfuse.so -> libconfuse.so.1.0.0 

Ich hoffe, ich gebe genug Informationen und jemand kann mir helfen. P.S. Ich übersetze die Zusammenstellung.

Antwort

1

Sie sind verwirrend Compiler-Optionen:

  • -L einen Pfad für Bibliotheken hinzufügen
  • -I einen Pfad hinzufügen für enthält
  • -l(libname) eine bestimmte kompilierte Bibliothek in den

verknüpft werden undefined reference to ist ein Verknüpfungsfehler. Also fügst du nicht die lib hinzu.

Mindestens hinzufügen -L/usr/local/lib -lconfuse auf Ihren Befehl

BTW sollten Sie hinzufügen/usr/local/lib standardmäßig Bibliotheks-Suchpfad hinzufügen den Pfad zu /etc/ld.so.conf und ldconfig Befehl starten.

+0

Jetzt denke ich, dass es durch Cross-Compilierung verursacht werden kann? Ich habe keine libconfuse.so für meine Cross-Compilation-Plattform? Was denken Sie? –

+1

Wenn Sie Cross-Compiling durchführen, benötigen Sie die über Kreuz kompilierte Bibliothek in Ihrem SDK. – LPs

+0

Ich bin neu in der Cross-Compilation. Es reicht, wenn ich libConfuse als Shared Library importiere und unter Eigenschaften> Projektreferenzen hinzufüge? –

0

Als @LPs antwortete:

Wenn Sie Kreuz sind Kompilieren Sie das Kreuz kompilierte Bibliothek in Ihrem SDK benötigen.