Note that there are some explanatory texts on larger screens.

plurals
  1. POLinker error when moving function to a different file in VS2010 with Qt Add-in
    primarykey
    data
    text
    <p>I have a function to convert from one image representation (<code>MyImage</code>) to a <code>QImage</code>, and I decided it would be tidier to dedicate a namespace to functions that interface in this manner. I previously had this function directly in the class representing my main <code>QMainWindow</code>.</p> <p>So, I created a file <code>MyFormatToQtInterfacing.h</code> which looks as follows:</p> <pre><code>#include &lt;QtGui/QMainWindow&gt; #include &lt;qlabel.h&gt; namespace MyFormatToQtInterfacing { // These functions below convert a cv::Mat to a QImage. // Adapted from http://stackoverflow.com/questions/5026965/how-to-convert-an-opencv-cvmat-to-qimage // The grayscale ones seem to be inverted. Look into this later. QImage MyImage2QImage(const MyImage &amp;src) { //snip }; }; </code></pre> <p>I then call the function from this new namespace, as you would expect, and I get the following linker error:</p> <blockquote> <p>1>main.obj : error LNK2005: "class QImage _<em>cdecl MyFormatToQtInterfacing::Mat2QImage(class MyImage2QImage const &amp;)" (?MyImage2QImage@MyFormatToQtInterfacing@@YA?AVQImage@@ABV?$Mat</em>@V?$Vec@E$02@cv@@@cv@@@Z) already defined in moc_Tracker.obj</p> <p>1>Tracker.obj : error LNK2005: "class QImage _<em>cdecl MyFormatToQtInterfacing::MyImage2QImage(class MyImage2QImage const &amp;)" (?MyImage2QImage@MyFormatToQtInterfacing@@YA?AVQImage@@ABV?$Mat</em>@V?$Vec@E$02@cv@@@cv@@@Z) already defined in moc_Tracker.obj</p> <p>1>C:\Projects\Tracker\Tracker.exe : fatal error LNK1169: one or more multiply defined symbols found</p> </blockquote> <p>I've also been subbing out MyImage with OpenCV matrices and getting the same problem. Why is this happening and how can I resolve it?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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