私はC++に比較的慣れていませんが、使用log4j
しました(そして、Pythonクローンですlogging
)。log4cxx
したがって、新しいC++プロジェクトへのログインに使用したいと思います。
log4cxxをインストールしました
brew install log4cxx
次に、それをソースファイルに含める必要があります。私は試しました、例えば
#include "log4cxx/logger.h"
namespace EnsembleClustering {
METISGraphParser::METISGraphParser() {
// logging
log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("METISGraphParser"));
logger->setLevel(log4cxx::Level::getInfo());
this->logger = logger;
}
}
これは私にリンカーエラーを与えるので、これは十分に含まれていないようです
13:06:29 **** Incremental Build of configuration Debug for project EnsembleClustering ****
make all
Building file: ../src/METISGraphParser.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/METISGraphParser.d" -MT"src/METISGraphParser.d" -o "src/METISGraphParser.o" "../src/METISGraphParser.cpp"
../src/METISGraphParser.cpp: In member function 'virtual void EnsembleClustering::METISGraphParser::connectNode(EnsembleClustering::id, std::vector<unsigned int, std::allocator<unsigned int> >)':
../src/METISGraphParser.cpp:128: warning: unused variable 'deg'
../src/METISGraphParser.cpp: In member function 'virtual EnsembleClustering::Graph EnsembleClustering::METISGraphParser::parse(std::string)':
../src/METISGraphParser.cpp:112: warning: control reaches end of non-void function
Finished building: ../src/METISGraphParser.cpp
Building target: EnsembleClustering
Invoking: MacOS X C++ Linker
g++ -o "EnsembleClustering" ./src/EdgeScoring.o ./src/EdgeTripleGraphData.o ./src/EnsembleClustering.o ./src/EnsembleClusteringAlgo.o ./src/Graph.o ./src/METISGraphParser.o ./src/Matching.o ./src/Modularity.o
Undefined symbols for architecture x86_64:
"log4cxx::spi::LocationInfo::LocationInfo(char const*, char const*, int)", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"log4cxx::Level::getInfo()", referenced from:
EnsembleClustering::METISGraphParser::METISGraphParser()in METISGraphParser.o
EnsembleClustering::METISGraphParser::METISGraphParser()in METISGraphParser.o
"log4cxx::Level::getDebug()", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"log4cxx::Logger::getLogger(char const*)", referenced from:
EnsembleClustering::METISGraphParser::METISGraphParser()in METISGraphParser.o
EnsembleClustering::METISGraphParser::METISGraphParser()in METISGraphParser.o
"log4cxx::helpers::MessageBuffer::str(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"log4cxx::helpers::MessageBuffer::MessageBuffer()", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"log4cxx::helpers::MessageBuffer::~MessageBuffer()", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"log4cxx::helpers::MessageBuffer::operator<<(char const*)", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"log4cxx::helpers::ObjectPtrBase::exchange(void**, void*)", referenced from:
log4cxx::helpers::ObjectPtrT<log4cxx::Logger>::exchange(log4cxx::Logger const*)in METISGraphParser.o
"log4cxx::helpers::ObjectPtrBase::ObjectPtrBase()", referenced from:
log4cxx::helpers::ObjectPtrT<log4cxx::Logger>::ObjectPtrT()in METISGraphParser.o
"log4cxx::helpers::ObjectPtrBase::~ObjectPtrBase()", referenced from:
log4cxx::helpers::ObjectPtrT<log4cxx::Level>::~ObjectPtrT()in METISGraphParser.o
log4cxx::helpers::ObjectPtrT<log4cxx::Level>::~ObjectPtrT()in METISGraphParser.o
log4cxx::helpers::ObjectPtrT<log4cxx::Logger>::~ObjectPtrT()in METISGraphParser.o
log4cxx::helpers::ObjectPtrT<log4cxx::Logger>::~ObjectPtrT()in METISGraphParser.o
"log4cxx::helpers::CharMessageBuffer::operator<<(int)", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"log4cxx::Logger::isDebugEnabled() const", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"log4cxx::Logger::forcedLog(log4cxx::helpers::ObjectPtrT<log4cxx::Level> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, log4cxx::spi::LocationInfo const&) const", referenced from:
EnsembleClustering::METISGraphParser::initGraph(int, int)in METISGraphParser.o
"typeinfo for log4cxx::helpers::ObjectPtrBase", referenced from:
typeinfo for log4cxx::helpers::ObjectPtrT<log4cxx::Level>in METISGraphParser.o
typeinfo for log4cxx::helpers::ObjectPtrT<log4cxx::Logger>in METISGraphParser.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [EnsembleClustering] Error 1
log4cxxを使い始めるには、何を含める必要がありますか?または、Eclipseビルド設定を変更してlog4cxxに明示的にリンクする必要がありますか?log4cxxの概要は、この点では特に役に立ちません。