CMake: Make a static library works but dynamic doesn't - c++

I am trying to make a shared library using CMake, but its wired that if I make it statically, it works well, but dynamic doesn't:
CMAKE_MINIMUM_REQUIRED(VERSION 3.6)
PROJECT(TestDemo)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_COMPILER clang++)
# Headers
INCLUDE_DIRECTORIES(src)
INCLUDE_DIRECTORIES(src/xxx)
INCLUDE_DIRECTORIES(3rdparty/zstd)
INCLUDE_DIRECTORIES(/usr/local/include)
# CORE LIB
FILE(GLOB CORE_SRC src/xxx/*.cpp
src/xxx/io/*.cpp
src/xxx/util/*.cpp
src/xxx/thread/*.cpp)
LIST(REMOVE_ITEM CORE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/xxx/io/BzipStream.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/xxx/io/GzipStream.cpp)
# This works
ADD_LIBRARY(xxx-core STATIC ${CORE_SRC})
# This doesn't
#ADD_LIBRARY(xxx-core SHARED ${CORE_SRC})
The error message is:
[100%] Linking CXX shared library libxxxdb-core.dylib
Undefined symbols for architecture x86_64:
"_mpool_get_global", referenced from:
xxx::mpoolxx<xxx::alloc_to_mpool_bridge<xxx::mpoolxx<long>, 1>::MemBlock>::get_vtab() in trb_cxx.cpp.o
"_sfixed_mpool_destroy", referenced from:
xxx::fixed_mpool_wrapper<24>::~fixed_mpool_wrapper() in trb_cxx.cpp.o
"_sfixed_mpool_init", referenced from:
xxx::fixed_mpool_wrapper<24>::fixed_mpool_wrapper() in trb_cxx.cpp.o
"_trb_destroy", referenced from:
xxx::trbstrmap_imp<int, unsigned char, &(xxx_trb_compare_less_tag), xxx::mpoolxx<long>, 0, 16>::~trbstrmap_imp() in trb_cxx.cpp.o
xxx::trbtab<int const, std::__1::pair<int const, int>, 0, &(xxx_trb_compare_less_tag), xxx::fixed_mpoolxx<long>, 0, 16>::~trbtab() in trb_cxx.cpp.o
"_trb_erase", referenced from:
xxx::trbtab<int const, std::__1::pair<int const, int>, 0, &(xxx_trb_compare_less_tag), xxx::fixed_mpoolxx<long>, 0, 16>::erase(int const&) in trb_cxx.cpp.o
xxx::trbtab<int const, std::__1::pair<int const, int>, 0, &(xxx_trb_compare_less_tag), xxx::fixed_mpoolxx<long>, 0, 16>::erase(xxx::trb_iterator<std::__1::pair<int const, int>, 16, 0>) in trb_cxx.cpp.o
"_trb_iter_first", referenced from:
xxx::trbtab<int const, std::__1::pair<int const, int>, 0, &(xxx_trb_compare_less_tag), xxx::fixed_mpoolxx<long>, 0, 16>::begin() const in trb_cxx.cpp.o
"_trb_iter_next", referenced from:
xxx::trb_iterator<std::__1::pair<int const, int>, 16, 0>::operator++() in trb_cxx.cpp.o
"_trb_probe", referenced from:
xxx::trbtab<int const, std::__1::pair<int const, int>, 0, &(xxx_trb_compare_less_tag), xxx::fixed_mpoolxx<long>, 0, 16>::insert(std::__1::pair<int const, int> const&) in trb_cxx.cpp.o
xxx::trbmap<int, int, &(xxx_trb_compare_less_tag), xxx::fixed_mpoolxx<long>, 0, 16>::operator[](int const&) in trb_cxx.cpp.o
"_trb_probe_node", referenced from:
xxx::trbstrmap_imp<int, unsigned char, &(xxx_trb_compare_less_tag), xxx::mpoolxx<long>, 0, 16>::probe_raw(char const*, unsigned long, char const*) in trb_cxx.cpp.o
"_trb_vtab_init", referenced from:
xxx::trbxx_vtab_init_by_cxx_type(trb_vtab*, field_type_t, int (*)(trb_vtab const*, trb_tree const*, void const*, void const*), int (*)(trb_vtab const*, trb_tree const*, void const*, void const*)) in trb_cxx.cpp.o
xxx::trbxx_vtab_init(trb_vtab*, field_type_t, int (*)(trb_vtab const*, trb_tree const*, void const*, void const*)) in trb_cxx.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

No linkage happens in the creation of a static library because a static library
is not produced by the linker: it is simply an archive of object files created
with the archiver ar. So there can't
be any undefined references or other linkage errors when you create a static library,
just like there can't be if you create a .tar or .zip archive of object files.
See static-libraries,
A shared library, like a program, is produced by the linker and the Mac OS/Darwin
linker (unlike the GNU/Linux linker) by default does not permit undefined symbol
references in a shared library.
You have two options:
You can specify all the libraries that xxx-core depends upon to its linkage,
with target_link_libraries
Or, you can override the linker's default behaviour with the linkage option
-undefined=dynamic_lookup, indicating
that undefined references in the shared library are to be resolved by the loader at runtime.
In your CMakeLists.txt, use set_target_properties
after you have defined the xxx-core target:
ADD_LIBRARY(xxx-core SHARED ${CORE_SRC})
SET_TARGET_PROPERTIES(xxx-core LINK_FLAGS Wl,-undefined=dynamic_lookup)

Related

QT Library imported in iOS native sdk

So the plan for this project is to have a QT library that can be used in a native SDK.
We have done a mock library that when imported in a QT App buit into a xcodeproj works without issues.
The library is static, running lipo -info returns x86_64 arm64.
I used the tutorial from https://alediaferia.com/2014/12/18/a-native-ios-app-with-a-qt-third-party-library/ but got stuck. After a bit of digging I got to the step where linking occurs this is the result:
Undefined symbols for architecture arm64:
"_pcre2_match_16", referenced from:
safe_pcre2_match_16(pcre2_real_code_16 const*, unsigned short const*, int, int, int, pcre2_real_match_data_16*, pcre2_real_match_context_16*) in libQt5Core.a(qregularexpression.o)
"_pcre2_match_context_create_16", referenced from:
QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
"_pcre2_jit_stack_assign_16", referenced from:
QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
"_pcre2_jit_stack_free_16", referenced from:
QThreadStorage<QPcreJitStackPointer*>::deleteData(void*) in libQt5Core.a(qregularexpression.o)
"_pcre2_get_ovector_pointer_16", referenced from:
QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
"_pcre2_match_data_free_16", referenced from:
QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
"_pcre2_config_16", referenced from:
QRegularExpressionPrivate::getPatternInfo() in libQt5Core.a(qregularexpression.o)
"_pcre2_pattern_info_16", referenced from:
QRegularExpressionPrivate::getPatternInfo() in libQt5Core.a(qregularexpression.o)
QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
"_pcre2_jit_compile_16", referenced from:
QRegularExpressionPrivate::optimizePattern() in libQt5Core.a(qregularexpression.o)
"_pcre2_match_context_free_16", referenced from:
QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
"_pcre2_compile_16", referenced from:
QRegularExpressionPrivate::compilePattern() in libQt5Core.a(qregularexpression.o)
"_pcre2_code_free_16", referenced from:
QRegularExpressionPrivate::~QRegularExpressionPrivate() in libQt5Core.a(qregularexpression.o)
QRegularExpressionPrivate::compilePattern() in libQt5Core.a(qregularexpression.o)
"_pcre2_jit_stack_create_16", referenced from:
safe_pcre2_match_16(pcre2_real_code_16 const*, unsigned short const*, int, int, int, pcre2_real_match_data_16*, pcre2_real_match_context_16*) in libQt5Core.a(qregularexpression.o)
"_pcre2_match_data_create_from_pattern_16", referenced from:
QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
"_uncompress", referenced from:
qUncompress(unsigned char const*, int) in libQt5Core.a(qbytearray.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How the project looks:
Does anyone know what is going on?
You're missing the linking to libqtpcre2
Add
-lqtpcre2
into your "OTHER LINKER FLAGS" in xcode's "build settings"

while buidling a project with CMAKE, I got "ld: symbol(s) not found for architecture x86_64"

I'm building a big project related to a simulation of a detector in physics.
I have to compile the project using CMAKE on macOS Sierra 10.12.5 and my processor architecture is 64-bits.
I built all the requirement programs using "homebrew".
I tried to compile in different CMAKE architecture modes:
cmake ../mu3e
cmake -DCMAKE_OSX_ARCHITECTURES=x86_64 ../mu3e
cmake -DCMAKE_OSX_ARCHITECTURES=i386 ../mu3e
cmake -DCMAKE_OSX_ARCHITECTURES="ppc;i386" ../mu3e
cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;i386" ../mu3e
../mu3e is the directory of the source.
I always ended up with the same or similar error regarding the "Undefined symbols for architecture x86_64:" and "ld: symbol(s) not found for architecture x86_64":
[ 66%] Built target mu3eAnaFibreTrackStat
[ 66%] Building CXX object mu3eAna/Fibres/CMakeFiles/mu3eAnaFibreAna.dir/fibreana.cpp.o
[ 67%] Linking CXX shared library libmu3eAnaFibreAna.dylib
Undefined symbols for architecture x86_64:
"HitStatistics::processFrame(std::__1::map<unsigned int, std::__1::vector<fibreAnaTypes::hit_t, std::__1::allocator<fibreAnaTypes::hit_t> >, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::vector<fibreAnaTypes::hit_t, std::__1::allocator<fibreAnaTypes::hit_t> > > > >*)", referenced from:
fibreAna::processFrame() in fibreana.cpp.o
"HitStatistics::HitStatistics(unsigned int)", referenced from:
fibreAna::setHitStat(bool) in fibreana.cpp.o
"TVersionCheck::TVersionCheck(int)", referenced from:
__GLOBAL__sub_I_fibreana.cpp in fibreana.cpp.o
"MPPCStatistics::processFrame(std::__1::map<unsigned int, std::__1::vector<fibreAnaTypes::sensor_t, std::__1::allocator<fibreAnaTypes::sensor_t> >, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::vector<fibreAnaTypes::sensor_t, std::__1::allocator<fibreAnaTypes::sensor_t> > > > >*)", referenced from:
fibreAna::processFrame() in fibreana.cpp.o
"MPPCStatistics::MPPCStatistics(unsigned int, unsigned int)", referenced from:
fibreAna::setMPPCStat(bool) in fibreana.cpp.o
"FibreStatistics::processFrame(std::__1::map<unsigned int, std::__1::vector<fibreAnaTypes::fibre_t, std::__1::allocator<fibreAnaTypes::fibre_t> >, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::vector<fibreAnaTypes::fibre_t, std::__1::allocator<fibreAnaTypes::fibre_t> > > > >*)", referenced from:
fibreAna::processFrame() in fibreana.cpp.o
"FibreStatistics::FibreStatistics(unsigned int, unsigned int, unsigned int)", referenced from:
fibreAna::setFibreStat(bool) in fibreana.cpp.o
"TrackStatistics::processFrame(std::__1::vector<fibreAnaTypes::track_t, std::__1::allocator<fibreAnaTypes::track_t> >*, std::__1::map<unsigned int, std::__1::vector<fibreAnaTypes::hit_t, std::__1::allocator<fibreAnaTypes::hit_t> >, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::vector<fibreAnaTypes::hit_t, std::__1::allocator<fibreAnaTypes::hit_t> > > > >*)", referenced from:
fibreAna::processFrame() in fibreana.cpp.o
"TrackStatistics::TrackStatistics()", referenced from:
fibreAna::setTrackStat(bool) in fibreana.cpp.o
"FibreEndStatistics::processFrame(std::__1::map<unsigned int, std::__1::vector<fibreAnaTypes::fibreend_t, std::__1::allocator<fibreAnaTypes::fibreend_t> >, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::vector<fibreAnaTypes::fibreend_t, std::__1::allocator<fibreAnaTypes::fibreend_t> > > > >*)", referenced from:
fibreAna::processFrame() in fibreana.cpp.o
"FibreEndStatistics::FibreEndStatistics(unsigned int, unsigned int, unsigned int)", referenced from:
fibreAna::setFibreEndStat(bool) in fibreana.cpp.o
"TChain::TChain(char const*, char const*)", referenced from:
fibreAna::fibreAna(char const*) in fibreana.cpp.o
"TClass::GetClass(std::type_info const&, bool, bool)", referenced from:
fibreAna::init() in fibreana.cpp.o
"TObject::operator delete(void*)", referenced from:
fibreAna::fibreAna(char const*) in fibreana.cpp.o
"TStorage::ObjectAlloc(unsigned long)", referenced from:
fibreAna::fibreAna(char const*) in fibreana.cpp.o
"TDataType::GetType(std::type_info const&)", referenced from:
fibreAna::init() in fibreana.cpp.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[2]: *** [mu3eAna/Fibres/libmu3eAnaFibreAna.dylib] Error 1
make[1]: *** [mu3eAna/Fibres/CMakeFiles/mu3eAnaFibreAna.dir/all] Error 2
make: *** [all] Error 2
When compiling in Ubuntu 16.04 LTS, everything works correctly, which might give you a hint why this is not working.
Thank you for any possible advice and please let me know if you need further information.

Dlib C++ library with Qt on macOS Sierra

I am using dlib c++ library with Qt on macOS Sierra. I can compile all examples from terminal and some examples with Qt. However, compiling some examples such as optimization with Qt throws below linker error:
Undefined symbols for architecture x86_64:
"_cblas_daxpy", referenced from:
dlib::blas_bindings::cblas_axpy(int, double, double const*, int, double*, int) in main.o
"_cblas_ddot", referenced from:
dlib::blas_bindings::cblas_dot(int, double const*, int, double const*, int) in main.o
"_cblas_dgemv", referenced from:
dlib::blas_bindings::cblas_gemv(dlib::blas_bindings::CBLAS_ORDER, dlib::blas_bindings::CBLAS_TRANSPOSE, int, int, double, double const*, int, double const*, int, double, double*, int) in main.o
"_cblas_dger", referenced from:
dlib::blas_bindings::cblas_ger(dlib::blas_bindings::CBLAS_ORDER, int, int, double, double const*, int, double const*, int, double*, int) in main.o
"_cblas_dscal", referenced from:
dlib::blas_bindings::cblas_scal(int, double, double*) in main.o
"_cblas_dtrsm", referenced from:
dlib::blas_bindings::cblas_trsm(dlib::blas_bindings::CBLAS_ORDER, dlib::blas_bindings::CBLAS_SIDE, dlib::blas_bindings::CBLAS_UPLO, dlib::blas_bindings::CBLAS_TRANSPOSE, dlib::blas_bindings::CBLAS_DIAG, int, int, double, double const*, int, double*, int) in main.o
"_dgetrf_", referenced from:
dlib::lapack::binding::getrf(int, int, double*, int, int*) in main.o
"_dpotrf_", referenced from:
dlib::lapack::binding::potrf(char, int, double*, int) in main.o
"_dsyevr_", referenced from:
dlib::lapack::binding::syevr(char, char, char, int, double*, int, double, double, int, int, double, int*, double*, double*, int, int*, double*, int, int*, int) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have also included in .pro file:
LIBS += -L/usr/local/lib\
-ldlib\
After installing LAPACK, BLAS, and CBLAS and including -lblas and -llapack in the .pro I got this error in addition to the error above:
warning: object file (/usr/local/lib/liblapack.a(iladlr.o)) was built for newer OSX version (10.12) than being linked (10.8)
Undefined symbols for architecture x86_64:
"__gfortran_concat_string", referenced from:
_dormtr_ in liblapack.a(dormtr.o)
_dormql_ in liblapack.a(dormql.o)
_dormqr_ in liblapack.a(dormqr.o)
"__gfortran_st_write", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_st_write_done", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_stop_string", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_string_len_trim", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_transfer_character_write", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_transfer_integer_write", referenced from:
_xerbla_ in libblas.a(xerbla.o)
It seems the new macOS already has LAPACK. You only need to include -lcblas and -lclapack in the .pro file. You may find them in /usr/lib or /usr/local/lib.
if in /usr/lib:
LIBS += -L/usr/lib\
-lcblas\
-lclapack\
-L/usr/local/lib\
-ldlib\
if in /usr/local/lib
LIBS += -L/usr/local/lib\
-lcblas\
-lclapack\
-ldlib\

ld: symbols not found for architecture x86_64, clang: linker command failed

I'm trying to use homebrew to download and build packages like boost, ceres-solver, stuff like that. What happens is that I will try and compile code, without any special flags (g++ foo.cpp -o foo -I /usr/local/... and I've tried clang++ too) and I get this error consistently:
Undefined symbols for architecture x86_64:
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So I looked around and the solution is to use the -stdlib=libstdc++ flag. I tried it, and now it gives me errors related to the fact that apple ships an old version of the libstdc++, doesn't get fixed by invoking -std=c++11 or -std=c++14. It throws up objections to C++11 syntax like the shared_ptr:
/usr/local/include/ceres/internal/port.h:62:12: error: no member named
'shared_ptr' in namespace 'std'
using std::shared_ptr;
~~~~~^
...
/usr/local/include/ceres/solver.h:629:15: error: expected member name or ';'
after declaration specifiers
shared_ptr<ParameterBlockOrdering> inner_iteration_ordering;
~~~~~~~~~~^
5 errors generated.
I'd rather not edit the library source code if I don't have to, I'd hope the devs have done a pretty good job?
Is there a way to build libraries (with or without homebrew) that will give the correct linking? Currently I just brew install <package> am I missing something obvious? Or am I screwing something up when I compile the code itself?
I'm on Mac OS X 10.10.5, and brew --config gives this:
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: 03ad27453de01adc29cbf941bd29a2dfb54a9960
Last commit: 69 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: 8-core 64-bit ivybridge
OS X: 10.10.5-x86_64
Xcode: 6.4
CLT: 6.4.0.0.1.1435007323
Clang: 6.1 build 602
X11: N/A
System Ruby: 2.0.0-p481
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby
Java: N/A
Running $arch gives: i386
and $clang++ -v gives:
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
I should add that I've tried cleaning out my computer in case there was an old version or something mucking things up. Everything I've seen says this error is caused by improper linking at build time, but it seems like brew does most of that properly, at least as far as I can tell? Everything installs and builds fine.
I've installed gcc using brew and tried to compile the library using the g++-5 and the gcc-5 command to avoid clang and I get the same problem when I try to pass the -std=c++11 flag at compile time - g++-5 foo.cpp -o foo -I /usr/local/bar -std=c++11. None of these work.
I should also emphasize that these happen when I try to compile and run the example scripts that come with, for example, boost, not even my own scripts. I'm just sort of hoping that the libraries are at least mostly correct.
I've also looked at a lot of similar questions here, many are unanswered and the ones that have solutions, well, I've tried many of the solutions and they don't help either. I've tried -lstdc++.6, I've tried -stdlib=libstdc++. The -l doesn't change anything, the -stdlib causes the issues I described above.
Any help I can get would be great, I've been working on this for weeks now and it's driving me nuts.
Quick Edit for clarity:
So when I input:
$g++ cerestest.cpp -o ceres -I /usr/local/include/eigen3
or
$clang++ cerestest.cpp -o ceres -I /usr/local/include/eigen3
I get:
Undefined symbols for architecture x86_64:
"ceres::Solve(ceres::Solver::Options const&, ceres::Problem*, ceres::Solver::Summary*)", referenced from:
_main in cerestest-ef733e.o
"ceres::Solver::Summary::Summary()", referenced from:
_main in cerestest-ef733e.o
"ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double*)", referenced from:
_main in cerestest-ef733e.o
"ceres::Problem::Problem()", referenced from:
_main in cerestest-ef733e.o
"ceres::Problem::~Problem()", referenced from:
_main in cerestest-ef733e.o
"google::LogMessage::stream()", referenced from:
ceres::AutoDiffCostFunction<CostFunctor, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::AutoDiffCostFunction(CostFunctor*) in cerestest-ef733e.o
ceres::internal::AutoDiff<CostFunctor, double, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::Differentiate(CostFunctor const&, double const* const*, int, double*, double**) in cerestest-ef733e.o
void ceres::internal::Make1stOrderPerturbation<ceres::Jet<double, 1>, double, 1>(int, double const*, ceres::Jet<double, 1>*) in cerestest-ef733e.o
void ceres::internal::Take0thOrderPart<ceres::Jet<double, 1>, double*>(int, ceres::Jet<double, 1> const*, double*) in cerestest-ef733e.o
void ceres::internal::Take1stOrderPart<ceres::Jet<double, 1>, double, 0, 1>(int, ceres::Jet<double, 1> const*, double*) in cerestest-ef733e.o
"google::LogMessageFatal::LogMessageFatal(char const*, int)", referenced from:
void ceres::internal::Make1stOrderPerturbation<ceres::Jet<double, 1>, double, 1>(int, double const*, ceres::Jet<double, 1>*) in cerestest-ef733e.o
void ceres::internal::Take0thOrderPart<ceres::Jet<double, 1>, double*>(int, ceres::Jet<double, 1> const*, double*) in cerestest-ef733e.o
void ceres::internal::Take1stOrderPart<ceres::Jet<double, 1>, double, 0, 1>(int, ceres::Jet<double, 1> const*, double*) in cerestest-ef733e.o
"google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)", referenced from:
ceres::AutoDiffCostFunction<CostFunctor, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::AutoDiffCostFunction(CostFunctor*) in cerestest-ef733e.o
ceres::internal::AutoDiff<CostFunctor, double, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::Differentiate(CostFunctor const&, double const* const*, int, double*, double**) in cerestest-ef733e.o
"google::LogMessageFatal::~LogMessageFatal()", referenced from:
ceres::AutoDiffCostFunction<CostFunctor, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::AutoDiffCostFunction(CostFunctor*) in cerestest-ef733e.o
ceres::internal::AutoDiff<CostFunctor, double, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::Differentiate(CostFunctor const&, double const* const*, int, double*, double**) in cerestest-ef733e.o
void ceres::internal::Make1stOrderPerturbation<ceres::Jet<double, 1>, double, 1>(int, double const*, ceres::Jet<double, 1>*) in cerestest-ef733e.o
void ceres::internal::Take0thOrderPart<ceres::Jet<double, 1>, double*>(int, ceres::Jet<double, 1> const*, double*) in cerestest-ef733e.o
void ceres::internal::Take1stOrderPart<ceres::Jet<double, 1>, double, 0, 1>(int, ceres::Jet<double, 1> const*, double*) in cerestest-ef733e.o
"google::InitGoogleLogging(char const*)", referenced from:
_main in cerestest-ef733e.o
"google::base::CheckOpMessageBuilder::ForVar2()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::MakeCheckOpString<int, int>(int const&, int const&, char const*) in cerestest-ef733e.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::MakeCheckOpString<int, ceres::DimensionType>(int const&, ceres::DimensionType const&, char const*) in cerestest-ef733e.o
"google::base::CheckOpMessageBuilder::NewString()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::MakeCheckOpString<int, int>(int const&, int const&, char const*) in cerestest-ef733e.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::MakeCheckOpString<int, ceres::DimensionType>(int const&, ceres::DimensionType const&, char const*) in cerestest-ef733e.o
"google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::MakeCheckOpString<int, int>(int const&, int const&, char const*) in cerestest-ef733e.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::MakeCheckOpString<int, ceres::DimensionType>(int const&, ceres::DimensionType const&, char const*) in cerestest-ef733e.o
"google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::MakeCheckOpString<int, int>(int const&, int const&, char const*) in cerestest-ef733e.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* google::MakeCheckOpString<int, ceres::DimensionType>(int const&, ceres::DimensionType const&, char const*) in cerestest-ef733e.o
"ceres::Solver::Summary::BriefReport() const", referenced from:
_main in cerestest-ef733e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And this is not just ceres, similar errors occur for boost also.
Thanks to Mark Setchell:
Keeping an eye on /usr/local/lib is important when using homebrew, the linking libraries need to be specified.
The final code that worked was this:
g++ cerestest.cpp -o ceres -lglog -lceres -I /usr/local/include
The same answer seems to work for the boost libraries, as well as all the others I've tried (Qt included, so far).

Apple Mach-O Linker (Id) Error in xcode

I am using xcode to work with SNAP package (http://memetracker.org).
When I Build, I get a few "Apple Mach-O Linker (Id) Error"
I read that I may have to add the right framework but I do not know how I can find what the right framework is.
Undefined symbols for architecture x86_64:
"_Env", referenced from:
_main in cliquesmain.o
"ExeStop(char const*, char const*, char const*, char const*, int const&)", referenced from:
TPt<TUNGraph>::operator->() const in cliquesmain.o
TVec<TVec<TInt, int>, int>::operator[](int const&) in cliquesmain.o
TVec<TInt, int>::operator[](int const&) in cliquesmain.o
TPt<TExcept>::operator->() const in cliquesmain.o
TRStr::GetNullRStr() in cliquesmain.o
TRStr::~TRStr() in cliquesmain.o
TVec<TInt, int>::operator[](int const&) const in cliquesmain.o
...
"WrNotify(char const*, char const*)", referenced from:
ErrNotify(char const*) in cliquesmain.o
"TCliqueOverlap::GetCPMCommunities(TPt<TUNGraph> const&, int, TVec<TVec<TInt, int>, int>&)", referenced from:
_main in cliquesmain.o
.....
Have you added this memetracker "library" correctly? Check out the tab "build phases", if not then there is probably your problem.
I assume you have the code/library in your project, so you have auto-completion, but to link this library you need to specify where to find it.