0

I'm trying to set up a VS2015 solution I have with OpenCV 3.0.0, and I'm trying to do so using static libraries only.

Header files: the OpenCV header files are included correctly and I can reference them in my source files without issue.

Libraries: the static library file that was created for me when I used CMake to build OpenCV (called "ippicvmt.lib") is included correctly, and loads without issue.

Using OpenCV in code: when I try to use OpenCV classes/functions in my solution, I get linker errors when building similar to

LNK2001:  unresolved external symbol "public: virtual double __thiscall cv::VideoCapture::get(int)const

I can right-click and choose "Go to definition" on my use of this function and it opens videoio.hpp and shows the declaration of the virtual method. The linker error I see is likely caused by the inability for visual studio to find the actual implementation of the method in the static library I have included in my solution.

It is my understanding that the only .lib file I need to include is the one static library file. That is all I have included right now.

Does anybody know why VS can't find the implementations of this code in the OpenCV static library?

  • When you used CMake, did you specify if you wanted to build shared libs? It should have generated way more libs than just ippicvmt. Also, are you building a debug or release version? – Connor H Dec 03 '15 at 19:53
  • I'm currently trying to build for release, and the project settings are all for release build. I did not touch the CMake settings, so I'm not sure. Should I have it build shared libs? – janimationd Dec 03 '15 at 19:55
  • Remake the openCV solution and uncheck build shared libs. That will tell openCV to compile static libs rather than DLLs – Connor H Dec 03 '15 at 19:57
  • I see the other libs it generated in .../opencv/.../lib, my understanding is that these were only useful if I was going to use the .dll's – janimationd Dec 03 '15 at 19:58
  • That is incorrect. When building a program with static libraries, you need to link in more libraries. You can see this post for more info: http://stackoverflow.com/questions/16830842/using-static-libraries-instead-of-dynamic-libraries-in-opencv An easy fix would be to include all the non-debug libs (ones that don't end in d). You can also include just the ones you need, which I believe would be core300 and video300. Building a program with static libs is a pain, but once you get all of the libs you need linked then it isn't too bad. – Connor H Dec 03 '15 at 20:04
  • ok, I'm rebuilding without the shared libs, I will try what you have suggested. – janimationd Dec 03 '15 at 20:07

1 Answers1

0

I fixed my issue by disabling the flag for building with shared libs in CMake, after that way more .lib files show up in the sharedlib folder in my install. I added each .lib file I wanted to use to my additional dependencies in my project properties and my project built.