Linking a DLLs in visual studio 2013 - c++

I've already looked for solution, without a success.
I need to use a DLL supplied by third parties on Visual Studio 2013(running on (x64) Windows 10).
On machine there are both OpenCV 3.0.0 and OpenCV2.410 installed and working.
The DLL's author has provided a .lib file and He says that in order to use this DLLs in your project, you need to put some others OpenCV's dlls in the project folder( I've tried to put these DLLs in every project folder[yes I know, it has no sense, but after a lot of tries i've lost my patience])
What he supplies is an .dll and an example project( that doesn't work for me because it needs OpenCV2.1 and there are instructions needs to be translate in newest version [and I prefered don't translate nothing]).
The errors in this example project are of this kind:
error LNK2001: unresolved external symbol
fatal error LNK1120: unresolved externals
The most of them are caused by the miss of OpenCV2.1, that I don't want to install, because I'll have to use it on a program using with OpenCV 3.0.0.
In the example project folder there are:
The upper mentioned .dll
A .lib file
The header file .h
These DLLs: cv210.dll, cxcore210.dll, highgui210.dll, ...(eg. cv210d.dll)
What I've done is this:
A folder called "lib" where I insert all .dll, .lib, .h files.
Put the "lib" folder in Project properties>linker> General> Additional Library Directories
Writing the .lib file in properties>linker> Input> Additional Dependencies
Put the 'lib' pathproperties>C/C++>Additional Include Directories[I know, this has no sense too]
I get these kind of errors:
error LNK2001: unresolved external symbol
I've tried #pragma comment(lib, 'file.lib') way too.
Someone can help me?

Related

Install OpenCV without lib file

I have a version of OpenCV built with MinGW and I'm trying to include it in a Visual Studio project. I have the dlls and the header files, however no lib files were provided. Only dll.a files. I tried pointing the linker additional dependencies setting to the dll.a files however I still get unresolved external symbol errors.
How do I use this version of OpenCV if it doesn't have the lib files?
Note: I should mention, I'm trying to use this specific build because it is x86, which is what I need for this project, and the official site doesn't seem to provide x86 builds.

Problems linking Nlopt-2.4.2 in visual studio 2017

Some back story: I am trying to get the bolt-lmm software to compile on a Windows machine, because it would be a nice addition to the research group I am in. The developers of the software have only made a linux static executeable, but made the source code available. I am used to programming in R or python, and this is my first ever encounter with C++.
I have solved a fair bit of problems, but for some reason I have not been able to get visual studio to link properly with Nlopt-2.4.2.
I downloaded it
and followed the steps given there on how to install it.
I can tell I have done the same to link the Nlopt library to the project as is described in How to add additional libraries to Visual Studio project?
I still get errors like:
Error LNK2019 unresolved external symbol __imp__nlopt_create referenced in function "public: __thiscall nlopt::opt::opt(enum nlopt::algorithm,unsigned int)" (??0opt#nlopt##QAE#W4algorithm#1#I#Z) boltCompiler C:\Users\au483192\source\repos\boltCompiled\boltCompiler\NonlinearOptMulti.obj 1
(there are a total of 12 of this type of error, and an error link 1120, which just tells me there are 12 unresolved eternals.)
I hope this is enough information to provide a hint of what is going wrong.
I did some more digging, and it seems the linker needed more than just the folder for the .lib file.
This post sums it up:
Linking a static library to my project on Visual Studio 2010
Essentially you just need to tell the linker the placement of the lib and the actual name of the .lib file.
Hopefully this will help others who forgot/did not know that added library names manually could be needed for some libraries.
TL;DR:
open configuration properties for the project > linker > general
Then add the path to the .lib file in the "addition library directories" line
Then (still in configuration properties) go to linker > input
add the .lib file name to the "addition dependencies" line, e.g. libnlopt-0.lib (don't forget to separate with ";")

Dlib LNK2001 unresolved external symbol USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2

I am trying to implement the DLIB 19.15 library to my app. I generated the dlib project for Windows Visual Studio 15 2017 Win64 and made a Release build using CMAKE.
In the project I have added directories and additional dependencies.
But during compilation I have following error
LNK2001 unresolved external symbol USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2
How Can I solve this problem?
Meet the same problem. You need to add one cpp file named dlib_path\dlib\all\source.cpp from the dlib source directory to your project and re-compile it. Do not copy it to your project path, just add it from dlib source directory.

OpenCV and Visual Studio 2015: Why is including the static library not working?

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?
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.

How to use libpng in Visual Studio?

I am using boost generic image library and it requires libpng. I built libpng and obtained the files libpng.lib, zlib.lib and libpngd.lib. When I tried to compile my project, Visual Studio gives a fatal error
fatal error LNK1120: 21 unresolved externals
with a bunch of unresolved external symbols like _png_set_sig_bytes and _png_read_row. What's going on here and how to solve it?
From MSDN:
https://msdn.microsoft.com/en-us/library/ba1z7822.aspx?f=255&MSPPError=-2147217396
To add .lib files as linker input in the development environment
Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
Click the Linker folder.
Click the Input property page.
Modify the Additional Dependencies property.
You must do this; explicitly specifying "libpng.lib", "zlib.lib" and "libpngd.lib" in your .exe's link command.
So this is coming from a complete simple minded moron so maybe this'll be helpful....it took me a little while to grasp. Basically, you're downloading the source code. That means, that you have to be the one to compile the source code.
Windows can compile programs that are written in C in the command prompt. You have to build the program, and it spits out a .dll or a .lib file. That or those are the files that you link to visual studio application.
You set dependencies to the header files which is usually like the source codes root folder or wherever all those .h files are.
You then set the linker to link to the .dll or .lib file(s). In Boost C++'s case, you need to link to a 'lib' folder.
I think what you need is to go over and completely grasp the basics. Here's a link from Microsoft on how Windows can compile C programs from the command prompt:
https://learn.microsoft.com/en-us/cpp/build/walkthrough-compile-a-c-program-on-the-command-line?view=vs-2019