mysql connection with visual studio c++ - c++

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

Related

Problems with linking MATLAB and Visual Studios

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.

Error Building Dlib Visual Studio 2015

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.

Linker error when trying to reference static library project in Visual Studio 2013

I have two projects in my Visual Studio solution: A (static library .lib project) and B (project that uses A). I have referenced A in B by following the steps:
right click B > properties > common properties > references > add new reference > select A from projects tab
I have set the path for .h files using additional include directories option in properties > Configuration Properties > C/C++ > General
Project A builds successfully when built separately. But on building project B, it show unresolved external symbol errors like follows:
Error 46 error LNK2001: unresolved external symbol __imp____glewActiveTexture c:\Users\student\documents\visual studio 2013\Projects\MCAProject\Narovatar\Narovatar\OGLDEV_Imported.lib(ogldev_texture.obj) Narovatar
Error 21 error LNK2001: unresolved external symbol __imp____glewAttachShader c:\Users\student\documents\visual studio 2013\Projects\MCAProject\Narovatar\Narovatar\OGLDEV_Imported.lib(technique.obj) Narovatar
Error 12 error LNK2001: unresolved external symbol __imp____glewBindBuffer c:\Users\student\documents\visual studio 2013\Projects\MCAProject\Narovatar\Narovatar\ogl_mesh.obj Narovatar
Error 13 error LNK2001: unresolved external symbol __imp____glewBufferData c:\Users\student\documents\visual studio 2013\Projects\MCAProject\Narovatar\Narovatar\ogl_mesh.obj Narovatar
What could I have left? Any thoughts?
Right click properties -> linker -> general ->additional library directories-> browse for your lib file directory.
Right click properties -> linker -> general ->input-> write your lib file name.
Do not forget to make them both MT or both MD like following:
properties -> C/C++ -> Code generation -> Runtime-library-> change them both to be the same
I have found my answer myself, of course with the help of help from all those who responded. Actually, the project A (.lib project) had all the header files and implementations in the same folder which I was referencing in the project B. So, when all the implementations were already available, I didn't have to link my the .dll output of project A in project B, but just had to refer it.
Another problem was that I had not linked (in project B) the libraries that were required for building project A. Now, its up and running...

Linking VS2010 with Assimp

I have been trying to get assimp working with VS2010. I have seen many questions similar to this but I just can't get it to work. Read the installation tutorials here http://assimp.sourceforge.net/lib_html/install.html and still can't get it to work.
This is what I did for VS2010 project setup:
All Configurations -> Configuration Properties -> VC++ Directories -> Library Directories ADDED
C:\assimp--3.0.1270-sdk\lib\assimp_release-dll_x64
All Configurations -> Configuration Properties -> VC++ Directories -> Include Directories ADDED
C:\assimp--3.0.1270-sdk\include
All Configurations -> Configuration Properties -> C++ -> General -> Additional Include Directories ADDED
C:\assimp--3.0.1270-sdk\include
All Configurations -> Configuration Properties -> Linker -> Input -> Additional Dependencies ADDED assimp.lib
When i write following code:
#include <assimp/Importer.hpp> // C++ importer interface
#include <assimp/scene.h> // Output data structure
#include <assimp/postprocess.h> // Post processing flags
Assimp::Importer importer;
This is the error I get:
Error 2 error LNK2019: unresolved external symbol "public: __thiscall Assimp::Importer::Importer(void)" (??0Importer#Assimp##QAE#XZ) referenced in function "void __cdecl `dynamic initializer for 'importer''(void)" (??__Eimporter##YAXXZ) C:\Users\Martin Liu\documents\visual studio 2010\Projects\MyGame\MyGame\Game.obj MyGame
Error 3 error LNK2019: unresolved external symbol "public: __thiscall Assimp::Importer::~Importer(void)" (??1Importer#Assimp##QAE#XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'importer''(void)" (??__Fimporter##YAXXZ) C:\Users\Martin Liu\documents\visual studio 2010\Projects\MyGame\MyGame\Game.obj MyGame
Any help would be appreciated
Make sure your application's bitness matches your libraries' one. E.g. you can't link against x64 libraries if your project is 32 bit.
You can check this out by right-clicking in your project and choosing "properties" and then "Configuration Manager" button.

Keep getting error LNK2019: unresolved external symbol

The IDE I use is Visual Studio 2010 Professional, and the library I use is ICU4C 4.8.1 for Win32 for MSVC10.
I have rebuilt all the source codes according to the manual for both Debug and Release, and all tests are successfully passed.
Then I do in the way I do with Boost.
I included \include in C/C++ > Additional Include Directories in Proprieties, which seems to be fine.
I also included \lib in Linker > Additional Library Directories.
However, I keep getting error LNK2019: unresolved external symbol.
Source Code:
#include <unicode/uchar.h>
int main () {
UBool b = u_isprint('c');
return 0;
}
Error
1>ClCompile:
1> Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol _u_isprint_48 referenced in function _main
1>C:\Users\ ... \Documents\Visual Studio\Finger-Printing-Non-ASCII\Debug\Finger-Printing-Non-ASCII.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
Apart from setting additional include directories and library directories, you have to actually link to the library. Go to Project Properties -> Linker -> Input and write the name to the .lib in Additional dependencies textbox. HTH