The example I'm trying to compile is from: http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/examples.html
(the chat example)
Here is what I'm using to make it:
>>> g++ chat_client.cpp chat_message.hpp
>>> g++ chat_server.cpp chat_message.hpp
This is what the terminal outputs:
% g++ chat_client.cpp chat_message.hpp
In file included from chat_client.cpp:17:
chat_message.hpp: In member function ‘void chat_message::encode_header()’:
chat_message.hpp:84: warning: format ‘%4d’ expects type ‘int’, but argument 3 has type ‘size_t’
ld: warning: in chat_message.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
"boost::system::generic_category()", referenced from:
__static_initialization_and_destruction_0(int, int)in cctJA2c1.o
__static_initialization_and_destruction_0(int, int)in cctJA2c1.o
"boost::thread::start_thread()", referenced from:
boost::thread::thread<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >(boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >, boost::disable_if<boost::is_convertible<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >&, boost::detail::thread_move_t<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > > >, boost::thread::dummy*>::type)in cctJA2c1.o
"boost::thread::join()", referenced from:
_main in cctJA2c1.o
"typeinfo for boost::detail::thread_data_base", referenced from:
typeinfo for boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >in cctJA2c1.o
"vtable for boost::detail::thread_data_base", referenced from:
boost::detail::thread_data_base::thread_data_base()in cctJA2c1.o
"boost::thread::~thread()", referenced from:
_main in cctJA2c1.o
_main in cctJA2c1.o
"boost::detail::thread_data_base::~thread_data_base()", referenced from:
boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data()in cctJA2c1.o
boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data()in cctJA2c1.o
"boost::system::system_category()", referenced from:
boost::system::get_system_category() in cctJA2c1.o
boost::system::error_code::error_code()in cctJA2c1.o
__static_initialization_and_destruction_0(int, int)in cctJA2c1.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Boost is installed correctly. I have another app that uses a couple of boosts bit features.
UPDATE:
this is the current command I'm using:
% g++ chat_client.cpp chat_message.hpp -lboost_asio -lboost_thread -o client -L/opt/local/lib/
says it can't find -lboost_asio
I looked in opt/local/lib (where boost is installed) and I don't see any libboost_asio.so or anything like that =\
You need to provide g++ boost libraries to link with usins -l option. I have a quick look on this examples and guess that you definitly need thread library. You can link with it using
g++ source.cpp -o executable -lboost_thread
Also you may need with boost_system library using
g++ source.cpp -o executable -lboost_thread -lboost_system
Related
OS -> OSX El Captain Version 10.11.6
Tried to install gRPC using the below commands:
git clone-b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc
cd grpc
git submodule update --init
make
I got the below error:
[HOSTCXX] Compiling src/compiler/cpp_plugin.cc
[HOSTLD] Linking /<path>/grpc/bins/opt/grpc_cpp_plugin
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
Undefined symbols for architecture x86_64:
"google::protobuf::io::StringOutputStream::StringOutputStream(std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*)", referenced from:
ProtoBufFile::CreatePrinter(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*) const in cpp_plugin.o
"google::protobuf::io::Printer::Print(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&, char const*)", referenced from:
ProtoBufPrinter::Print(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&, char const*) in cpp_plugin.o
"google::protobuf::FileDescriptor::GetSourceLocation(std::__1::vector<int, std::__1::allocator<int> > const&, google::protobuf::SourceLocation*) const", referenced from:
void grpc_generator::GetComment<google::protobuf::FileDescriptor>(google::protobuf::FileDescriptor const*, grpc_generator::CommentType, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*) in cpp_plugin.o
"google::protobuf::compiler::CodeGenerator::GenerateAll(std::__1::vector<google::protobuf::FileDescriptor const*, std::__1::allocator<google::protobuf::FileDescriptor const*> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::compiler::GeneratorContext*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) const", referenced from:
vtable for CppGrpcGenerator in cpp_plugin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/<path>/grpc/bins/opt/grpc_cpp_plugin] Error 1
This is what I have in
/<path>/grpc/libs/opt/ directory :
- libares.a
- libgpr.a
- libgrpc_cronet.a
- libgrpc_unsecure.a
- libboringssl.a
- libgrpc.a
- libgrpc_plugin_support.a
- pkgconfig
[EDIT]
After uninstalling protobuf and running make again I get the below warnings :
[LD] Linking /<path>/grpc/libs/opt/libgpr.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc_cronet.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc_unsecure.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++_cronet.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++_error_details.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++_reflection.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
[LD] Linking /<path>/grpc/libs/opt/libgrpc++_unsecure.dylib
ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
If I proceed with the installation by executing 'sudo make install', protobuf doesn't get installed and grpc_cpp_plugin doesn't work (gives the below error).
grpc_cpp_plugin: program not found or is not executable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.
[EDIT]
For the c-ares problem, i installed it using homebrew brew install c-ares. Then installed grpc grpc-1.3.0.tar.gz and protobuf libprotoc 3.2.0 without errors. But when i run make in the helloworld example, i'm getting the below error :
protoc -I ../../protos --cpp_out=. ../../protos/helloworld.proto
g++ -std=c++11 -I/usr/local/include -pthread -c -o helloworld.pb.o helloworld.pb.cc
protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/helloworld.proto
g++ -std=c++11 -I/usr/local/include -pthread -c -o helloworld.grpc.pb.o helloworld.grpc.pb.cc
g++ -std=c++11 -I/usr/local/include -pthread -c -o greeter_client.o greeter_client.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_client.o -L/usr/local/lib `pkg-config --libs grpc++ grpc` -lgrpc++_reflection -lprotobuf -lpthread -ldl -o greeter_client
Undefined symbols for architecture x86_64:
"grpc::CreateChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<grpc::ChannelCredentials> const&)", referenced from:
_main in greeter_client.o
"google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))", referenced from:
helloworld::protobuf_helloworld_2eproto::AddDescriptorsImpl() in helloworld.pb.o
"google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)", referenced from:
google::protobuf::internal::WireFormatLite::WriteStringToArray(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*) in helloworld.pb.o
"google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, google::protobuf::internal::ArenaStringPtr)", referenced from:
helloworld::HelloRequest::HelloRequest(helloworld::HelloRequest const&) in helloworld.pb.o
helloworld::HelloRequest::HelloRequest(helloworld::HelloRequest const&) in helloworld.pb.o
helloworld::HelloRequest::MergeFrom(helloworld::HelloRequest const&) in helloworld.pb.o
helloworld::HelloReply::HelloReply(helloworld::HelloReply const&) in helloworld.pb.o
helloworld::HelloReply::HelloReply(helloworld::HelloReply const&) in helloworld.pb.o
helloworld::HelloReply::MergeFrom(helloworld::HelloReply const&) in helloworld.pb.o
"google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)", referenced from:
helloworld::HelloRequest::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in helloworld.pb.o
helloworld::HelloReply::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in helloworld.pb.o
"google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)", referenced from:
google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) in helloworld.pb.o
"google::protobuf::internal::AssignDescriptors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::internal::MigrationSchema const*, google::protobuf::Message const* const*, unsigned int const*, google::protobuf::MessageFactory*, google::protobuf::Metadata*, google::protobuf::EnumDescriptor const**, google::protobuf::ServiceDescriptor const**)", referenced from:
helloworld::protobuf_helloworld_2eproto::(anonymous namespace)::protobuf_AssignDescriptors() in helloworld.pb.o
"google::protobuf::internal::fixed_address_empty_string[abi:cxx11]", referenced from:
google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]() in helloworld.pb.o
google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]() in greeter_client.o
"google::protobuf::Message::GetTypeName[abi:cxx11]() const", referenced from:
vtable for helloworld::HelloReply in helloworld.pb.o
vtable for helloworld::HelloRequest in helloworld.pb.o
"google::protobuf::Message::InitializationErrorString[abi:cxx11]() const", referenced from:
vtable for helloworld::HelloReply in helloworld.pb.o
vtable for helloworld::HelloRequest in helloworld.pb.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [greeter_client] Error 1
Thanks
It could be related with wrong or corrupted version of installed ProtoBuf, because if protobuf is installed and has version more than 3.0, than gRPC building system uses system's protobuf, instread thrird-party-protobuf from subrepo. Try to remove or fix protobuf in your system.
UPDATE:
For new issues try to run "readelf -s lib???.so" for each grpc and protobuf library, and try to find this symbols in libraries. If in some library is specified "UND", than it is wrong library.
Second things that you should do, run "file lib???.so" for each grpc and protobuf library for check binary type: x86_64 or not.
I have read a few related answers and some articles online as well as the official Google Test documentation, but since I lack experience in this area I am very insecure about a few things and seek guidance.
I am starting a brand new pet project in c++ and I want to write proper tests as I code along, ran into Google Test and decided to give it a try.
Currently this is my folder structure:
/
/bin
/main.cpp
/lib
/lib/db
/lib/external/googletest
My idea is to have the tests and class files in their own folders, for example:
/lib/db/db.h
/lib/db/db.cpp
/lib/db/db.test
Question #1
Is there a naming convention or expectation for the file containing the tests? (/lib/db/db.test in that example above)
Question #2
I ran the following commands
cd lib/external/googletest/googletest
cmake .
make
make install
cp lib*.a /usr/local/lib
cp -r include/gtest/ /usr/local/include/
And seeing how it ended up creating a series of .h files in /usr/local/include/gtest, I expected to be able to #include <gtest/gtest.h> and be able to run tests, I added this to my main.cpp:
TEST(Param1, Param2) {
EXPECT_EQ(1, 1);
}
and when building the following error showed up:
Undefined symbols for architecture x86_64:
"testing::AssertionSuccess()", referenced from:
testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&) in main-230b96.o
"testing::Test::SetUp()", referenced from:
vtable for Param1_Param2_Test in main-230b96.o
"testing::Test::TearDown()", referenced from:
vtable for Param1_Param2_Test in main-230b96.o
"testing::Test::Test()", referenced from:
Param1_Param2_Test::Param1_Param2_Test() in main-230b96.o
"testing::Test::~Test()", referenced from:
Param1_Param2_Test::~Param1_Param2_Test() in main-230b96.o
"testing::Message::Message()", referenced from:
Param1_Param2_Test::TestBody() in main-230b96.o
"testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)", referenced from:
Param1_Param2_Test::TestBody() in main-230b96.o
"testing::internal::AssertHelper::~AssertHelper()", referenced from:
Param1_Param2_Test::TestBody() in main-230b96.o
"testing::internal::GetTestTypeId()", referenced from:
___cxx_global_var_init in main-230b96.o
"testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)", referenced from:
___cxx_global_var_init in main-230b96.o
"testing::internal::IsTrue(bool)", referenced from:
testing::internal::scoped_ptr<std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::reset(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) in main-230b96.o
testing::internal::scoped_ptr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::reset(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) in main-230b96.o
"testing::internal::EqFailure(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:
testing::AssertionResult testing::internal::CmpHelperEQFailure<int, int>(char const*, char const*, int const&, int const&) in main-230b96.o
"testing::internal::AssertHelper::operator=(testing::Message const&) const", referenced from:
Param1_Param2_Test::TestBody() in main-230b96.o
"typeinfo for testing::Test", referenced from:
typeinfo for Param1_Param2_Test in main-230b96.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
Solution
Thanks to trojanfoe I fixed my makefile to look like this:
CC=g++
target_folder=bin
all:
$(CC) *.cpp -o $(target_folder)/prod
./bin/prod
test:
$(CC) *.cpp -o $(target_folder)/test lib/external/googletest/googletest/libgtest.a lib/external/googletest/googletest/libgtest_main.a
./bin/test
clean:
rm -f $(target_folder)/* *.o
And now it works just fine, please keep in mind that this is a skeleton project and I need to structure the test files and entry point, so at this point its just compiling a basic test.
You have forgotten to link-in the google test library with your executable.
I have been trying to link the very useful AssImp-library in my OpenGl project in Eclipse (CDT)
I successfully installed the AssImp library by following the answer to this question:
Trouble building the Open Asset Import Library (Assimp)
I also successfully set up OpenGl in Eclipse(CDT) by following the answer to this question:
OpenGL and GLUT in Eclipse on OS X
Now when i try to build some code where the AssImp-lib is being used the following error appears:
ld: warning: in /usr/local/lib/libassimp.a, file was built for unsupported file format which is not the architecture being linked (i386)
I guess the library is built for the wrong architecture ...
I tried filling in "i386"in the CMake's "CMAKE_OSX_ARCHITECTURES:" flag but this does not help in any way...
Ok I changed the architecture but it still gives some linking errors..
does anybody have the same errors ?
Undefined symbols:
"_get_crc_table", referenced from:
_unzOpenCurrentFile3 in libassimp.a(unzip.c.o)
"inflateInit2", referenced from:
Assimp::XGLImporter::InternReadFile(std::basic_string, std::allocator > const&, aiScene*, Assimp::IOSystem*)in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::basic_string, std::allocator > const&, aiScene*, Assimp::IOSystem*)in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
_unzOpenCurrentFile3 in libassimp.a(unzip.c.o)
"_inflateEnd", referenced from:
Assimp::XGLImporter::InternReadFile(std::basic_string, std::allocator > const&, aiScene*, Assimp::IOSystem*)in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::basic_string, std::allocator > const&, aiScene*, Assimp::IOSystem*)in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
_unzCloseCurrentFile in libassimp.a(unzip.c.o)
"_inflateSetDictionary", referenced from:
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
"_inflate", referenced from:
Assimp::XGLImporter::InternReadFile(std::basic_string, std::allocator > const&, aiScene*, Assimp::IOSystem*)in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::basic_string, std::allocator > const&, aiScene*, Assimp::IOSystem*)in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
_unzReadCurrentFile in libassimp.a(unzip.c.o)
"_crc32", referenced from:
_unzReadCurrentFile in libassimp.a(unzip.c.o)
_unzReadCurrentFile in libassimp.a(unzip.c.o)
"_inflateReset", referenced from:
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
Assimp::XFileParser::XFileParser(std::vector > const&)in libassimp.a(XFileParser.cpp.o)
ld: symbol(s) not found
I fixed the problem by adding the zlib library in the linker libraries -> add "z"
as suggested by gabor papp in the assimp-mailinglist
I am relatively new to C++, but I have used log4j (and it's Python clone logging). Therefore I want to use log4cxx for logging in my new C++ project.
I installed log4cxx with
brew install log4cxx
Now I need to include it in my source files. I tried, e.g.
#include "log4cxx/logger.h"
namespace EnsembleClustering {
METISGraphParser::METISGraphParser() {
// logging
log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("METISGraphParser"));
logger->setLevel(log4cxx::Level::getInfo());
this->logger = logger;
}
}
which does not seem to include enough, since this gives me the linker error
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
What do I need to include to get me started with log4cxx? Or do I need to explicitly link to log4cxx by modifying my Eclipse build settings? The Introduction to log4cxx isn't particularly helpful in this respect.
Here's how I managed to link log4cxx properly. Homebrew gives you a hint where it has installed the library:
cls ~/ $ brew info log4cxx
log4cxx: stable 0.10.0
http://logging.apache.org/log4cxx/index.html
Depends on: automake, libtool
/usr/local/Cellar/log4cxx/0.10.0 (182 files, 7,3M) *
https://github.com/mxcl/homebrew/commits/master/Library/Formula/log4cxx.rb
As user Component 10 has said, I need to add -L<dir>and -l<lib>to the linker line, where <dir> is /usr/local/Cellar/log4cxx/0.10.0/lib/and <lib> is the library name (not filename) log4cxx.
In Eclipse, I needed to edit the following settings:
To make this slightly simpler you can do
brew link log4cxx
It'll create the symlinks to the libraries in /usr/local/lib and /usr/local/include which are usually in the default linker/include search paths.
You'll still need to specify -llog4cxx.
I'm using OS X 10.7.3. I've been playing with the boost headers for a while now and i wanted to move onto using the Boost.Filesystem lib however it keeps throwing this message at me:
Undefined symbols for architecture x86_64:
"boost::system::generic_category()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccOhIhNG.o
boost::filesystem3::detail::create_directories(boost::filesystem3::path const&, boost::system::error_code*)in libboost_filesystem.a(operations.o)
boost::filesystem3::detail::canonical(boost::filesystem3::path const&, boost::filesystem3::path const&, boost::system::error_code*)in libboost_filesystem.a(operations.o)
"boost::system::system_category()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccOhIhNG.o
(anonymous namespace)::error(bool, boost::system::error_code const&, boost::filesystem3::path const&, boost::system::error_code*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in libboost_filesystem.a(operations.o)
(anonymous namespace)::error(bool, boost::filesystem3::path const&, boost::system::error_code*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in libboost_filesystem.a(operations.o)
(anonymous namespace)::error(bool, boost::filesystem3::path const&, boost::filesystem3::path const&, boost::system::error_code*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in libboost_filesystem.a(operations.o)
boost::filesystem3::detail::dir_itr_close(void*&, void*&)in libboost_filesystem.a(operations.o)
boost::filesystem3::detail::directory_iterator_increment(boost::filesystem3::directory_itera tor&, boost::system::error_code*)in libboost_filesystem.a(operations.o)
boost::filesystem3::detail::directory_iterator_construct(boost::filesystem3::directory_itera tor&, boost::filesystem3::path const&, boost::system::error_code*)in libboost_filesystem.a(operations.o)
...
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
i get this when i try to compile using this:
g++ -o test main.cpp -I -l/opt/local/include ~/boost/libs/libboost_filesystem.a
So i went back to the boost.org tutorials and tried out the regex example. It worked perfectly using this:
g++ -o test main.cpp -I -l/opt/local/include ~/boost/libs/libboost_regex.a
try
g++ -o test main.cpp -I/opt/local/include -L/opt/local/lib -lboost_filesystem
Your compiler flags seem a bit off. Generally, the following hold:
-I // Sets the path for the relevant header files
-L // Sets the path where your libraries reside
-l // specifies the library you want to link against.
So, if you have a library called mylib in ~/libs/ and need to use header files located in ~/include, you'd pass
-I ~/include -L ~/libs -lmylib
as flags to the compiler.