Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After discussion: Here a description of what happened:</p> <p>If you use gcc and you have two files (lets say <code>f1.c</code> and <code>f2.c</code>), and in both files you declare:</p> <pre><code>int myGlobalVariable; </code></pre> <p>Then the following will happen:</p> <ul> <li>When compiling <code>f1.c</code> into <code>f1.o</code>, the object file will reserve space for <code>myGlobalVariable</code>.</li> <li>When compiling <code>f2.c</code> into <code>f2.o</code>, the object file will also reserve space for <code>myGlobalVariable</code>.</li> <li>When you link both object files together, the linker will detect that there are two variables called <code>myGlobalVariable</code> and will merge these variables together.</li> </ul> <p>Now it seems the <code>nvcc</code> compiler/linker is <strong>not</strong> able to merge these variables.</p> <p>The problem was, that the file <code>ILS.h</code> declares <code>&lt;some type&gt; p_instanceFragments;</code>. Because <code>ILS.h</code> is included into both <code>ILS.cu</code> and <code>Consensus.cu</code>, you get this variable twice and <code>nvcc</code> complains when it has to link the application.</p> <p>The solution is to declare <code>extern &lt;some type&gt; p_instanceFragments;</code> in <code>ILS.h</code> and then to define <code>&lt;some type&gt; p_instanceFragments;</code> either in <code>ILS.cu</code> <strong>or</strong> <code>Consensus.cu</code> (not in both). </p> <p>The question <a href="https://stackoverflow.com/questions/1433204/what-are-extern-variables-in-c/1433387">What are extern variables in C</a> has a rather extensive answer explaining all of this in detail.</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