Note that there are some explanatory texts on larger screens.

plurals
  1. POSegmentation fault when instantiating object from particular library
    text
    copied!<p>I have an C++ application (heavily shortened down, shown below);</p> <pre><code>#include &lt;iostream&gt; #include "MyClass.h" void foobar() { MyClass a; } int main(int argc, char** argv) { std::cout &lt;&lt; "Hello world!\n"; return 0; } </code></pre> <p>Where "MyClass" is defined in a statically linked library (.a). </p> <p>However, this application Segfaults the instant its started, and I never get to the "Hello world". </p> <p>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;</p> <pre><code>void foobar() { IMyClass a; // Having this in the application works. MyClass b; // Segfault if this is in. } </code></pre> <p>As you can see from above, the code doesn't even need to get called for the application to segfault. </p> <p>I'm using Netbeans 6.7.1 and GCC 4.3.2. </p> <p>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.</p> <p>It's possible that the problem is similar (or related) to my other problem: <a href="https://stackoverflow.com/questions/1844190/linking-with-apache-xml-security-causes-unresolved-references">https://stackoverflow.com/questions/1844190/linking-with-apache-xml-security-causes-unresolved-references</a></p> <p>Does anyone have any suggestions on what might be the problem?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload