linux - 编译时出错:::strcmp 尚未声明

标签 linux makefile

我正在使用一个叫做 supersense tagger 的软件,我有一个 makefile 粘贴在下面。

#Makefile for sst-light

    CXX = g++
    CFLAGS = -g -O1 -DPIC -fPIC -ILIB -I.

    CXXFLAGS = $(CFLAGS) -fno-exceptions
    #CXXFLAGS = -g
    #LIB = -lm ${TAO_LIB} ${PETSC_SNES_LIB}
    #include ${TAO_DIR}/bmake/tao_common

    SOURCES = sst-light.cc \
LIB/utils/utils.cc \
LIB/stats/stats.cc \
LIB/results/results.cc \
LIB/evaluate/evaluate.cc \
LIB/Chain/Chain.cc  \
LIB/Perceptron/Perceptron.cc  \
LIB/tagger_light/Tlight.cc \
LIB/examples/examples.cc \
LIB/features/features.cc

    MLIBOBJECTS = LIB/utils/utils.o \
    LIB/stats/stats.o \
    LIB/results/results.o \
    LIB/evaluate/evaluate.o \
    LIB/Chain/Chain.o  \
    LIB/Perceptron/Perceptron.o  \
    LIB/tagger_light/Tlight.o \
    LIB/examples/examples.o \
LIB/features/features.o 


    OBJECTS = sst-light.o \
LIB/utils/utils.o \
LIB/stats/stats.o \
LIB/results/results.o \
LIB/evaluate/evaluate.o \
LIB/Chain/Chain.o  \
LIB/Perceptron/Perceptron.o  \
LIB/tagger_light/Tlight.o \
LIB/examples/examples.o \
LIB/features/features.o #\
     #  /usr/local/WordNet-2.1/lib/libWN.a

    PEROBJ  = Perceptron/Perceptron.o  Perceptron/Kernel_Perceptron.o
    CRFOBJ  = CRF/CRF.o

    SuperSenseTagger: $(OBJECTS) 
        g++ $(OBJECTS) -o sst

    videotagger: $(MLIBOBJECTS) videotagger.o
      g++ $(MLIBOBJECTS) videotagger.o -o videotagger

    to-conll: to-conll.o
       g++ to-conll.o -o to-conll

    libwnss.so:     $(MLIBOBJECTS)
g++ -shared -o libwnss.so  $(MLIBOBJECTS) -lm -lpthread -lc -lstdc++ -lgcc_s

    .PHONY: clean

    clean:
      find . -name '*.[od]' -print -exec rm {} \;
    clean_bak:
      find . -name '*~' -print -exec rm {} \;

    # this command tells GNU make to look for dependencies in *.d files
    -include $(patsubst %.c,%.d,$(SOURCES:%.cc=%.d))

执行时我得到以下信息:

g++ -g -O1 -DPIC -fPIC -ILIB -I. -fno-exceptions   -c -o sst-light.o sst-light.cpp
In file included from /usr/include/c++/4.3/ext/hash_map:64,
                 from LIB/examples/../tagger_light/../results/../utils/../hash_stuff/hash_stuff.h:26,
                 from LIB/examples/../tagger_light/../results/../utils/utils.h:31,
                 from LIB/examples/../tagger_light/../results/results.h:29,
                 from LIB/examples/../tagger_light/Tlight.h:29,
                 from LIB/examples/examples.h:19,
                 from sst-light.cpp:21:
/usr/include/c++/4.3/backward/backward_warning.h:33:2: warning: #warning This file includes at least
one deprecated or antiquated header which may be removed without further notice at a future date.
Please use a non-deprecated interface with equivalent functionality instead. For a listing of 
replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
In file included from LIB/examples/../tagger_light/../results/../utils/utils.h:31,
                 from LIB/examples/../tagger_light/../results/results.h:29,
                 from LIB/examples/../tagger_light/Tlight.h:29,
                 from LIB/examples/examples.h:19,
                 from sst-light.cpp:21:
LIB/examples/../tagger_light/../results/../utils/../hash_stuff/hash_stuff.h: In member function
    âbool std::equal_to<const char*>::operator()(const char*, const char*) constâ:
LIB/examples/../tagger_light/../results/../utils/../hash_stuff/hash_stuff.h:44: error: â::strcmpâ has not been declared
make: *** [sst-light.o] Error 1

有人知道是什么原因造成的吗?

最佳答案

是的 - gcc 已经更新了他们的编译器,它不是“默认包括”它用于旧版本的一些头文件 - 您正在使用的代码尚未更新以反射(reflect)这一点。

看起来您需要在 sst-light.cpp 中为 strcmp 添加 include

#include <cstring>

而且看起来代码使用的是旧式的 C++ include - 所以改变一些东西,比如

#include <iostream.h>

#include <iostream>

但只对 C++ 头文件执行此操作。

关于linux - 编译时出错:::strcmp 尚未声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8888431/

相关文章:

c - 在linux系统上顺序打开和读取多个文件

python - 将 Python 应用程序作为 debian 包分发,但作为服务分发

c - 编译文件时出错 |收集 2 : error: ld returned 1 exit status

opencv - 如何在ROS中使用OpenCV 4?

linux - shell 脚本中的主机名变量(非 FQDN)

linux - 如何在 bash 的 for 循环中使用命令的输出?

linux - nginx permission denied 错误获取

Android AOSP项目导入eclipse

perl编译: 'Too many levels of symbolic links'

Makefile:$@~ 是什么意思?