3

我正在尝试编译别人的项目。我已经设法在 Windows 下构建它,这意味着它是可编译的,但现在我在 Linux 上苦苦挣扎。具体来说,我收到一个文件的错误:

#ifndef _LOGGER_H_2011_27_02_ 
#define _LOGGER_H_2011_27_02_ 

//  logger
#include <log4cplus/logger.h>
#include <iomanip>

#define LOG_TRACE(logger, msg) LOG4CPLUS_TRACE(logger, \
    "[@" << std::hex << (size_t)this << "] " << std::dec << msg);

#define LOG_DEBUG(logger, msg) LOG4CPLUS_DEBUG(logger, \
    "[@" << std::hex << (size_t)this << "] " << std::dec << msg);

// I erased repetitive declarations for WARN, FATAl etc...

代码本身对我来说毫无意义,表达式"[@" <<有点疯狂,但没关系,它应该编译。我得到的错误是:

source/repository/../query/../loader/../common/logger.h:30:64: error: ‘LOG4CPLUS_ERROR’ was not declared in this scope
     "[@" << std::hex << (size_t)this << "] " << std::dec << msg);

并且:

source/repository/Repository.cpp: In member function ‘void W3TTServer::Repository::cleanupSessions()’:
source/repository/Repository.cpp:82:64: error: invalid operands of types ‘const char [33]’ and ‘long int’ to binary ‘operator<<’
  LOG4CPLUS_TRACE(logger, "Cleaning up inactive sessions..." << sessionCleanupTimer);

我启用了详细模式,但这是一个笑话,真的,我得到的只是包含目录的列表:

#include <...> search starts here:
 /usr/local/ssl/include
 /usr/include/c++/4.9
 /usr/include/x86_64-linux-gnu/c++/4.9
 /usr/include/c++/4.9/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.

安装了 log4cplus 库/usr/include/log4cplus/,由于缺少头文件没有错误,我假设<log4cplus/logger.h>加载得很好。为了验证这一点,我需要一个包含文件的列表来查看位置是否正确。

如何获取 GCC 中包含的文件列表?

4

1 回答 1

3

-H(预处理器)选项传递给g++,通常通过在Makefile例如添加

CXXFLAGS += -H

在您的适当位置Makefile

您可以简单地make CXX='g++ -H -Wall'在终端上尝试。

如果您g++在终端中输入,请在其后添加-H

于 2015-09-29T08:59:53.210 回答