I have an C++ application (heavily shortened down, shown below);
#include <iostream>
#include "MyClass.h"
void foobar()
{
MyClass a;
}
int main(int argc, char** argv)
{
std::cout << "Hello world!\n";
return 0;
}
Where "MyClass" is defined in a statically linked library (.a).
However, this application Segfaults the instant its started, and I never get to the "Hello world".
I can create an instance of an interface from the same library, but I cannot create an instance of a class that implements the interface. I.e;
void foobar()
{
IMyClass a; // Having this in the application works.
MyClass b; // Segfault if this is in.
}
As you can see from above, the code doesn't even need to get called for the application to segfault.
I'm using Netbeans 6.7.1 and GCC 4.3.2.
Now, I'm presuming there is something wrong with the linking of the library but I cannot tell what. I'm linking in other libraries (all statically linked) as well. The classes above are from the first linked library (first in the list at least). If I create an instance of a class from the second listed library, everything runs fine.
It's possible that the problem is similar (or related) to my other problem: http://stackoverflow.com/questions/1844190/linking-with-apache-xml-security-causes-unresolved-references
Does anyone have any suggestions on what might be the problem?