Ask Your Question
1

fatal error LNK1181: cannot open input file 'opencv_world311.lib'

asked 2017-12-19 07:33:56 -0600

Raki gravatar image

updated 2017-12-20 12:42:44 -0600

berak gravatar image

Hi,

I have followed this tutorial regarding installing OpenCV 3.0.0 with VS13 and I am trying to make my OpenCV 3.3.1 work but no luck, looked for 2 hours for a remedy, followed tons of tutorials but I keep getting the same error. I am using VS13 and Windows 10 64 bit.

fatal error LNK1181: cannot open input file 'opencv_world311.lib'

Before you ask: yes, I have added

C:\opencv\build\x64\vc14\bin

to my PATH. If that is the only thing to do there, this should be fine. (Haven't added anything to user variables, FYI)

UPDATE!

So I built everything from the source which I got from official Github page of OpenCV. I used CMAKE and VS to build and install. No error here at all.

I added the following to my environment variable and PATH, respectively:

C:\opencv\build\install\x64\vc12
%OPENCV_DIR%/bin

Then, I set the following as it was in every tutorial:

image description image description image description

And finally, this is the piece of code I am trying to build (yes, I need GPU support):

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"

int main(int argc, char* argv[])
{
    try
    {
        cv::Mat src_host = cv::imread("hdd.png", CV_LOAD_IMAGE_GRAYSCALE);
        cv::gpu::GpuMat dst, src;
        src.upload(src_host);

        cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);

        cv::Mat result_host;
        dst.download(result_host);

        cv::imshow("Result", result_host);
        cv::waitKey();
    }
    catch (const cv::Exception& ex)
    {
        std::cout << "Error: " << ex.what() << std::endl;
    }
    return 0;
}

And this time getting:

fatal error C1083: Cannot open include file: 'opencv2/opencv_modules.hpp': No such file or directory
edit retag flag offensive close merge delete

Comments

1

libs are in C:\opencv\build\x64\vc14\lib, and you have to add this to your ADDITONAL_LIBRARY_PATH in your linker settings (IDE), not to your PATH environment var, which is for the dlls.

then, the prebuilt libs are for VS2015 ONLY. if you want to use VS2013, you'll have to build the opencv libs from src, using cmake.

can you just update your VS ? (much easier for an obvious noob !)

berak gravatar imageberak ( 2017-12-19 07:48:39 -0600 )edit

I am bound to use VS13 due to a restriction. But okay, I'll have to then build opencv from src using cmake on Windows and retry again, and we shall see. Thanks.

Raki gravatar imageRaki ( 2017-12-19 09:45:35 -0600 )edit

Aaand this time: fatal error C1083: Cannot open include file: 'opencv2/opencv_modules.hpp': No such file or directory

Raki gravatar imageRaki ( 2017-12-20 09:04:51 -0600 )edit

does that happen, while compiling the libs ? (in other words, did you succeed building them ?)

if so, did you build the INSTALL project ? after that, all you need is in build/install. (and you need to rewire your original project to this, so it's using the newly built libs)

berak gravatar imageberak ( 2017-12-20 09:13:07 -0600 )edit
1

I updated the question for you @berak.

Raki gravatar imageRaki ( 2017-12-20 09:21:44 -0600 )edit
1

first, congrats, that you succeed building the libs !

it seems, you also have to adjust your "Additional Include Directories" to c:/opencv/build/install/include

(opencv2/opencv_modules.hpp should be in that folder, too !)

berak gravatar imageberak ( 2017-12-20 09:40:14 -0600 )edit

Perhaps you may wish to change the title of your post, to reflect the new error? :)

sjhalayka gravatar imagesjhalayka ( 2017-12-20 09:40:53 -0600 )edit
2

@berak Yes, that was the answer, it solved the problem. Also, the code which I took from the tutorial was not appropriate, instead this had to be used. So, if you post it as an answer, I can accept it.

Raki gravatar imageRaki ( 2017-12-20 09:48:35 -0600 )edit
1

i have another proposal ;)

maybe you could write up a short description of the steps you had to take ?

that would be the much better answer !! (especially, because the official tutorial is so outdated ...)

berak gravatar imageberak ( 2017-12-20 09:56:02 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-12-20 10:04:54 -0600

Raki gravatar image

updated 2017-12-20 10:06:03 -0600

The following steps were taken to solve the problem:

You need to download the Github source code of OpenCV from the official website if you want to use VS2013, since I had to build everything from the source. I used CMake to configure and generate the files. As for BUILD and INSTALL, VS2013 itself was used.

After that I took the steps which I showed above in the screenshots, but what I was missing, and was pointed out by @berak , was that I had to also add:

c:/opencv/build/install/include

into my Additional Include Directories.

After that I still got an error, but this time it was complaining about the gpu.hpp, with a quick search I found out that the code in the tutorial was not supposed to be used, instead the code below was supposed to be used (just to test) and ta da, after replacing the code I got everything running.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-12-19 07:33:56 -0600

Seen: 3,442 times

Last updated: Dec 20 '17