I have version 2.6 of Google protobuffers installed via macports and gcc 4.8 and, when I compile my code (with the -lprotobuf flag), get the following link error:
Undefined symbols for architecture x86_64:
"google::protobuf::MessageLite::ParseFromString(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
_main in cclSIxVT.o
"google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))", referenced from:
protomessages::protobuf_AddDesc_msg_2eproto() in cc219IO6.o
"google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)", referenced from:
protomessages::DatabaseRequestInfo::SerializeWithCachedSizesToArray(unsigned char*) const in cc219IO6.o
"google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)", referenced from:
protomessages::DatabaseRequestInfo::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in cc219IO6.o
"google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)", referenced from:
protomessages::DatabaseRequestInfo::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in cc219IO6.o
"google::protobuf::DescriptorPool::FindFileByName(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const", referenced from:
protomessages::protobuf_AssignDesc_msg_2eproto() in cc219IO6.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
My LD_LIBRARY_PATH is correct (otherwise the -lprotobuf flag would not be recognised)
protoc --version returns 2.6.1
I am also compiling with the generated pb.o files so I don't think this is related to , what i know is a common omission.
The command in question I'm using is :
g++ -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-long-long -Wno-variadic-macros -Wno-deprecated -Wno-unused-function -Wno-vla -Wno-unused-variable -std=c++11 -o testbin util/myutil.o util/config.o util/MySemaphore.o network/jobMsg.o network/JobQueue.o network/Message.o network/protocolMsgs.o network/socket/receiver.o network/socket/sender.o blocks/Block.o cluster.o blocks/tc/MVTxCoord.o blocks/tc/StoredProcedure.o blocks/tc/TxCoord.o blocks/tc/IInGroupTC.o blocks/tc/InGroupTCFactory.o blocks/tc/DummyInGroupTC.o blocks/tc/2PLInGroupTC.o blocks/ds/DataService.o blocks/ds/MVDataService.o blocks/ds/HashTableIndex.o blocks/ds/Storage.o blocks/ds/IInGroupDS.o blocks/ds/InGroupDSFactory.o blocks/ds/DummyInGroupDS.o blocks/ds/2PLInGroupDS.o blocks/ds/Lock.o blocks/gm/GroupManager.o blocks/ts/TimestampServer.o blocks/client/Client.o blocks/client/ClientLib.o blocks/client/ClientEnv.o msg.pb.o microbenchmarks/main.o -L/opt/local/lib -lprotobuf -lpthread
I've checked that the library is compiled for 64 bits.
Non-fat file: /opt/local/lib/libprotobuf.a is architecture: x86_64
Any ideas where I am going wrong?
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'm trying to get OpenCV to work on my computer - for simple programs I can get it to work but for this certain program I'm unable to. The error I am getting is as follow:
Undefined symbols for architecture x86_64:
"cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
_main in ccuX28GE.o
"cv::split(cv::Mat const&, std::vector<cv::Mat, std::allocator<cv::Mat> >&)", referenced from:
computeFocusDPC(std::vector<R_image, std::allocator<R_image> >, int, float, int, int, int, int, cv::Mat*) in ccuX28GE.o
qDPC_loop(std::vector<cv::Mat, std::allocator<cv::Mat> >, std::vector<cv::Mat, std::allocator<cv::Mat> >, double) in ccuX28GE.o
"cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
_main in ccuX28GE.o
"cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in ccuX28GE.o
ld: symbol(s) not found for architecture x86_64
I'm trying to compile the file with the command line
g++-5.1.0 -o qDPC_desktop qDPC.cpp -I. -std=c++11 -ggdb -fopenmp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_stitching
I know that this error is not in the code of qDPC.cpp since it can compile on my friend's Ubuntu (I'm working on a Mac) - so I was wondering if there's something wrong with my OpenCV? I've read online online that it might be a linker problem but can't for the life of me figure this problem out. The version of OpenCV I have is 2.4.11, and the version my friend is able to compile with is 2.4.9.
All help is appreciated!
After upgrading to Mac OS X 10.9 / Xcode 5.0.1, command lines to create a shared library (.dylib) failed with several undefined symbols.
clang++ -dynamiclib -install_name test.dylib *.o -o test.dylib
Undefined symbols for architecture x86_64:
"std::allocator<char>::allocator()", referenced from:
_main in test.o
"std::allocator<char>::~allocator()", referenced from:
_main in test.o
"std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from:
_main in test.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
_main in test.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
_main in test.o
"std::ios_base::Init::Init()", referenced from:
___cxx_global_var_init in test.o
"std::ios_base::Init::~Init()", referenced from:
___cxx_global_var_init in test.o
"std::cout", referenced from:
_main in test.o
"std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
_main in test.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<<<char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
_main in test.o
ld: symbol(s) not found for architecture x86_64
The answer is there: https://mathematica.stackexchange.com/questions/34692/mathlink-linking-error-after-os-x-10-9-mavericks-upgrade
There are two implementations of the standard C++ library available on OS X: libstdc++ and libc++. They are not binary compatible and libMLi3 requires libstdc++.
On 10.8 and earlier libstdc++ is chosen by default, on 10.9 libc++ is chosen by default. To ensure compatibility with libMLi3, we need to choose libstdc++ manually.
To do this, add -stdlib=libstdc++ to the linking command.
Related post: Compiling with Clang using Libc++ undefined references
Edit: After some investigations it seems there is a link between the -mmacosx-version-min and the choice of the default libstd. If min version < 10.9, then the default libstd is equal to libstdc++, else to libc++. The long term solution is clearly to use -stdlib=libc++
Those suggestions did not work for me with Mac El capitan. If you have similar issues after upgrading to El Capitan, just run
xcode-select --install
before trying to compile
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.
I am currently trying to build some test code that uses Google C++ Test framework but I keep getting an error stating
ld: warning: in /usr/local/lib/libgtest.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
I have tried to make the issue as simple as possible:
I have a main function
cmtest.cc
#include <gtest/gtest.h>
/** Main entry point */
int main(int argc, char**argv, char**envArg)
{
testing::InitGoogleTest(&argc, argv);
return(RUN_ALL_TESTS());
}
really basic test code
CrazyTest.cc
#include <gtest/gtest.h>
TEST(CrazyTest, one) {
EXPECT_EQ(2, 2);
}
I use the following commands to build gtest and my test code.
g++ -o CrazyTest.o -c -Wall -Werror=non-virtual-dtor -pipe -std=c++98 -fno-rtti -fno-exceptions -fno-strict-aliasing -Wno-deprecated -g -arch i386 -arch x86_64 -mmacosx-version-min=10.5.4 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_RTTI=0 -I/opt/gtest-1.6.0/include CrazyTest.cc
g++ -o cmtest.o -c -Wall -Werror=non-virtual-dtor -pipe -std=c++98 -fno-rtti -fno-exceptions -fno-strict-aliasing -Wno-deprecated -g -arch i386 -arch x86_64 -mmacosx-version-min=10.5.4 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_RTTI=0 -I/opt/gtest-1.6.0/include cmtest.cc
g++ -o gtest-all.o -c -Wall -Werror=non-virtual-dtor -pipe -std=c++98 -fno-rtti -fno-exceptions -fno-strict-aliasing -Wno-deprecated -g -arch i386 -arch x86_64 -mmacosx-version-min=10.5.4 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_RTTI=0 -I/opt/gtest-1.6.0 -I/opt/gtest-1.6.0/include /opt/gtest-1.6.0/src/gtest-all.cc
ar rc libgtest.a gtest-all.o
ranlib libgtest.a
g++ -o cmtest -arch i386 -arch x86_64 -mmacosx-version-min=10.5.4 CrazyTest.o cmtest.o -lstdc++ -lgtest
The final build step gives me the following error and I am unable to figure out why. I am able to get the actual tests (not the simple one shown) to build on other OSs the mac OS (leopard) is giving me problems.
ld: warning: in /usr/local/lib/libgtest.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"testing::Test::~Test()", referenced from:
CrazyTest_one_Test::~CrazyTest_one_Test()in CrazyTest.o
CrazyTest_one_Test::~CrazyTest_one_Test()in CrazyTest.o
"testing::internal::AssertHelper::~AssertHelper()", referenced from:
CrazyTest_one_Test::TestBody() in CrazyTest.o
"testing::Test::Test()", referenced from:
CrazyTest_one_Test::CrazyTest_one_Test()in CrazyTest.o
"testing::internal::GetTestTypeId()", referenced from:
__static_initialization_and_destruction_0(int, int)in CrazyTest.o
"testing::Test::TearDown()", referenced from:
vtable for CrazyTest_one_Testin CrazyTest.o
"testing::internal::EqFailure(char const*, char const*, testing::internal::String const&, testing::internal::String const&, bool)", referenced from:
testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&)in CrazyTest.o
"testing::UnitTest::GetInstance()", referenced from:
_main in cmtest.o
"testing::internal::IsTrue(bool)", referenced from:
testing::internal::scoped_ptr<std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> > >::reset(std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >*)in CrazyTest.o
testing::internal::scoped_ptr<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::reset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)in CrazyTest.o
"testing::UnitTest::Run()", referenced from:
_main in cmtest.o
"testing::internal::AssertHelper::operator=(testing::Message const&) const", referenced from:
CrazyTest_one_Test::TestBody() in CrazyTest.o
"testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)", referenced from:
CrazyTest_one_Test::TestBody() in CrazyTest.o
"testing::AssertionSuccess()", referenced from:
testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&)in CrazyTest.o
"testing::Test::SetUp()", referenced from:
vtable for CrazyTest_one_Testin CrazyTest.o
"testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)", referenced from:
__static_initialization_and_destruction_0(int, int)in CrazyTest.o
"testing::InitGoogleTest(int*, char**)", referenced from:
_main in cmtest.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccZQiF8k.out (No such file or directory)
I have defined -arch i386 and -arch x86_64 for everything I have built so I am unable to figure out what I have missed. I don't do a lot of programming on Macs and this particular issue has me stuck.
Any suggestions would be helpful.
Solution found. It turns out that the build instructions used are correct the issue was that on the computer that the build was being performed another developer had done some work with Google Test Framework 1.5 and they had installed the libraries on the computer in the compilers search path. This resulted in the compiler finding the other library first that was not compiled using multiple architecture options.
Compile gtest and your project with the same compiler (-flags).
If you compiled gtest with Apple g++ and meanwhile installed gcc with e.g. homebrew, linking to gtest will cause this error. This is exactly the reason why Google advices to integrate gtest statically linked in your project, and not to use precompiled binaries.
You might also have this problem if gmock and gtest are out of sync. I had similar build errors with gmock-1.6.0 and gtest-1.7.0:
../../../third_party/gmock/build/libgmock.a(gmock-all.cc.o): In function `testing::internal::ParseGoogleMockFlagValue(char const*, char const*, bool)':
gmock-all.cc:(.text+0x3b5c): undefined reference to `testing::internal::String::Format(char const*, ...)'
../../../third_party/gmock/build/libgmock.a(gmock-all.cc.o): In function `testing::internal::String::operator==(char const*) const':
gmock-all.cc:(.text._ZNK7testing8internal6StringeqEPKc[testing::internal::String::operator==(char const*) const]+0x33): undefined reference to `testing::internal::String::Compare(testing::internal::String const&) const'
collect2: ld returned 1 exit status
Switching to both 1.7.0 or both 1.6.0 fixed the problem.