Serialization problem

This is a discussion on Serialization problem within the C++ Programming forums, part of the General Programming Boards category; I am trying to make a Serialization Class here the code follows.
serialize.h http://pastebin.com/f1e82ff7f
Code:
//serialize.h
#ifndef SERIALIZE_H
#define SERIALIZE_H
...

serialize.h is include in the file that contains the main() and It also builds the serialize.o Object Module too But Cant find the reference to the methods.
I cant understand why any Help Please.
Thank you.

You may be compiling all of the source files (i.e., generating .o files for each .cpp file), but are you linking them all together? Can you describe how you're compiling the code? If you're using g++, you'll want something like this to link the object files into one executable:

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

It looks like the code from serialize.cpp isn't being linked into your executable for some reason, because the functions defined in that source file cannot be found by the linker.

I'm not really sure what's going on here. I'm pretty sure that the order of .o objects passed to g++ doesn't matter (unlike libraries). Perhaps a source file isn't being recompiled, but that shouldn't happen with automake.

The only thing I can suggest is to rebuild the whole thing, which you've probably already tried.

Code:

automake && autoconf
./configure
make clean
make

Using KDevelop shouldn't make any difference.

[edit] extern isn't necessary here.

If you want to test whether my theory of serialize.cpp not being included is correct, temporarily move the code from serialize.cpp to the end of the source file that main() is in. That should compile, but if it does, it means that serialize.cpp isn't being compiled . . . .

Can you post your autoconf and automake files? Not the generated ones, the input ones, like configure.in or configure.ac, and Makefile.am. [/edit]

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

No My code doesnt use any Namespace But I use the standered std namespace.
However I've done one more research on it never thought that I'll use geeky tools Like nm and objdump. I dont have much knowledge on them too.
I was testing wheather or not the serialize.o contains the load() and store methods. but I dont see that serialize.o contains those load() and store() methods may be thats due to static may be I donno how to see the nm or objdumpo output.

I can send you my email address if you like, but it's easier if you just send me a private message with your code or whatever. You can attach any file extension if you add .c or .txt onto the end. (i.e., rename code.zip to code.zip.txt and you can attach it.)

[edit] Just try compiling serialize.cpp yourself. cat it, make sure you have the right version. As you can see here, your basic idea should be working.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

However I'll be glad If you send me your email address.
I've filtered the Project and removed unnecessary Classes and files and made this KDevelop Project.
Its in a tar.gz archive containing a srz.kdevelop in it.Not to mention that It also gives that same Error LOL however different LIne Numbers cause I've removed some OffTopic Classes.
However I dont find the Option to Upload Files in PM so I've uploaded it in rapidshare plese download it from there.http://rapidshare.com/files/129694700/srz.tar.gz.html

I'm working on it. Your build system doesn't seem to be the problem -- compiling it by hand generates the same errors -- though your clock is in the future compared to mine, so I had to run "touch $(find)" to get it to work.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

I'm working on it. Your build system doesn't seem to be the problem -- compiling it by hand generates the same errors -- though your clock is in the future compared to mine, so I had to run "touch $(find)" to get it to work.

httputil.cpp: In function ‘int UrlEncode(const char*, char*, unsigned int)’:
httputil.cpp:90: error: ‘strchr’ was not declared in this scope
httputil.cpp: In function ‘std::string UrlDecodeString(const std::string&)’:
httputil.cpp:113: error: ‘malloc’ was not declared in this scope
httputil.cpp:117: error: ‘free’ was not declared in this scope
httputil.cpp: In function ‘std::string UrlEncodeString(const std::string&)’:
httputil.cpp:126: error: ‘malloc’ was not declared in this scope
httputil.cpp:130: error: ‘free’ was not declared in this scope

You need to include <cstring> and <cstdlib> there, and have using directives, for those functions as well.

The problem must be with your build system. This sample code compiles just fine:

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

The strange thing is that the commented-out throws give errors when this code is in srz.cpp. (failedToWrite() has only a default constructor, so of course it gives an error.) Yet, in serialization.cpp, the same code gives no errors at all.

The same thing happens if I compile the code by hand.

So it seems like serialization.cpp is jinxed or something. I created new.cpp, a new source file to hold the bodies of those two static functions. I got the same errors.

Moving main() to new.cpp, and leaving the function bodies in srz.cpp, creates the same errors. Grr. So main() has to be in the same file as those functions?

By the way, I finally got your code to compile by using this for serialization.h:

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell