Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't compile C++ in Ubuntu using GCC -- Include/Library Problems (collect2: ld returned 1 exit status)
    primarykey
    data
    text
    <p>I guess I'm not linking something right?</p> <p>I want to call <code>ABC.cpp</code> which needs <code>XYZ.h</code> and <code>XYZ.cpp</code>. All are in my current directory and I've tried <code>#include &lt;XYZ.h&gt;</code> as well as<code>#include "XYZ.h"</code>.</p> <p>Running <code>$ g++ -I. -l. ABC.cpp</code> at the Ubuntu 10 Terminal gives me:</p> <pre><code>`/tmp/ccCneYzI.o: In function `ABC(double, double, unsigned long)': ABC.cpp:(.text+0x93): undefined reference to `GetOneGaussianByBoxMuller()' collect2: ld returned 1 exit status` </code></pre> <p>Here's a summary of ABC.cpp:</p> <pre><code>#include "XYZ.h" #include &lt;iostream&gt; #include &lt;cmath&gt; using namespace std; double ABC(double X, double Y, unsigned long Z) { ...stuff... } int main() { ...cin, ABC(cin), return, cout... } </code></pre> <p>Here's XYZ.h:</p> <pre><code>#ifndef XYZ_H #define XYZ_H double GetOneGaussianByBoxMuller(); #endif </code></pre> <p>Here's XYZ.cpp:</p> <pre><code>#include "XYZ.h" #include &lt;cstdlib&gt; #include &lt;cmath&gt; // basic math functions are in std namespace but not in Visual C++ 6 //(comment's in code but I'm using GNU, not Visual C++) #if !defined(_MSC_VER) using namespace std; #endif double GetOneGaussianByBoxMuller() { ...stuff... } </code></pre> <p>I'm using GNU Compiler version <code>g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3</code>.</p> <p>This is my first post; I hope I included everything that someone would need to know to help me. I have actually read the "Related Questions" and the <a href="http://www.network-theory.co.uk/docs/gccintro/gccintro_22.html" rel="nofollow noreferrer">Gough article</a> listed in one of the responses, as well as searched around for the error message. However, I still can't figure out how it applies to my problem.</p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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