I have been trying to compile dlib library in visual studio.
So I created an empty project.
I added face_landmark_detection_ex.cpp and source.cpp from dlib/all folder into my project (I copied paste the aforementioned into "Source Files" in my project).
I added: C:\Users\user\Desktop\dlib2\dlib-19.4 and C:\Users\user\Desktop\dlib2\dlib-19.4\dlib\external\libjpeg and C:\Users\user\Desktop\dlib2\dlib-19.4\dlib\external\libpng into the include directory.
And added DLIB_PNG_SUPPORT and DLIB_JPEG_SUPPORT into the C/C++ -> Preprocessor -> Preprocessor Defintion.
the platform chosen is Active(win32).
Under Debugging -> Command Argument, I added the following arguments: C:\Users\user\Desktop\dlib2\dlib-19.4\shape_predictor_68_face_landmarks.dat C:\Users\user\Desktop\dlib2\dlib-19.4\examples\faces*.jpg
When trying to build the project I got the following errors:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _png_set_sig_bytes referenced in function "private: void __thiscall dlib::png_loader::read_image(char const *)" (?read_image#png_loader#dlib##AAEXPBD#Z) dlibTest c:\Users\user\documents\visual studio 2015\Projects\dlibTest\dlibTest\source.obj 1
Any help is much appreciated!!
You have to add the source files from the libpng and libjpeg folders too.
Related
I downloaded the sdk and ran the Windows related commands described here.
Then I created a new VC++ project and copied the contents of a tutorial file included with that sdk (t1.cpp).
There were compile time errors, which I fixed by including the path to gmsh.h in the include settings found in projcet->Properties->Configuration Properties->C/C++->General->Additional Include Directories.
I also included path to the gmsh.lib file at projcet->Properties->Configuration Properties->Linker->General->Additional Libraries Directories.
Still I am getting the below error while trying to build the project:
LNK2019: unresolved external symbol gmshFree referenced in function "int __cdecl gmsh::model::geo::addCurveLoop(class std::vector<int,class std::allocator<int> > const &,int,bool)" (?addCurveLoop#geo#model#gmsh##YAHAEBV?$vector#HV?$allocator#H#std###std##H_N#Z)
Please say what I am missing here. I am running Microsoft Visual Studio Community 2019 (Version 16.10.4) on Windows 10.
Did you add #include "gmsh.h " and add gmsh.lib in Configuration Properties > Linker > Input? For more information, you could refer to the document: Create a client app that uses the DLL.
In my on my header file (pages.h), I've done:
#include "mat.h".
In my cpp, all I'm trying to do is a simple:
MATFile *pmat.
However, whenever I try to build my code, I get an error that says:
1>pages.obj : error LNK2019: unresolved external symbol _matOpen referenced in function "public: void __thiscall DataPage::LoadDBIData(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadDBIData#DataPage##QAEXV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
and
1>C:\Users\celes\source\repos\bci2000-svn\tools\P300Classifier_electrode_selection\P300Classifier_electrode_selection.exe : fatal error LNK1120: 1 unresolved externals
I've tried going into Properties->C/C++->General->Additional Include Directories and adding a file path of C:\Program Files (x86)\MATLAB\R2015b\extern\include", but I am still receiving the same error. Without this included path, I only received the second error, not the first one.
I am using Visual Studio 2010 (it's for an old research lab) and R2015b for MATLAB.
Any sort of help would be appreciated!
The error message indicates that the compiler has trouble resolving the symbol. Apparently, you didn't set up the project correctly. Besides the "Additional Include Directories" option, you also need to set the library directory in the Linker-> Additional Library Directories for using an external library.
Because you are running a project in VS C++, you will need to have $(MATLABPATH)\extern\lib\<arch>\microsoft in that option, where $(MATLABPATH) is "C:\Program Files (x86)\MATLAB\R2015b" and the <arch> might be Win64 or Win32 depending on your target machine flag in your VS project (i.e. 32- or 64-bit).
Firstly, you could check if you add C:\Program Files (x86)\MATLAB\R2015b\extern\include in Porperties->VC++ Directories-> Include Directories, C:\Program Files (x86)\MATLAB\R2015b\extern\lib\winXX\microsoft in Porperties->VC++ Directories->Library Directories.
Secondly, you could check if you add libmat.lib;ibeng.lib;libmx.lib in Porperties->Linker->Input->Additional Dependencies.
Finally, you could refer to Microsoft Docs about LNK2019 and LNK1120.
I have a project I am trying to add google-test unit testing to. It is structured like so:
VM (project)
some source files
BytecodePrograms.h
VMTest (project, made by add project -> google test -> link dynamically, test VM)
pch.h
test.cpp
I added my VM project as an include directory in VMTest properties -> c/c++ -> general -> additional include directories
contents of test.cpp are:
#include "pch.h"
#include "BytecodePrograms.h"
TEST(TestCaseName, TestName) {
EXPECT_EQ(8, VMFibonacciImp(6));
EXPECT_TRUE(true);
}
If I build, I get the following errors
Error LNK2019 unresolved external symbol "public: __thiscall WVM::WVM(void)" (??0WVM##QAE#XZ) referenced in function "int __cdecl VMFibonacciImp(int)" (?VMFibonacciImp##YAHH#Z) WVMTest C:\Users\WadeMcCall\source\repos\Virtual Machine Visual Scripting\WVMTest\test.obj 1
Error LNK2019 unresolved external symbol "public: __thiscall WVM::~WVM(void)" (??1WVM##QAE#XZ) referenced in function "int __cdecl VMFibonacciImp(int)" (?VMFibonacciImp##YAHH#Z) WVMTest C:\Users\WadeMcCall\source\repos\Virtual Machine Visual Scripting\WVMTest\test.obj 1
Error LNK2019 unresolved external symbol "public: int __thiscall WVM::interpret(class std::vector<int,class std::allocator<int> >)" (?interpret#WVM##QAEHV?$vector#HV?$allocator#H#std###std###Z) referenced in function "int __cdecl VMFibonacciImp(int)" (?VMFibonacciImp##YAHH#Z) WVMTest C:\Users\WadeMcCall\source\repos\Virtual Machine Visual Scripting\WVMTest\test.obj 1
However, my VM project defines my WVM class and uses it and can build and run and BytecodePrograms.h includes VM.h which has the declaration for this class.
I feel like this must just be a problem with the set up of my projects in Visual Studio somehow, but I have no idea. I have been googling for 2 days straight and have found other people with similar problems but their solution never seems to work for me.
Any ideas? Thanks.
I found a solution here: https://stackoverflow.com/a/19709712/8488701
Similar to what Steve suggested, except instead of creating a whole new project, I use a post-build event to build my project to a library and then link google test to that. The advantage of this over Steve's solution is that you don't have to modify your main project at all and you can still build a unit testing project on top of it.
This is a link error indicating that it found the .h file but couldn't find the actual implementation found in the .cpp. If you have a LIB project then visual studio may take the cpp code compiled into the LIB project and add it to your EXE project.
To incorporate the code into the test project, you have two options.
You can add the .cpp files in your VM Project to your Test project as well, but this is not usually done.
Instead, if your VM project is now an EXE I would recommend creating a new project called VMLib as a LIB project and then adding that project to both the test project and the VM EXE project.
I am trying to build the BGSLibrary for Windows 10, cmake 3.9, with python support, built with opencv 3.1 and boost 1.64.0 with Visual Studio Community 2017.
Can someone more familiar with Visual Studio interpret this error for me. The c++ seems to compile great, but then project solution fails. It starts by building all the .obj files
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x86\Lib.exe /OUT:"C:\Users\Ben\Documents\bgslibrary\build\libbgs.lib" /NOLOGO /machine:X86 libbgs.dir\Release\AdaptiveBackgroundLearning.obj
2>libbgs.dir\Release\AdaptiveSelectiveBackgroundLearning.obj
2>libbgs.dir\Release\CodeBook.obj
2>libbgs.dir\Release\DPAdaptiveMedian.obj
2>libbgs.dir\Release\DPEigenbackground.obj
The general error reads.
5>libbgs.lib(LBSP.obj) : error LNK2019: unresolved external symbol "public: virtual void __thiscall cv::Feature2D::read(class cv::FileNode const &)" (?read#Feature2D#cv##UAEXABVFileNode#2##Z) referenced in function "[thunk]:public: virtual void __thiscall cv::Feature2D::read`vtordisp{4294967292,0}' (class cv::FileNode const &)" (?read#Feature2D#cv##$4PPPPPPPM#A#AEXABVFileNode#2##Z)
But the file LBSP.obj compiled fine just 100 lines earlier? I can see it here.
This file was created during the build, why can't it link? Where do I need to add this dir?
I'm reading other SO questions that this error may mean I need to add additional paths, which was done pre-VS2017 by going to PROPERTIES->LINKER->ADDITIONAL DEPENDENCIES. I don't see this option or structure anymore.
3>C:\Users\Ben\Documents\opencv\modules\core\include\opencv2/core/types_c.h(894)
This was a Cmake path error, not a Visual Studio error. Adding OpenCV/bin to path solved this.
I have visual studio 10 and mysql workbench installed.I have created a new win32 console application project and to include the files done the following:
in project properties under c/c++ -> general, I have added C:\Program Files\MySQL\MySQL Server 5.6\include
in linker -> general -> additional library directories I have added C:\Program Files\MySQL\MySQL Server 5.6\lib
in linker -> general -> input -> additional dependencies I have added libmysql.lib
i have copied libmysql.lib to system32 folder.
#include<iostream>
#include<my_global.h>
#include<mysql.h>
MYSQL* con=mysql_init(NULL);
MYSQL_RES* result;
the above code gives the following error->
error LNK2019: unresolved external symbol _mysql_init#4 referenced in function "void __cdecl `dynamic initializer for 'con''(void)" (??__Econ##YAXXZ)
1>c:\users\dell\documents\visual studio 2010\Projects\dmrc2\Debug\dmrc2.exe : fatal error LNK1120: 1 unresolved externals
unresolved external symbol this is linker error. In other words, your code is OK to compile but is not correct when attempting to link library into an executable because you input wrong library file name.
You need input library name instead of dll name.
In linker -> general -> input -> additional dependencies I have added libmysql.lib
place your libmysql.lib file in debug folder which is located in your project directory