Note that there are some explanatory texts on larger screens.

plurals
  1. POMinGW linker can't find MPICH2 libraries
    text
    copied!<p>MPICH2 is installed in C:\Program Files\MPICH2. There are two subdirectories (of interest), <code>\include</code> which contains .h files, and <code>\lib</code> which contains .lib files.</p> <p>The readme that comes with MPICH2 has the following instructions:</p> <ol> <li>create a makefile</li> <li>add <code>–I...mpich2\include</code></li> <li>add <code>–L...mpich2\lib</code></li> <li>add <code>–lmpi</code></li> <li>add the rules for your source files</li> <li>compile</li> </ol> <p>Since there are no other rules in my project, I don't create a makefile, I just go to the command line and try compiling like this:</p> <pre><code>g++ -I"C:\Program Files\MPICH2\include" main.cpp -L"C:\Program Files\MPICH2\lib" -lmpi </code></pre> <p>This gives me a fistful of <code>undefined reference</code> errors on every single MPI symbol in the code. I spent hours trying to fix it, juggling <code>-I</code>, <code>-L</code> and <code>-l</code> switches around, shuffling the order of the parameters, even copied all the .lib files into the same directory as my source, but nothing seems to work.</p> <p>What kind of voodoo is needed to get this thing to link?</p> <hr> <p>EDIT: I think I found the problem: here's an excerpt of the linker's output in verbose mode (adding <code>-Wl,--verbose</code> to the compile command):</p> <pre><code>attempt to open C:\Program Files\MPICH2\lib/libmingwex.dll.a failed attempt to open C:\Program Files\MPICH2\lib/mingwex.dll.a failed attempt to open C:\Program Files\MPICH2\lib/libmingwex.a failed attempt to open C:\Program Files\MPICH2\lib/mingwex.lib failed attempt to open C:\Program Files\MPICH2\lib/libmingwex.dll failed attempt to open C:\Program Files\MPICH2\lib/mingwex.dll failed attempt to open C:\Program Files\MPICH2\lib\libmingwex.a failed </code></pre> <p>Apparently, the linker adds a <code>/</code> instead of a <code>\</code> to the directory names I supply it with (except when looking for the <code>lib___.a</code> format for some reason), which is obviously not a valid path. Is there any way to tell the linker to use backslashes instead of slashes?</p> <p>This also caught my eye:</p> <pre><code>attempt to open /mingw/lib/libmingwex.a succeeded </code></pre> <p>So I tried compiling like this:</p> <pre><code>g++ -I"/Program Files/MPICH2/include" -L"/Program Files/MPICH2/lib" objManager.cpp ongom.cpp io.cpp main.cpp -lmpi -lcxx </code></pre> <p>But I still get the same <code>undefined reference</code> errors.</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