Note that there are some explanatory texts on larger screens.

plurals
  1. POc compiler error with linking
    text
    copied!<p>Here is the error I get from the <code>gcc</code> call:</p> <pre><code>gcc -o rr4 shells2.c graph1.c rng.c; Undefined symbols: "_getdisc", referenced from: _main in cckR7zjP.o ld: symbol(s) not found </code></pre> <p>The "cckR7zjP.o" keeps changing every time I call the compiler. The code for the method is in the file <code>graph1.c</code>; its header file is called <code>graph2.h</code>, and I am importing it to the file with the main method called <code>shells2.c</code> using:</p> <pre><code>#include "graph2.h" </code></pre> <p>The method or function definition is:</p> <pre><code>int getdisc(int i){ return disc[i];} </code></pre> <p>which attempts to return the i<sup>th</sup> member of the array disc created by </p> <pre><code>static int *disc; </code></pre> <p>that I already initialized in some other method! I think the problematic call is:</p> <pre><code>for (iter = 0; iter &lt; n; iter++) { if (getdisc(iter) == cln) avgbtwn += get_betweenness(iter); } </code></pre> <p>This seems like a linker problem I checked with some other questions, and I think I am linking my method properly (and am using the same method elsewhere in the code) but I still can't figure this out.</p> <p>Edit: So I switched the order of the command in linux to </p> <pre><code>gcc -o rr4 graph1.c rng.c shells2.c </code></pre> <p>as per Soren's suggestion and the function compiled as normal, does anyone know why? Further it seems when i put a trailing line break in the file graph1.c alleviates 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