Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 2.4.9, Visual Studio 10, the infamous LNK1104 error...

Greetings!

I'm checking out OpenCV as a possible solution to my needs for an optical ranging/orientation system, and have run into installation issues with OpenCV 2.4.9 on Visual Studio 2010 Professional. I don't generally have issues with setting up new development environments - I have toolchains for Atmel and Mircochip microcontrollers, SDKs for various platforms, etc. etc. etc. - but this is giving me fits.

I suspect I'm missing something stupidly simple but am just not seeing what it is...

My development environment is Visual Studio 2010 Pro SP1 on Windows 7 Ultimate x64 SP1. I get either LNK1104 (cannot open file) or LNK1107 (invalid/corrupt file) errors trying to compile a simple test program with OpenCV. My research on the 1104 error suggests a file path problem, and 1107 suggests the compiler is trying to load a DLL as a library.

What I've done to set up:

  1. My OpenCV root is:

    E:\Development\Development Tools\OpenCV

  2. My PATH environment variable is set to:

    %SystemRoot%\system32;%SystemRoot%;E:\Development\Development Tools\OpenCV\build\x64\vc10\bin;

  3. I'm working in debug/x64 mode in VS2010. All settings are relative to Active(Debug) config on Active(x64) platform in the project's properties.

  4. Project Properties > VC++ Directories > Include Directories reads:

    E:\Development\Development Tools\OpenCV\build\include

  5. Project Properties > VC++ Directories > Library Directories reads:

    E:\Development\Development Tools\OpenCV\build\x64\vc10\lib

  6. Project Properties > C/C++ > General > Additional Include Directories reads:

    E:\Development\Development Tools\OpenCV\build\include E:\Development\Development Tools\OpenCV\build\include\opencv E:\Development\Development Tools\OpenCV\build\include\opencv2

  7. Project Properties > Linker > General > Additional Library Directories reads:

    E:\Development\Development Tools\OpenCV\build\x64\vc10\lib

  8. Project Properties > Linker > Input > Additional Dependencies reads:

    opencv_core249d.dll

My simple "make sure it's working" application consists of a really simple file:

#include <opencv\cv.h>

using namespace cv;

int Main()
{
    return 0;
}

Compile fails with error LNK1104: cannot open file 'opencv_core249d.dll'. If I change the Additional Dependencies entry for that file to include a full path to the file, compile fails with error LNK1107: invalid or corrupt file: cannot read at 0x310, affecting opencv_core249d.dll.

I've gone all over the Internet trying to figure out why I'm having this issue, since as near as I can tell I have VS2010 pointed in the right direction in every place it's required, and I've rebooted a good dozen times thus far in case it's a "rebooting Windows fixes it" type of problem (read: environment vars not updating), but to no avail.

Any ideas on what I'm missing or where I should look next?