0
$\begingroup$

Rosanswers logo

I am trying to compile my ROS node. This node compiles perfectly fine in Unix (running ROS Electric). Now, I am trying to compile it in Mac (running ROS Fuerte). The node depends on Google Protobuf, and I have installed protobuf successfully and also compiled my .proto file successfully. However, when I try to make my ROS node, I get some errors:

Linking CXX executable bin/mylib Undefined symbols for architecture x86_64: "_main", referenced from: start in crt1.10.6.o "google::protobuf::DescriptorPool::generated_pool()", referenced from: protobuf::protobuf_AssignDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::DescriptorPool::FindFileByName(std::basic_string<char, std::char_traits, std::allocator > const&) const", referenced from: protobuf::protobuf_AssignDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)", referenced from: protobuf::protobuf_AssignDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o protobuf::CommandObj::MergeFrom(protobuf::CommandObj const&)in maverick_cmd.pb.o protobuf::CommandObj::MergeFrom(google::protobuf::Message const&)in maverick_cmd.pb.o

The list of errors continues for quite some time... it's doubtful that this helps, but here is the full list of errors...

Linking CXX executable bin/mylib Undefined symbols for architecture x86_64: "_main", referenced from: start in crt1.10.6.o "google::protobuf::DescriptorPool::generated_pool()", referenced from: protobuf::protobuf_AssignDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::DescriptorPool::FindFileByName(std::basic_string, std::allocator > const&) const", referenced from: protobuf::protobuf_AssignDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)", referenced from: protobuf::protobuf_AssignDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o protobuf::CommandObj::MergeFrom(protobuf::CommandObj const&)in maverick_cmd.pb.o protobuf::CommandObj::MergeFrom(google::protobuf::Message const&)in maverick_cmd.pb.o "google::protobuf::internal::LogMessage::operator, std::allocator > const&, google::protobuf::io::CodedOutputStream*)", referenced from: protobuf::CommandObj::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in maverick_cmd.pb.o "google::protobuf::internal::WireFormatLite::WriteFloat(int, float, google::protobuf::io::CodedOutputStream*)", referenced from: protobuf::CommandObj::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in maverick_cmd.pb.o "google::protobuf::internal::WireFormatLite::WriteDouble(int, double, google::protobuf::io::CodedOutputStream*)", referenced from: protobuf::CommandObj::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in maverick_cmd.pb.o "google::protobuf::internal::WireFormat::SerializeUnknownFields(google::protobuf::UnknownFieldSet const&, google::protobuf::io::CodedOutputStream*)", referenced from: protobuf::CommandObj::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in maverick_cmd.pb.o "google::protobuf::io::CodedInputStream::ReadVarint32Fallback(unsigned int*)", referenced from: protobuf::CommandObj::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in maverick_cmd.pb.o "google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::basic_string, std::allocator >*)", referenced from: protobuf::CommandObj::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in maverick_cmd.pb.o "google::protobuf::io::CodedInputStream::ReadLittleEndian32Fallback(unsigned int*)", referenced from: protobuf::CommandObj::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in maverick_cmd.pb.o "google::protobuf::io::CodedInputStream::ReadLittleEndian64Fallback(unsigned long long*)", referenced from: protobuf::CommandObj::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in maverick_cmd.pb.o "google::protobuf::internal::WireFormat::SkipField(google::protobuf::io::CodedInputStream*, unsigned int, google::protobuf::UnknownFieldSet*)", referenced from: protobuf::CommandObj::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in maverick_cmd.pb.o "google::protobuf::io::CodedInputStream::ReadTagFallback()", referenced from: protobuf::CommandObj::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in maverick_cmd.pb.o "google::protobuf::UnknownFieldSet::ClearFallback()", referenced from: protobuf::CommandObj::Clear() in maverick_cmd.pb.o "google::protobuf::UnknownFieldSet::~UnknownFieldSet()", referenced from: protobuf::CommandObj::~CommandObj()in maverick_cmd.pb.o protobuf::CommandObj::~CommandObj()in maverick_cmd.pb.o protobuf::CommandObj::~CommandObj()in maverick_cmd.pb.o protobuf::CommandObj::CommandObj(protobuf::CommandObj const&)in maverick_cmd.pb.o "google::protobuf::Message::~Message()", referenced from: protobuf::CommandObj::~CommandObj()in maverick_cmd.pb.o protobuf::CommandObj::~CommandObj()in maverick_cmd.pb.o protobuf::CommandObj::New() constin maverick_cmd.pb.o protobuf::CommandObj::~CommandObj()in maverick_cmd.pb.o protobuf::CommandObj::CommandObj(protobuf::CommandObj const&)in maverick_cmd.pb.o protobuf::CommandObj::CommandObj()in maverick_cmd.pb.o protobuf::CommandObj::CommandObj()in maverick_cmd.pb.o ... "google::protobuf::UnknownFieldSet::UnknownFieldSet()", referenced from: protobuf::CommandObj::New() constin maverick_cmd.pb.o protobuf::CommandObj::CommandObj(protobuf::CommandObj const&)in maverick_cmd.pb.o protobuf::CommandObj::CommandObj()in maverick_cmd.pb.o protobuf::CommandObj::CommandObj()in maverick_cmd.pb.o protobuf::protobuf_AddDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::internal::VerifyVersion(int, int, char const*)", referenced from: protobuf::protobuf_AddDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const*, int)", referenced from: protobuf::protobuf_AddDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::basic_string, std::allocator > const&))", referenced from: protobuf::protobuf_AddDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::internal::OnShutdown(void (*)())", referenced from: protobuf::protobuf_AddDesc_maverick_5fcmd_2eproto() in maverick_cmd.pb.o "google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(google::protobuf::Descriptor const*, google::protobuf::Message const*)", referenced from: protobuf::(anonymous namespace)::protobuf_RegisterTypes(std::basic_string, std::allocator > const&)in maverick_cmd.pb.o "google::protobuf::Message::GetTypeName() const", referenced from: vtable for protobuf::CommandObjin maverick_cmd.pb.o "google::protobuf::Message::InitializationErrorString() const", referenced from: vtable for protobuf::CommandObjin maverick_cmd.pb.o "google::protobuf::Message::CheckTypeAndMergeFrom(google::protobuf::MessageLite const&)", referenced from: vtable for protobuf::CommandObjin maverick_cmd.pb.o "google::protobuf::Message::DiscardUnknownFields()", referenced from: vtable for protobuf::CommandObjin maverick_cmd.pb.o "google::protobuf::Message::SpaceUsed() const", referenced from: vtable for protobuf::CommandObjin maverick_cmd.pb.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: *** [bin/mylib] Error 1 make[1]: *** [CMakeFiles/mylib.dir/all] Error 2 make: *** [all] Error 2

