2016-05-31 1 views
1

안녕 libConfuse를 사용하여 구성 파일에 액세스하려고합니다. 내가에/usr/local/lib을 추가해야libConfuse를 Eclipse에 추가 [c] [cross compilation]

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' 

: 여기

이클립스에서 내 코드

#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. 
} 

그리고 오류가 등록 정보> 설정> 포함 (-I) 오류>

/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 
:> 설정> 라이브러리 (-L)

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' 

나는 또한 추가가 (-l)에 혼동하지만 찾을 수 없다는 오류가 시도 : 나는 줄 희망

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 

을 여기

6,설치 파일에서 메모입니다 충분한 정보와 누군가가 나를 도울 수 있습니다. 오후 8시 30 분 P.S. 나는 크로스 컴파일을한다.

답변

1

당신은 컴파일러 옵션을 혼동 :

  • -L이 라이브러리에 대한 경로를 추가

에 연결하는

  • -l(libname) 컴파일 된 특정 라이브러리를 추가를 포함하기위한
  • -I 경로를 추가 undefined reference to은 연결 오류입니다. 그래서 lib를 추가하지 않습니다.

    적어도 BTW 당신이 /etc/ld.so.conf의 경로를 추가하고 ldconfig 명령을 실행 기본적으로 라이브러리 검색 경로에/usr/local/lib을 추가해야합니다 명령

    -L/usr/local/lib -lconfuse를 추가합니다.

  • +0

    이제 크로스 컴파일로 인해 발생할 수 있다고 생각합니까? 내 크로스 컴파일 플랫폼을위한 libconfuse.so가 없습니까? 어떻게 생각해? –

    +1

    크로스 컴파일하는 경우 SDK에 크로스 컴파일 된 라이브러리가 필요합니다. – LPs

    +0

    나는 크로스 편집에서 새로운입니다. libConfuse를 공유 라이브러리로 가져 와서 Properties> Project References에 추가하면됩니다. –

    0

    으로 @LPs 대답 :

    당신이 당신의 SDK로 크로스 컴파일 된 라이브러리를 필요로 컴파일 교차하는 경우.