I am getting an error 'Undefined Reference' and I cannot fix the problem. I am using Boost libraries and am trying to do serialization/deserialization.
Here is the code:
/usr/local/include/boost/serialization/access.hpp:118: undefined reference to `void Manifest::serialize<boost::archive::xml_iarchive>(boost::archive::xml_iarchive&, unsigned int)'
I have looked up other forums and most say to "forward declare" the class or namespace. I am not completely sure how this is done, but I also believe this isnt my problem.
Oh and I believe I have everything linked correctly. I have multiple projects that I have up and running of which are using boost libraries and using almost this exact same class, but they are working just fine. I have tried to replicate the class in this project and it does not work for some reason. I am using eclipse on xubuntu.
When compiling Manifest.cpp, how would the compiler know that some other file is going to attempt to link against Manifest::serialize<boost::archive::xml_iarchive>?
In short, don't put templates in .cpp files.
(or was this printed when compiling Manifest.cpp?)
This was printed when compiling...I am actually compiling a main.cpp of which references Manifest.h. I have a function which is called load_xml where I am passing the Manifest class as an argument.
Update:
I actually just got it to compile, but now eclipse is arguing that it cannot find the binary when I try to run the program.
I would say no. I have used these libraries multiple times in the past, for some reason I am running into this issue for the first time...I have a feeling that it has to do with either Eclipse not linking correctly. But I am not 100% sure on that.
Ok I see now...thank you. This seemed to fix my immediate problem.
I had no idea that you cant define the template in the cpp. It's odd because I have written templates like that for a while and I havnt come across that error until just now.