title: DLL LNK2019 error (unresolved external error __imp)
body: <p>Well i basically inherited a bunch of code that i was told to fix because it used to work a few months ago but it doesn't at the moment. The program itself seems to be riddled with linking errors and i was able to fix some of them. However I have run across a LNK2019 unresolved external _<em>imp error where some function utilized in the main is not resolved. due to the "</em>_imp" i am assuming that it is a problem related to importing from .dll or .lib files. </p>
  
  <p>First of all i have three .lib files which i believe am importing them correctly into VS2010 and i have configured the platform to be 64x. There is also .dll files that correspond with the .lib files. The .h file that contains the declaration for these error ridden functions contain something like </p>
  
  <pre><code>ILAPI void ILAPIENTRY ilDeleteImage(const ILuint Num);
  </code></pre>
  
  <p>unfortunately i would be guessing that the definition is defined in the .dll file which i did not write myself so i am unsure. But since this is code that worked before i believe that i am getting this error because the linker can't find the definition rather than def/decl not matching reason.</p>
  
  <p>when i hover over the ILAPI it states: "ILAPI __declspec(dllimport)"
  My current guess is that the program imports the .lib files and the .lib files use the .dll files to get the definition of the functions. I believe that i am importing the .lib files since the compiler no longer keeps on telling me that it can't find specific .lib files. However i am concerned that it may not be connecting the the .dll files. I am some what unsure. I have opened the .lib files and the .lib files contain the names of the functions that are giving errors. I have also used the dependency walker program to look at my DLL files and it has been giving me some of the following errors:</p>
  
  <p>Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.</p>
  
  <p>Error: Modules with different CPU types were found.</p>
  
  <p>Based on other peoples comments i feel like i can ignore the 2nd error. But i am unsure of the first error. I am also unsure if that would be the root cause of the problem. It may or may not be. </p>
  
  <p>I have also looked inside the .lib files using VS cmd and dependency walker and it seems like the names of the functions that can't be found are listed in one of the .lib and .dll. </p>
  
  <p>In terms of configuration I am running on release mode x64 platform.
  I have added "DevIL.lib ILU.lib ILUT.lib " library functions in the proj -> prop -> linker -> commandline. I have also added the path for linker -> general -> additional library directory. I have also tried messing with input additional dependency but it has no effect. The .lib and .dll files are put in the same directory as well. In the proj property configuration i do not mention .dll anywhere (am i supposed to? I've tried in various locations but just creates more error) I understand that there are a ton of posts regarding link 2019 error but i have not had good luck so far in my search for my particular problem. I would appreciate any suggestions, comment, or a link where i may find a clue as in to why this is occuring</p>
  
  <p>here is the linker command from log:</p>
  
  <p>here is the linker command from the build log itself:      </p>
  
  <blockquote>
    <p>Link:
             C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:PROMPT /OUT:"x64\Release\dff.exe" /VERBOSE /INCREMENTAL /NOLOGO
    /LIBPATH:C:\Users\Sub2\Desktop\dff\x64\Release /MANIFEST
    /ManifestFile:"x64\Release\dff.exe.intermediate.manifest"
    /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG
    /PDB:"C:\Users\Sub2\Desktop\dff\x64\Release\dff.pdb"
    /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT
    /IMPLIB:"x64\Release\dff.lib" /MACHINE:X64
    x64\Release\dff.exe.embed.manifest.res
             x64\Release\acquisition.obj
             x64\Release\azmemutil.obj
             x64\Release\dff.obj
             x64\Release\fft.obj
             x64\Release\FocusMeasure.obj
             x64\Release\ge.obj
             x64\Release\stdafx.obj DevIL.lib ILU.lib ILUT.lib 
         1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification</p>
  </blockquote>
  
  <pre><code>    // This is from Win32's &lt;wingdi.h&gt; and &lt;winnt.h&gt;
      #if defined(__LCC__)
          #define ILAPI __stdcall
      #elif defined(_WIN32) //changed 20031221 to fix bug 840421
          #ifdef IL_STATIC_LIB
              #define ILAPI
          #else
              #ifdef _IL_BUILD_LIBRARY
                  #define ILAPI __declspec(dllexport)
              #else
                  #define ILAPI __declspec(dllimport)
              #endif
          #endif
      #elif __APPLE__
          #define ILAPI extern
      #else
          #define ILAPI
      #endif
  </code></pre>
  
  <p>Also:</p>
  
  <pre><code>    #define ILAPIENTRY __stdcall 
  </code></pre>
  
  <p>build log info when it gets close to error:</p>
  
  <pre><code>           Found KERNEL32_NULL_THUNK_DATA
               Referenced in kernel32.lib(KERNEL32.dll)
               Loaded kernel32.lib(KERNEL32.dll)
           Searching C:\Users\Sub2\Desktop\dff\x64\Release\DevIL.lib:
           Searching C:\Users\Sub2\Desktop\dff\x64\Release\ILU.lib:
           Searching C:\Users\Sub2\Desktop\dff\x64\Release\ILUT.lib:
           Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\MSVCRT.lib:
           Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\OLDNAMES.lib:
           Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\msvcprt.lib:
  
       Finished searching libraries
  
       Finished pass 1
  
  
       Invoking CVTRES.EXE:
        /machine:amd64
        /verbose
        /out:"C:\Users\Sub2\AppData\Local\Temp\lnk92ED.tmp"
        /readonly
        "x64\Release\dff.exe.embed.manifest.res"
       Microsoft (R) Windows Resource To Object Converter Version 10.00.30319.01
       Copyright (C) Microsoft Corporation.  All rights reserved.
  
       adding resource. type:MANIFEST, name:1, language:0x0409, flags:0x30, size:2
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_iluGetImageInfo referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_iluImageParameter referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilDeleteImages referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilSaveImage referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_iluFlipImage referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_iluScale referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilTexImage referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilCopyPixels referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilGetError referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilLoadImage referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilBindImage referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilGenImages referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilInit referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilGetInteger referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilEnable referenced in function main
   1&gt;dff.obj : error LNK2019: unresolved external symbol __imp_ilOriginFunc referenced in function main
   1&gt;x64\Release\dff.exe : fatal error LNK1120: 16 unresolved externals
   1&gt;Done Building Project "C:\Users\Sub2\Desktop\dff\dff.vcxproj" (rebuild target(s)) -- FAILED.
  </code></pre>
  
  <p>Build FAILED.</p>
  
  <p>Just in case i have also tried writing #define _IL_BUILD_LIBRARY but has no effect. </p>