First try with serialization w/ boost library

Hi everyone, so my problem is with serialization and I am trying to implement this using the boost library.

Background info:
*Using Eclipse, but have netbeans installed
*I have been using mingw for my compiler, but I have cygwin and from what I can tell it isn't properly configured since gcc commands do nothing.
*I've installed the boost libraries and then in eclipse linked them.

The issue I am running into is I can not even get the sample boost serialization code to compile properly, so I can attempt to start doing this on my other projects.

The sample code that I have used can be found here.
http://www.boost.org/doc/libs/1_46_1/libs/serialization/doc/tutorial.html

When attempting to compile the code I receive the following errors when compiled with mingw

Description	Resource	Path	Location	Type
undefined reference to `boost::archive::basic_text_iprimitive<std::istream>::~basic_text_iprimitive()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::basic_text_oprimitive<std::ostream>::~basic_text_oprimitive()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_iarchive::~basic_iarchive()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_iarchive::load_object(void*, boost::archive::detail::basic_iserializer const&)'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_iserializer::~basic_iserializer()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_oarchive::save_object(void const*, boost::archive::detail::basic_oserializer const&)'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_oserializer::~basic_oserializer()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::shared_ptr_helper::~shared_ptr_helper()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::shared_ptr_helper::shared_ptr_helper()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::text_iarchive_impl(std::istream&, unsigned int)'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::ostream&, unsigned int)'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::serialization::extended_type_info::key_unregister() const'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::serialization::typeid_system::extended_type_info_typeid_0::~extended_type_info_typeid_0()'	try.cpp	/mingwTry	 	C/C++ Problem
undefined reference to `boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister()'	try.cpp	/mingwTry	 	C/C++ Problem



When compiled with cygwin I get even more errors.
Description	Resource	Path	Location	Type
make: *** [cygwinTry.exe] Error 1	cygwinTry		 	C/C++ Problem
undefined reference to `boost::archive::basic_text_iprimitive<std::basic_istream<char, std::char_traits<char> > >::~basic_text_iprimitive()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_iarchive::~basic_iarchive()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_iarchive::load_object(void*, boost::archive::detail::basic_iserializer const&)'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_iserializer::~basic_iserializer()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_iserializer::basic_iserializer(boost::serialization::extended_type_info const&)'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_oarchive::save_object(void const*, boost::archive::detail::basic_oserializer const&)'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_oserializer::~basic_oserializer()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::basic_oserializer::basic_oserializer(boost::serialization::extended_type_info const&)'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::shared_ptr_helper::~shared_ptr_helper()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::detail::shared_ptr_helper::shared_ptr_helper()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::text_iarchive_impl(std::basic_istream<char, std::char_traits<char> >&, unsigned int)'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::serialization::extended_type_info::key_unregister() const'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::serialization::typeid_system::extended_type_info_typeid_0::~extended_type_info_typeid_0()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem
undefined reference to `boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister()'	cygwinTry.cpp	/cygwinTry	 	C/C++ Problem



Now I've only used MinGW to compile stuff previously and I've never had any errors like this, so I really don't know where to begin. I get the feeling it is somehow related to how I am linking the library to the project, but I really have no idea.
Yes, it sounds like you aren't linking against the serialization library. (you are including the header files for it, but you aren't linking the final executable against it).
Do you know what I could be doing wrong?

For MinGW I have it "linked" like this.
http://i.imgur.com/EsZwq.jpg
http://i.imgur.com/x7b9s.jpg

Without the library location linked in the source path(vs. just the library path tab) for MinGW it simply says my header files don't exist.

I'll reply with Cygwin results later since I need to reinstall it.
With Cygwin linked in the same way, I still get the same list of errors. Any ideas?
And the Libraries tab?
For previous builds I did not have anything under the Libraries tab. I added a few .dll files to the list and now the compiler lists them as not found.
http://i.imgur.com/NPplq.jpg

Console Output

**** Build of configuration Release for project cygwinTry ****

make all 
Building file: ../cygwinTry.cpp
Invoking: Cygwin C++ Compiler
g++ -I"C:\Program Files (x86)\boost\boost_1_44" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"cygwinTry.d" -MT"cygwinTry.d" -o"cygwinTry.o" "../cygwinTry.cpp"
cygwin warning:
  MS-DOS style path detected: C:\Users\Eric\workspace\cygwinTry\Release
  Preferred POSIX equivalent is: /cygdrive/c/Users/Eric/workspace/cygwinTry/Release
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Finished building: ../cygwinTry.cpp
 
Building target: cygwinTry.exe
Invoking: Cygwin C++ Linker
g++ -L"C:\Program Files (x86)\boost\boost_1_44" -o"cygwinTry.exe"  ./cygwinTry.o   -l"C:/Program\ Files\ (x86)/boost/boost_1_44/lib/boost_wserialization-vc90-mt-gd-1_44.dll" -l"C:/Program\ Files\ (x86)/boost/boost_1_44/lib/boost_wserialization-vc100-mt-1_44.dll" -l"C:/Program\ Files\ (x86)/boost/boost_1_44/lib/boost_wserialization-vc100-mt-gd-1_44.dll" -l"C:/Program\ Files\ (x86)/boost/boost_1_44/lib/boost_serialization-vc100-mt-gd-1_44.dll"
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lC:/Program\ Files\ (x86)/boost/boost_1_44/lib/boost_wserialization-vc90-mt-gd-1_44.dll
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lC:/Program\ Files\ (x86)/boost/boost_1_44/lib/boost_wserialization-vc100-mt-1_44.dll
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lC:/Program\ Files\ (x86)/boost/boost_1_44/lib/boost_wserialization-vc100-mt-gd-1_44.dll
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lC:/Program\ Files\ (x86)/boost/boost_1_44/lib/boost_serialization-vc100-mt-gd-1_44.dll
collect2: ld returned 1 exit status
make: *** [cygwinTry.exe] Error 1
First, reconcile the version of boost with the documentation you are using.

Then go find the files. Verify their location and the location you are trying to link with.
Well I have Boost 1.46.1 installed which is the most recent version and am using the documentation off their website.

I'm not sure I understand what you mean. I'm selecting the boost directory that the boost files are located in.

Let's talk about the compiler for a second: GCC (g++). There are three parameters of interest when using a library. man gcc for more information.

1) -I specifies an include path: the place(s) to be searched when it encounters a #include <>
2) -L specifies a library path: the place(s) to be searched for a library
3) -l specifies a library to link with

You can use -l and specify the entire path and file name of the library file or you can use -L to specify a path and -l to specify the file name.

Note that it won't just figure out what to link with on it's own. You need to know what file you are trying to link with first, then you need to know where it is, then you need to tell the compiler.

The IDE is providing a tab for each of these parameters. Hope this helps.
Last edited on
Topic archived. No new replies allowed.