I'm thinking that the errors have something to do with the protobuf dependency. Also, I have a file in my node ./libs/libmylib.so, and I don't actually know what the purpose of this file is, but it is referenced in my CMakeLists.txt file...

rosbuild_add_library(mylib src/maverick_cmd.pb.cc)

Thanks for the help.


Originally posted by amittleider on ROS Answers with karma: 227 on 2012-05-27

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Are you linking against the protobuf library? Is it, per chance, only built for 32-bit (or only 64-bit) and you're building everything else using the other architecture?

(Tangential: why protobufs? ROS messages serve the same purpose...)


Originally posted by Mac with karma: 4119 on 2012-05-27

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by amittleider on 2012-05-27:
Could you expand a bit? It's possible that I am not linking against the protobuf library, but I'm not exactly sure how. On your other comment, I am using protobuf is because I am using a GUI written in Java and communicating through a socket with ROS. I am open to other solutions if you have them.

Comment by amittleider on 2012-05-27:
Could you expand a bit? It's possible that I am not linking against the protobuf library, but I'm not exactly sure how.

Comment by Mac on 2012-05-27:
ROSJava is a (potentially) better solution to that problem. Do you have a target_link_libraries somewhere in your CMakeLists?

Comment by amittleider on 2012-05-28:
ROSJava is a great idea! However, I am also having problems with that. I have also made a post about that issue here: http://answers.ros.org/question/34857/rosjava-on-macos-fail-to-build-roscore/ . I have target_link_libraries(publisher protobuf) in my CMakeLists. Is this correct?

Comment by amittleider on 2012-05-28:
Thanks a lot for the help, Mac. Your idea inspired me to add the line "rosbuild_add_library(publisher src/maverick_cmd.pb.cc)", which fixed the issue. I do agree that rosjava is a better solution, but this is my fallback in case I can't get that working.

Comment by Mac on 2012-05-28:
Glad I could help. Upvote and accept my answer? (Karma!)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.