代码之家  ›  专栏  ›  技术社区  ›  Gi Yeon Shin

编译make命令std时出错::\uu cxx11

  •  0
  • Gi Yeon Shin  · 技术社区  · 7 年前

    首先,我的Makefile写为:

    .SUFFIXES: .c .cpp
    
    CC              = g++ -fopenmp
    # CFLAGS                = -c -Wall -D_I386 -D_UNIX -O2 -fPIC -Wno-deprecated -Wno-unused-result -std=c++0x -Wno-sign-compare 
    CFLAGS          = -c -O2 -Wall -D_I386 -D_UNIX -fPIC -Wno-unused-result -std=c++11 -Wno-sign-compare -D_GLIBCXX_USE_CXX11_ABI=0
    LFLAGS          = -shared -O2 -o
    LIBS            = -llmi -lblas -lboost_regex -lpthread -lleveldb
    MAINDIR = ../../../
    LIBDIR  = ${MAINDIR}lib/
    LD_PATH = -L${LIBDIR}
    INCLUDEDIR = ${MAINDIR}include/Lheader
    IN_PATH = -I${INCLUDEDIR} -I${MAINDIR}include
    LM_TEST = main.o
    all: lang.test clean
    lang.test:$(LM_TEST)
         ${CC} -o $@ $^ ${IN_PATH} ${LD_PATH} ${LIBS}
    
    .cpp.o:
        @echo " compiling '$<' ..."
        @$(CC) $(CFLAGS) ${IN_PATH} $<
    clean:
        \rm -f *.o
    

    make 然后,它会出错:

    /usr/bin/ld: ../../../lib//liblmi.a(LMInterface.o): unrecognized relocation (0x2a) in section `.text'
    /usr/bin/ld: final link failed: Bad value
    

    因此,我在sudo ID中将binutils更新为2.26,如下所示:

    $ sudo apt-get update
    $ sudo apt-get install binutils
    $ dpkg -l | grep binutils
    ii  binutils                                  2.24-5ubuntu14.2                                    amd64        GNU assembler, linker and binary utilities
    ii  binutils-2.26                             2.26.1-1ubuntu1~14.04                               amd64        GNU assembler, linker and binary utilities
    

    /usr/bin/as-2.26 所以,我把它们改成这样:

    PATH="/usr/lib/binutils-2.26/bin:$PATH"
    

    制作 同样,还有其他错误:

    env_posix.cc:(.text+0x28bf): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    

    我补充道 -D_GLIBCXX_USE_CXX11_ABI=0 在队伍的最后 CFLAGS ,但是我得到了上面的错误。

    我的环境是这样的(Ubuntu 14.04):

    $ gcc --version
    gcc (Ubuntu 5.4.1-2ubuntu1~14.04) 5.4.1 20160904
    $ ld --version
    GNU ld (GNU Binutils for Ubuntu) 2.24
    
    0 回复  |  直到 7 年前