error LNK2019: unresolved external symbol MPI_INIT referenced in function

user1515769 picture user1515769 · Jul 18, 2012 · Viewed 12k times · Source

I am trying to compile a software package called FDMNES for X-ray Absorption Spectra Modelling with MPI for the first time in Windows, using Visual Studio 2010 and a trial version of the Intel Composer XE 2011 SP1, ifort visual fortran compiler in conjunction with Intel Parrelel Studio 2011. I have managed to get all the object files compiled using the 64-bit version of ifort, but when it comes dime to link the files I recieve the followed error:

1>------ Build started: Project: Console2, Configuration: Release x64 ------
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol MPI_INIT referenced in function MAIN__
1>main.obj : error LNK2019: unresolved external symbol MPI_COMM_SIZE referenced in function MAIN__
1>main.obj : error LNK2019: unresolved external symbol MPI_COMM_RANK referenced in function MAIN__
1>general.obj : error LNK2019: unresolved external symbol MPI_BCAST referenced in function RESEAU
1>potential.obj : error LNK2001: unresolved external symbol MPI_BCAST
1>main.obj : error LNK2001: unresolved external symbol MPI_BCAST
......etc
1>x64\Release\Console2.exe : fatal error LNK1120: 7 unresolved externals
1>
1>Build log written to  "file://C:\Users\Arturo\Documents\Visual Studio 2010\Projects\Console2\Console2\x64\Release\BuildLog.htm"
1>Console2 - 18 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I've tried linking to the 64bit Intel MPI libraries, as well as MPICH2 64bit libraries by adding the command /L"C:\PathtoMPILibrary\" but to no avail. I have also tried using this makefile, running with gmake from a mingw32 package:

#Make file for the fdmnes package
objects = main.obj clemf0.obj coabs.obj convolution.obj dirac.obj fdm.obj fprime.obj general.obj hubbard.obj lecture.obj mat.obj metric.obj minim.obj potential.obj scf.obj selec.obj spgroup.obj sphere.obj sub_util.obj tab_data.obj tddft.obj tensor.obj
compiler = mpif90 -O3 -c
fdmnes_mpi : $(objects)
    mpif90 -o fdmnes_mpi $(objects)
main.obj : main.f
    $(compiler) main.f 
clemf0.obj : clemf0.f
    $(compiler) clemf0.f
.....etc

But when I run gmake, I get the following error:

Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64,
Version 12.1.0.233 Build 20110811
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.

ifort: error #10037: could not find 'link'

I've exhausted forums, and I need this to be compiled with MPI under 64bit windows. Any help would be very much appreciated! Thanks.

Answer

towry picture towry · Sep 12, 2012

Here Microsoft give some explanations about Linker Tools Error LNK2019, hope this can help you.
Linker Tools Error LNK2019


Another way to solve this problem is go to the project's properties->linker->input->Additional
Dependencies, add what lib you need into here.
For example if you use timeGetDevCaps function and you get LNK2019 error, then you can add Winmm.lib into Additional Dependencies, after that, everything will be works fine.