I am using the boost libraries for a project, and I am running into issues with the regex library. I am re-installing the libraries because I have upgraded to osx 10.9 (mavericks).
I am getting 2 undefined references for :
boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > const&)
and
boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)
I am installing the boost libraries from source, specifically because I do not want to be using macports or any outside package installer. The reason is that my program is used in the mathematics and scientific community, and I am trying to keep it so that it can easily compiled from source with the appropriate dependencies (i.e. linking to certain libraries like gmp and mpfr, and, at least for now, boost).
The undefined reference issue is occurring regardless of the compiler I've used. That is, I have installed gcc 4.7.3 with apple's default compiler from the command line developer's tools. So this occurs for both gcc4.7.3 AND the default g++ (apple's clang, version 4.2.1).
This is a parallel application, so I have two versions of mpich3 installed, both compiled with the above 2 compilers and installed and built in separate directories.
When I built boost, I edited the user-config.jam file and added the lines
using gcc : 4.7.3 : "abs\loc\here" ;
and
using mpi ;
Then I ran sudo ./bootstrap.sh ; sudo ./b2 ; sudo ./b2 install (with the sudo being necessary as the installation files are in a /usr/local subdir)
Anyway, the file that is using the boost libraries is called para_aux_funcs.hpp / para_aux_funcs.cpp, and I am compiling with (well, after a Makefile that produces this for me to make all .o files from the .cpp ones ):
/usr/local/mpich3-mac-default/bin/mpic++ -cxx=/usr/local/bin/g++ -I/Users/matthewniemerg/Research/Bertini/Current/BertiniSource_v1.4/include -I/usr/local/boost_1_50_0/include -I../include -Dtimingstep2 -DTIXML_USE_STL -Wall -O3 -funroll-loops -fexpensive-optimizations -fopenmp -c para_aux_funcs.cpp -L/usr/local/boost_1_50_0/lib -lboost_regex -lboost_system -lboost_filesystem -o para_aux_funcs.o
I've also done this with the other mpi installation with the appropriate -cxx flag passed to indicate which compiler was used for the mpi compilation. And, I've also switch the order of where the -L and -l flags go in the above command, but with the same results.
That is, the following command gives me the undefined references indicated above:
/usr/local/mpich3-mac-default/bin/mpic++ -cxx=/usr/local/bin/g++ -I/Users/matthewniemerg/Research/Bertini/Current/BertiniSource_v1.4/include -I/usr/local/boost_1_50_0/include -I../include -Dtimingstep2 -DTIXML_USE_STL -Wall -O3 funroll-loops -fexpensive-optimizations -fopenmp -o paramotopy paramotopy.o point.o datagatherer.o failed_paths.o menu_cases.o master.o slave.o step2readandwrite.o runinfo.o mtrand.o random.o step2_funcs.o step1_funcs.o timing.o tinyxmlerror.o tinyxml.o tinystr.o tinyxmlparser.o xml_preferences.o para_aux_funcs.o ../lib/libbertini_osx9.a -lm -lmpfr -lgmp -L/usr/local/boost_1_50_0/lib -lboost_regex -lboost_system -lboost_filesystem
This looks like a linking error, but I am linking the libraries (i.e. -l flag) and pointing to the appropriate directories for where the library is located (i.e. -L flag) and indicating where the appropriate header files are (i.e. -I flag).
Any thoughts / ideas?
Related
I'm trying to link my program (gcc) with boost 1.70 (Wave specifically) and getting linker errors ("undefined reference").
I'm compiling boost into a static library with the following command with an addition flag BOOST_WAVE_SUPPORT_THREADING=0 (since threads support not needed in my case).
./b2 -j 8 toolset=gcc-7.2.0 cxxstd=17 link=static threading=multi runtime-link=static address-model=32 variant=release --without-python --stagedir=./linux/release stage
Compilation passes (few warnings).
Now, I'm building another static library (which uses wave). Same compiler and std is c++17 as previously. This one also builds successfully.
Third part is the actual executable which is linked to the previous static library and then linked to boost wave (actually system, wave, filesystem and regex). Compilation is also with std=17 (same results with std=c++11 btw). The error occurs at the linking phase of boost giving the following errors:
MyParserImplementation.cpp:(.text._ZN5boost4wave4impl19pp_iterator_functorINS0_7contextIN9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEENS0_8cpplexer12lex_iteratorINSE_9lex_tokenINS0_4util13file_positionINSH_11flex_stringIcSA_SB_NSH_9CowStringINSH_22AllocatorStringStorageIcSB_EES6_EEEEEEEEEENS0_26iteration_context_policies19load_file_to_stringE28advanced_preprocessing_hooksNS0_9this_typeEEEE12pp_directiveEv[_ZN5boost4wave4impl19pp_iterator_functorINS0_7contextIN9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEENS0_8cpplexer12lex_iteratorINSE_9lex_tokenINS0_4util13file_positionINSH_11flex_stringIcSA_SB_NSH_9CowStringINSH_22AllocatorStringStorageIcSB_EES6_EEEEEEEEEENS0_26iteration_context_policies19load_file_to_stringE28advanced_preprocessing_hooksNS0_9this_typeEEEE12pp_directiveEv]+0x301): undefined reference to `boost::wave::grammars::cpp_grammar_gen<boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > > >, std::__cxx11::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > >, boost::default_user_allocator_new_delete, std::mutex, 32u, 0u> > >::parse_cpp_grammar(boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > > > const&, boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > > > const&, boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > const&, bool&, boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > >&, std::__cxx11::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char*> > > >, boost::default_user_allocator_new_delete, std::mutex, 32u, 0u> >&)'
collect2: error: ld returned 1 exit status
(partial output)
As mentioned before, I've tried the same with std=c++11 and also with gcc 7.3.0 which is officially tested by boost for this version (stated in their website) with the same results.
It's also worth mentioning that when building the debug version of the libraries and executable, everything works fine.
edit:
here is the linking command:
g++ -O3 -DNDEBUG -std=c++17 -I /path/to/static/lib/myparser -I /path/to/boost/1_70_0 -lstdc++ -o bin/my_release/exe \
-L /path/to/static/lib/myparser/release -lmyparser -L /path/to/boost/1_70_0/linux/release/lib \
-l boost_system \
-l boost_wave \
-l boost_filesystem \
-l boost_regex \
Any idea what could be wrong?
Just happened to see this randomly - I ran into a similar problem today. The issue is that BOOST_WAVE_SUPPORT_THREADING=0 indirectly causes the fast pool allocator to use an internal null_mutex instead of std::mutex. The fix is to ensure you build the executable with the same BOOST_WAVE_SUPPORT_THREADING=0 and it should expect the null_mutex version instead.
I am trying to compile a program using cmake, and am seeing the following linker error:
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so:
undefined reference to
boost::filesystem::path_traits::convert(wchar_t const*, wchar_t
const*, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, std::codecvt<wchar_t, char, __mbstate_t>
const&)' /home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so:
undefined reference to
boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry
const&, std::__cxx11::basic_string,
std::allocator >&)'
The linker command that ninja generated looks like this:
g++ -pthread -DBOOST_ALL_DYN_LINK
utility/test/CMakeFiles/utilityTest.dir/loadCSVTests.cpp.o
utility/test/CMakeFiles/utilityTest.dir/main.cpp.o
utility/test/CMakeFiles/utilityTest.dir/randomDeviceTests.cpp.o -o
utility/test/utilityTest -rdynamic
/home/quant/bin/boost_1_61_0/stage/lib/libboost_thread.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_program_options.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_serialization.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_unit_test_framework.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_system.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_filesystem.so
utility/lib/libutilityLib.a utility/testLib/libutilityTestLib.a
utility/lib/libutilityLib.a
/home/quant/bin/boost_1_61_0/stage/lib/libboost_thread.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_program_options.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_serialization.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_unit_test_framework.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_system.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_filesystem.so
-Wl,-rpath,/home/quant/bin/boost_1_61_0/stage/lib
As you can see, I am linking against boost_filesystem and boost_system, so it's not the same problem as referenced on this SO post (and the many others like it).
I am using boost 1.61, which I compiled with gcc 5.3 (the same compiler as the one I'm compiling my program with).
What am I doing wrong?
I had a similar issue, this could be because of a new ABI which is introduced from gcc 5.1.
https://github.com/openframeworks/openFrameworks/issues/4203
I fixed mine by adding "add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)" to CMakeLists.txt
I'm trying to link Boost.Log statically into my program. Boost.Log has successfully compiled with other modules using bjam. However, when I try to link with my program I'm getting an error:
g++ -g -O2 -pthread -o sonar sonar-main.o sonar-config.o sonar-util.o sonar-logger.o /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_system.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_timer.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_iostreams.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_thread.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log_setup.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_filesystem.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_atomic.a -lcrypto -lssl
sonar-logger.o: In function `void boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::aligned_write<wchar_t>(wchar_t const*, long)':
/usr/include/boost/log/utility/formatting_ostream.hpp:702: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
/usr/include/boost/log/utility/formatting_ostream.hpp:696: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
sonar-logger.o: In function `void boost::log::v2s_mt_posix::type_dispatcher::callback_base::trampoline<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::expressions::aux::stream_ref<boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> > >&>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >(void*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
/usr/include/boost/log/utility/formatting_ostream.hpp:575: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
collect2: error: ld returned 1 exit status
I've compiled boost with the following:
./b2 --ignore-site-config -a -j9 --with-timer --with-system --with-chrono --with-iostreams --with-log --with-thread variant=debug link=static threading=multi
So far:
I've tried to troubleshoot it using this article (http://www.boost.org/doc/libs/1_60_0/libs/log/doc/html/log/rationale/namespace_mangling.html) that talks about how it could be a different namespace based on compiling. However, when I look in the libboost_log.a I can see functions named like so "void boost::log::v2s_mt_posix::aux::code_convert
This article (https://sourceforge.net/p/boost-log/discussion/710022/thread/2a7b5c0d/) says to make sure both BOOST_LOG_USE_CHAR and BOOST_LOG_USE_WCHAR_T are not defined. They are not.
Other articles say to define BOOST_LOG_DYN_LINK,but I'm using static libraries.
Here is how it's defined in my Makefile.am:
sonar_CPPFLAGS = -march=native -pipe -funroll-loops -fomit-frame-pointer -fforce-addr -fprefetch-loop-arrays -Wall -std=c++0x
sonar_SOURCES = main.cpp \
config.cpp \
config.hpp \
util.cpp \
util.hpp \
logger.cpp \
logger.hpp
sonar_LDADD = /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_system.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_timer.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_iostreams.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_thread.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log_setup.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_filesystem.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_atomic.a -lcrypto -lssl
sonar_LDFLAGS = -pthread
How can I nix this linker error?
You're likely including headers from an older version of Boost.
In 1.60, the code_convert series of functions are templated, but the error you're seeing is an undefined reference to a non-templated function.
I'm using a CamBoard Nano and Point Cloud Library in a C++ program. It uses a couple other libraries and one main C++ function as of right now. Someone else wrote the code for Windows, and I'm porting it over to Linux (Ubuntu 12.04). I've been able to get the C++ file to compile with a Makefile, but now I'm getting a ton of errors from the object file. I'm new to C++, and I don't understand what they all mean. It looks like they all stem from the same issue, hopefully one change will fix everything.
I was able to work out the errors in the C++ file by installing some Libraries (PCL, VTK, Eigen, OpenNI, etc.). I'll post what I can of the errors below, they fill up more than the entire terminal. I did look around on Google, and I found this: Qt 4.7 + VTK 5.6.1 on Mac OS X 10.6: errors linking projects
I downloaded QT 5.3, but when I use cmake on the example program I get the following error:
-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:20 (message):
VTK was not built with Qt
-- Configuring incomplete, errors occurred!
I'm trying to fix this now. I'll post my Makefile and errors below, so if anyone knows how to fix this or has advice, please let me know. Thanks!
Makefile:
CC = g++-4.4
CFLAGS = -I ../include -I ~/../../usr/include/pcl-1.7/ -I ~/../../usr/include/eigen3/Eigen/src -I ~/../../usr/include/vtk-5.8
# first location: pmd header files (include, back one directory)
# second location: your pcl header files
# third location: your eigen header files
# fourth location: your vtk header files
LDFLAGS = -L. -lpmdaccess2 -lc
all: main
main: main.cpp copysdk copyplugins
$(CC) $(CFLAGS) -c -o main.o main.cpp
$(CC) $(LDFLAGS) -o main main.o
copysdk:
cp ../bin/libpmdaccess* ./ # bin folder back one directory
copyplugins:
cp ../bin/camboardnano* ./
clean:
rm main
rm main.o
rm camboardnano*
rm libpmdaccess*
Example of Errors:
main.o: In function `bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0xcc): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x22d): undefined reference to `vtkActor2D::GetProperty()'
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x279): undefined reference to `pcl::visualization::PCLVisualizer::addActorToRenderer(vtkSmartPointer<vtkProp> const&, int)'
main.o: In function `bool pcl::visualization::PCLVisualizer::addPointCloud<pcl::PointXYZ>(pcl::PointCloud<pcl::PointXYZ>::ConstPtr const&, pcl::visualization::PointCloudGeometryHandler<pcl::PointXYZ> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer13addPointCloudINS_8PointXYZEEEbRKNS_10PointCloudIT_E8ConstPtrERKNS0_25PointCloudGeometryHandlerIS5_EERKSsi[bool pcl::visualization::PCLVisualizer::addPointCloud<pcl::PointXYZ>(pcl::PointCloud<pcl::PointXYZ>::ConstPtr const&, pcl::visualization::PointCloudGeometryHandler<pcl::PointXYZ> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x84): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
main.o: In function `vtkSmartPointer<vtkDataSet>::~vtkSmartPointer()':
These aren't all the errors, but all the errors that would fit in the terminal can be found here:
http://pastebin.com/jgbczK74
One of the things I noticed is that vtkSmartPointer came up a lot. I think that was the first header file that I was notified about when I was trying to compile the C++ code without the VTK library. Don't know if that means anything.
I would like to use the Library cpp-netlib for a C++ project. Therefore I installed the boost library with the help of homebrew (OS is Mac OS X 10.8). Then I downloaded cpp-netlib from the projects homepage, used cmake to create the Makefile for g++ and successfully applied make.
"make test" passed all its tests. Then I copied the include folder of cpp-netlib into the boost directory.
So here is when the trouble began:
I tried to compile the documentation's first example http-client but couldn't get it to work. When I used
g++ test.cpp -o out -I/usr/local/Cellar/boost/1.53.0/include
-L/usr/local/Cellar/boost/1.53.0/lib
-lboost_system-mt -lboost_filesystem-mt -lboost_thread-mt
I received these linker errors:
Undefined symbols for architecture x86_64:
"boost::network::uri::detail::parse(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::network::uri::detail::uri_parts<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)", referenced from:
boost::network::uri::uri::parse() in ccs87Dq3.o
"boost::network::http::impl::normal_delegate::normal_delegate(boost::asio::io_service&)", referenced from:
boost::network::http::impl::connection_delegate_factory<boost::network::http::tags::http_async_8bit_udp_resolve>::new_connection_delegate(boost::asio::io_service&, bool, boost::optional<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::optional<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >)in ccs87Dq3.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I really used the search function but I couldn't find any solution for my problem. What am I doing wrong?
Thanks a lot!
After building cpp-netlib (>=0.9.3) there should 3 static libraries:
libcppnetlib-client-connections.a
libcppnetlib-server-parsers.a
libcppnetlib-uri.a
When building your http-client project, you should specify a library path for cpp-netlib (-L) and libraries to link (-l) against: cppnetlib-uri and libcppnetlib-client-connections.
Here is what worked for me. You will need to modify certain parts to deal with different versions of boost, different install paths, and so on.
g++ -o demo \
demo.cpp \
-lcppnetlib-uri \
-lcppnetlib-server-parsers \
-lcppnetlib-client-connections \
-lboost_thread-mt \
-lboost_system-mt \
-lssl \
-lcrypto \
-I/usr/local/include \
-L/usr/local/lib
If you are writing server-side code then I imagine you will also need to include -lcppnetlib-server-parsers.
In case someone is having the same issue with visual studio, provide the library input to the linker.
Project properties > Linker > input >
libcppnetlib-client-connectionsd.lib
libcppnetlib-urid.lib
for Debug configuration and
libcppnetlib-client-connections.lib
libcppnetlib-uri.lib
for Release configuration.
Specify the Library path here,
Project properties > Linker > general > Additional include directories