I have problem, I use mysql++ 3.1.0:
after building mysql++.sln in debug and release mode for vc2008, and using instal.hta then
adding dirrectoires in vc++ directories to lib and include folders,
and adding in project properties-> Linker-> General Additional Library Directories directory to lib folder which have mysqlpp.dll, mydqlpp.lib, mysqlpp_d.dll, mydqlpp_d.lib.
These code:
#include <iostream>
#include <mysql++.h>
using namespace std;
using namespace mysqlpp;
int main()
{
Connection con;
return 0;
}
gets these errors:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall mysqlpp::Connection::~Connection(void)" (__imp_??1Connection#mysqlpp##UAE#XZ) referenced in function _main
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall mysqlpp::Connection::Connection(bool)" (__imp_??0Connection#mysqlpp##QAE#_N#Z) referenced in function _main
in visual studio 2008. How can I fix this?
I think you missed the last step here, which adds several libraries to your project: the MySQL++ DLL import library, the MySQL C API library, and the Winsock DLL import library.
Related
I had boost compiled & working on my Visual Studio 2022 project. After the PC was upgraded and the OS changed to Windows 11 I attempted to re-build boost and use it with the same project. Now I get linker errors, and it seems like I have tried every suggested fix posted online. Somehow it seems like the lib files are not being found, even though I have confirmed the include and lib directories are included properly, and have tried rebuilding boost with many different configurations.
The boost build produces libboost_*.lib files, for example
libboost_log_setup-vc143-mt-gd-x32-1_78.lib
libboost_log_setup-vc143-mt-x32-1_78.lib
libboost_log-vc143-mt-gd-x32-1_78.lib
libboost_log-vc143-mt-x32-1_78.lib
Here are my boost build options
x86
b2 -j 16 --stagedir=stage/Win32 threading=multi --toolset=msvc-14.3
link=static runtime-link=shared --build-type=complete architecture=x86
address-model=32
x64
b2 -j 16 --stagedir=stage/x64 threading=multi --toolset=msvc-14.3
link=static runtime-link=shared --build-type=complete architecture=x64
--address-model=64
And my Visual Studio properties
C/C++->General->Additional Include Directories
C:\Program Files\Code Libraries\boost\boost_1_78_0
Linker->General->Additional Library Directories
C:\Program Files\Code
Libraries\boost\boost_1_78_0\stage$(Platform)\lib
And here's an example of the errors
1>Logging.obj : error LNK2019: unresolved external symbol "private: static unsigned int __cdecl boost::log::v2s_mt_nt62::attribute_name::get_id_from_string(char const *)" (?get_id_from_string#attribute_name#v2s_mt_nt62#log#boost##CAIPBD#Z) referenced in function "public: __thiscall boost::log::v2s_mt_nt62::attribute_name::attribute_name(char const *)" (??0attribute_name#v2s_mt_nt62#log#boost##QAE#PBD#Z)
1>Logging.obj : error LNK2001: unresolved external symbol "public: static void __cdecl boost::log::v2s_mt_nt62::aux::stream_provider<char>::release_compound(struct boost::log::v2s_mt_nt62::aux::stream_provider<char>::stream_compound *)" (?release_compound#?$stream_provider#D#aux#v2s_mt_nt62#log#boost##SAXPAUstream_compound#12345##Z)
1>Logging.obj : error LNK2019: unresolved external symbol "public: static void * __cdecl boost::log::v2s_mt_nt62::attribute::impl::operator new(unsigned int)" (??2impl#attribute#v2s_mt_nt62#log#boost##SAPAXI#Z) referenced in function "class boost::log::v2s_mt_nt62::attribute_value __cdecl boost::log::v2s_mt_nt62::attributes::make_attribute_value<unsigned int &>(unsigned int &)" (??$make_attribute_value#AAI#attributes#v2s_mt_nt62#log#boost##YA?AVattribute_value#123#AAI#Z)
1>Logging.obj : error LNK2019: unresolved external symbol "public: static void __cdecl boost::log::v2s_mt_nt62::attribute::impl::operator delete(void *,unsigned int)" (??3impl#attribute#v2s_mt_nt62#log#boost##SAXPAXI#Z) referenced in function __unwindfunclet$??$make_attribute_value#AAI#attributes#v2s_mt_nt62#log#boost##YA?AVattribute_value#123#AAI#Z$0
Edit: I also wanted to mention my preprocessor variables for Debug/Win32
WIN32
_DEBUG
_CONSOLE WIN32_LEAN_AND_MEAN
_WIN32_WINNT=0x0A00
I haven't been able to find a _WIN32_WINNT value for Windows 11, and I thought maybe that could be the problem. But I'm not entirely sure that matters.
The problem is that Boost, and Boost.Log in particular, was built for a different Windows version. You need to either:
Build Boost with _WIN32_WINNT defined to the same version as you define when you build your code.
Define BOOST_USE_WINAPI_VERSION when building your code to the Windows version Boost should target, which would be lower than your _WIN32_WINNT. Also define _WIN32_WINNT or BOOST_USE_WINAPI_VERSION macro to that version when building Boost.
To define the macro when building Boost add define=macro=value to the b2 command line. For example, define=_WIN32_WINNT=0x0A00.
I am using mfc class CImageList in my project and using its APIs like Add(), Create() etc. It works fine with vs2010.
Now, I am upgrading the project to vs2012. It compiles and links fine for 32 bit platform, however throws below linking errors for 64 bit.
File1.obj : error LNK2019: unresolved external symbol imp_ImageList_ReplaceIcon referenced in function "public: int __cdecl CImageList::Add(struct HICON *)"
File2.obj : error LNK2019: unresolved external symbol __imp_ImageList_AddMasked referenced in function "public: int __cdecl CImageList::Add(class CBitmap *,unsigned long)"
Similarly, below error is thrown for calling CBitmap api.
File2.obj : error LNK2019: unresolved external symbol __imp_CreateMappedBitmap referenced in function "public: int __cdecl CBitmap::LoadMappedBitmap(unsigned int,unsigned int,struct _COLORMAP *,int)"
It seems that the libraries having these implementations might have been changed. However, I could not find any clue on how to resolve them.
Finally figured out the reason for this error.
ImageList_ReplaceIcon & CreateMappedBitmap symbols are present in comctl32.lib.
There was an older version comctl32.lib present in a path which was included in Additional Include Directories of my project settings.
So, instead of picking this lib from Microsoft SDK folder, the linker was picking from this directory and hence causing problems.
I'm getting some unresolved externals when importing a DLL of a project (Project 1) in a .exe project (Project 2) using MSVC 2013 (it compiles fine in Mingw 4.8.1):
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class chakra::Message * __thiscall chakra::PublisherSubscriberChannel::GetMessageA(unsigned __int64)" (__imp_?GetMessageA#PublisherSubscriberChannel#chakra##QAEPAVMessage#2#_K#Z) referenced in function "public: virtual void __thiscall Bar2::ProcessMessages(void)" (?ProcessMessages#Bar2##UAEXXZ)
test_wrap.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class chakra::Message * __thiscall chakra::PublisherSubscriberChannel::GetMessageA(unsigned __int64)" (__imp_?GetMessageA#PublisherSubscriberChannel#chakra##QAEPAVMessage#2#_K#Z)
The function GetMessage is a member function of class PublisherSubscriberChannel of namespace chakra in Project 1.
Examined the .exp and .dll file of Project 1 using dumpbin.exe /exports and found the function to be exported as ?GetMessage#PublisherSubscriberChannel#chakra##QAEPAVMessage#2#_K#Z whereas during importing it is looking for ?GetMessageA#PublisherSubscriberChannel#chakra##QAEPAVMessage#2#_K#Z as per the above error.
It happens only when I #include "Ogre.h" or any of the other Ogre headers in test_wrap.cxx file (which is a SWIG generated file).
Does anyone have any idea why the function name mismatch with the extra 'A'?
Summary: Is there any tiny example on how to build the Win32 C++ console application that uses the libgit2 library (sources available at GitHub)?
I have followed the readme and the wiki on how to build the library on Windows using the CMake, and it worked smoothly (only a single unit-test error).
Now, I want to build a simple console application that uses the library -- using Microsoft Visual Studio C++ 2010 (the.vcxproj and the.sln). I have found the general.c code in the libgit2 examples, and I would like to do the same from my C++ application. No success -- I feel really stupid today...
I have noticed there is libqgit2 for C++ and Qt. Is there anything similar for pure C++? Or is there a way to use the C library from C++ application?
Update: I have renamed the general.c to general.cpp, added the libgit2 include path to the project and the path to the .lib files, changed the #include <stdio.h> to #include <cstdio>, and compiled. The following link errors appear:
1>------ Build started: Project: libgit2_general, Configuration: Debug Win32 ------
1>general.obj : error LNK2019: unresolved external symbol _git_repository_free referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _git_config_get_string referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _git_config_get_int32 referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _git_config_open_ondisk referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _git_strarray_free referenced in function _main
... etc.
1>general.obj : error LNK2019: unresolved external symbol _git_repository_open referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _giterr_last referenced in function "void __cdecl check_error(int,char const *)" (?check_error##YAXHPBD#Z)
1>D:\Tutorial\libgit2_general\Debug\libgit2_general.exe : fatal error LNK1120: 56 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This strongly suggests a calling convention mismatch to me. libgit2 uses __stdcall by default, for a number of reasons, while Visual Studio defaults to creating projects that use the __cdecl calling convention. While your program can use either calling convention and successfully call libgit2 using a different one, the easiest solution is probably just to use the same calling convention for both.
When you configure libgit2, you can turn off the STDCALL flag, which will cause it to emit a library built with __cdecl calling conventions:
cmake %PATH_TO_LIBGIT2_SOURCE% -DTHREADSAFE=ON -DSTDCALL=OFF
cmake --build .
It's a little surprising if you generated the project from CMake, bit it could be that you're not linking to libgit2.lib. Make sure you have git2.dll in Project Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies.
I'm trying to set up sound in my Ogre3D project. I have installed irrKlang 1.4.0 and added it's include and lib directories to my projects VC++ Include and Library directories, but I'm still getting a Linker error when I attempt to build. Any suggestions?
(Error 4007 error LNK2019: unresolved external symbol
"__declspec(dllimport) class irrklang::ISoundEngine * __cdecl
irrklang::createIrrKlangDevice(enum
irrklang::E_SOUND_OUTPUT_DRIVER,int,char const *,char const *)"
(_imp?createIrrKlangDevice#irrklang##YAPAVISoundEngine#1#W4E_SOUND_OUTPUT_DRIVER#1#HPBD1#Z)
referenced in function "public: __thiscall
SoundManager::SoundManager(void)" (??0SoundManager##QAE#XZ)
Okay, after looking at this for awhile it seems I was making two mistakes.
The lib directory for irrKlang is divided in two, so instead of adding (IRRKLANGDIRECTORY)\lib to my library directories, I should have been using (IRRKLANGDIRECTORY)\lib\Win32-visualStudio.
Including the lib directory wasn't sufficient, I also needed to specify the use of the irrklang library file at the top of my class (#pragma comment(lib, "irrklang.lib")).