I'm trying to use CppSQLite wrapper for SQLite. I downloaded and compiled SQLite here: C:\sqlite\sqlite-autoconf-3310100. Then I downloaded CppSQLite to: C:\sqlite\cppsqlite. I then added these folders to include and library directories in MSVS project. Added the sqlite3.lib file to additional dependencies. As far as I'm aware that's all I have to do. I added #include "CppSQLite3.h" line. I created declared a CppSQLite3DB variable and MSVS says no problem, it know it comes from cppsqlite header. But when I run the project it throws LNK2019 error. Error code is below.
I'm aware of this question that is the same problem as mine but I tried all the answers there except the best answer. None of them worked. And I don't understand what to do in the best answer, I can't comment on it since I don't have enough rep, so I had to create a new question. Can anyone explain to me if that answer will work for me aswell? And if so, what am I supposed to do, can you explain me that answer simply? Thanks in advance!
LNK2019 unresolved external symbol "public: __cdecl CppSQLite3DB::CppSQLite3DB(void)"
(??0CppSQLite3DB##QEAA#XZ) referenced in function "bool __cdecl dbop::connectToDatabaseSQLITE(char
const *)" (?connectToDatabaseSQLITE#dbop##YA_NPEBD#Z)
https://github.com/neosmart/CppSQLite/
Get CppSQLite3.h and CppSQLite3.cpp files from here.
Add to your project.
You dont need to make CppSQLite3 seperate lib.
Adding files to project should be enouh
Related
I have a very specific problem when trying to compile a 'sample' project for the Orbiter space flight simulator. I'm trying to compile the sample for the space shuttle 'Atlantis' using the preview version of Visual Studio 2019, and I'm getting an error like:
LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall VESSEL2::VESSEL2(class VESSEL2 &&)" (__imp_??0VESSEL2##QAE#$$QAV0##Z) referenced in function "public: __thiscall Atlantis_SRB::Atlantis_SRB(class Atlantis_SRB &&)" (??0Atlantis_SRB##QAE#$$QAV0##Z)
This is happening in the Atlantis_SRB project. My code is located at:
C:\Orbiter2016\Orbitersdk\samples\Atlantis\
I have a lot of experience in software engineering, but I'm a C++ noob. I've looked at general help for this error, so I understand that there is something that needs to be linked, but I'm not sure what, or how to do it.
I looked at this question on the Orbiter forum:
https://www.orbiter-forum.com/showthread.php?t=24247
It suggests checking the following under project > properties:
Linker - Input - Additional libraries
and
Linker - Advanced - Library search paths
When I check under the 1st one, I have the following under Linker > Input > Additional Dependencies:
orbiter.lib;orbitersdk.lib;%(AdditionalDependencies)
The 2nd location (Linker - Advanced - Library search paths) doesn't exist.
I'm used to C# reference errors when dlls are missing from 'references' and know how to solve them quickly, but I'm not sure what to do with this type of C++ issue.
How do I identify what the specific problem is, and what do I need to link, where (and how?!)
I posted this problem on the excellent Orbiter forum, and cyph0r provided a fix there which works with VS2017:
https://www.orbiter-forum.com/showthread.php?p=589264&posted=1#post589264
Basically orbiter.lib seems to only be fully compatible 'out of the box' up to VS2013, and apparently the Atlantis sample compiles fine using VS2013. (I went back to using VS2017 and implemented cyph0r's fix, which works - I haven't tried VS2019):
This is the significant part of the error:
__declspec(dllimport) public: __thiscall VESSEL2::VESSEL2(class VESSEL2 &&)" (__imp_??0VESSEL2##QAE#$$QAV0##Z) referenced in function "public: __thiscall Atlantis_SRB::Atlantis_SRB(class Atlantis_SRB &&)
It's indicating that a move constructor is being referenced by the Atlantis_SRB class declaration, which can't be found in VS2017. This is the part that's indicating that the move constructor is being referenced:
__declspec(dllimport) public: __thiscall VESSEL2::VESSEL2(class VESSEL2 &&)
The fix is to remove the expectation that this move constructor exists, by editing the Atlantis.h file within the Atlantis sample. The link to the question on the Orbiter forum gives full details of what you need to do.
I had two array templates in one of my header files, everything worked well. Then I thought, I'd better get some more pedantism into my code, so I moved them all into another header file, mostly just for them (and for another function, that wants to use one of them). And then I got LNK2019 error every time I used functions from these templates in other header files.
Since everything was good before I pasted my code elsewhere, I assume the code is okay, it's just my lack of understanding. Basically, the question is: why do I get a linker error when I moved my function to another header file?
Here is an example of one of my errors:
Error LNK2019 unresolved external symbol "public: char __thiscall C2DArray::Get(int,int)" (?Get#?$C2DArray#D##QAEDHH#Z) referenced in function "public: char __thiscall SGame::GetRecordOutput(int,int)" (?GetRecordOutput#SGame##QAEDHH#Z) Mastermind C:\Users\Master\Documents\Visual Studio 2015\Projects\Mastermind\Mastermind\Menu.obj 1
I'm using Visual Studio 2015 if it matters.
Thank you for the reply. As it seems, I have resolved my problem. The cause was the class templats, which were not specialized (and had to be). All I had to do is include what types of these templates I wanted. Sorry for posting before doing more extensive research.
I frequently have this problem when I try a new library. This time I work with PointGrey Camera and try to use its API libraries (some dll, lib, header files). Mostly, problems were fixed by configuring the SDK (I'm using VS2008) Tools/Options/VC++ Directories/include files(/library files)(/executable files),
I also tried with project configuration:
+ project properties/linker/input/additional dependencies
+ project properties/linker/General/Additional Library Directories
This time, with all this, I still have the error.
Is there a general method to deal with this problem?
do I need to understand this diagnosis from VS2008?
Error 1 error LNK2019: unresolved external symbol __imp__flycaptureGetPacketInfo referenced in function "enum FlyCaptureError __cdecl initializeStandardEventSizes(void *,struct FlyCaptureImageEvent * const)" (?initializeStandardEventSizes##YA?AW4FlyCaptureError##PAXQAUFlyCaptureImageEvent###Z) main_2.obj test
does using analysis tool such as Dependencies Walker ensure to solve these problems well??
This message says that you used a symbol (a function or a variable) in your code. This symbol was probably declared somewhere (most likely in a header file you included in your code) otherwise there would have been a compilation error. When the linker searched for the symbol (in both your object files and the lib files you instructed it to look in) it couldn't find it.
That usually happens because you forgot to let the linker know about a lib you want it to search in.
Most libraries come with a set of instruction that is supposed to help you set up everything correctly and avoid running into these problems.
This problem has been solved lately. I installed the incompatible library of PointGrey. That's why it didn't work. But this says something between "incompatible library" and "unresolved exertal symbol error"
I'm trying to add Beecrypt library to my project. First i have added header files but after attempting to create an object i'm receiving the following errors:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall beecrypt::security::SecureRandom::~SecureRandom(void)" (__imp_??1SecureRandom#security#beecrypt##UAE#XZ) referenced in function _wmain
As far as i understand it is due to the absence of cpp files. Ok. Then i'm trying to add cpp files but whatever folder i put them i still receive the same error. For example SecureRandom.h is situated:
beecrypt/c++/security/SecureRandom.h
Where should i put SecureRandom.cpp to get rid of that error? I've already tried all levels of folders. Or maybe that error is caused by something else? Thanks a lot in advance
Simplest way is to Just drag and drop them to your project in the solutions explorer.
Or
Follow the steps given in the link below on MSDN website:
Adding a Source File.
I am using a library of code from a tutorial for providing functionality for passing function points of non-static member functions to a function that expects a static function pointer, probably helps to know what I am suing, so here is the link http://www.codeproject.com/KB/cpp/thunk32.aspx This code uses the Boost library, which I have downloaded and set-up more or less everything from.
In the Thunk library, one of the header files has a section that reads
#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,THUNK32_MAX_ARGS,"Thunk32_template.h"))
??=include BOOST_PP_ITERATE()
#undef BOOST_PP_ITERATION_PARAMS_1
but this gives me epic amounts of errors, which I can solve by changing it to
#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,THUNK32_MAX_ARGS,"Thunk32_template.h"))
#include BOOST_PP_ITERATE()
#undef BOOST_PP_ITERATION_PARAMS_1
This code that is downloaded is included in my solution as a second project, which is able to compile and build happily. But my project that is using this code has issues linking, to save people asking, I get these error messages
1>WebCamera.obj : error LNK2019: unresolved external symbol "protected: __thiscall indev::Thunk32Base::Thunk32Base(void)" (??0Thunk32Base#indev##IAE#XZ) referenced in function "public: __thiscall indev::Thunk32<class WebCamera,void __cdecl(struct HWND__ *,struct videohdr_tag *)>::Thunk32<class WebCamera,void __cdecl(struct HWND__ *,struct videohdr_tag *)>(void)" (??0?$Thunk32#VWebCamera##$$A6AXPAUHWND__##PAUvideohdr_tag###Z#indev##QAE#XZ)
1>WebCamera.obj : error LNK2019: unresolved external symbol "protected: __thiscall indev::Thunk32Base::~Thunk32Base(void)" (??1Thunk32Base#indev##IAE#XZ) referenced in function "public: __thiscall indev::Thunk32<class WebCamera,void __cdecl(struct HWND__ *,struct videohdr_tag *)>::~Thunk32<class WebCamera,void __cdecl(struct HWND__ *,struct videohdr_tag *)>(void)" (??1?$Thunk32#VWebCamera##$$A6AXPAUHWND__##PAUvideohdr_tag###Z#indev##QAE#XZ)
1>WebCamera.obj : error LNK2019: unresolved external symbol _capCreateCaptureWindowA#32 referenced in function "public: bool __thiscall WebCamera::Init(struct HWND__ *)" (?Init#WebCamera##QAE_NPAUHWND__###Z)
I think this is trying to say that the constructor and destructor are not declared and that my WebCamera.Init()is messed up as well. I have made sure that the library that the Thunk32 project exports is included in my other project, but still I get these errors.
I would like to know if I have made the correct assumption that ??=include should have been changed to #include and if I have, what have I done wrong or failed to do that results in these linker errors. Or if you can provide me with a different way of being able to pass a function pointer to a non-static member function that would be awesome.
Thanks
??= is a "trigraph" sequence for the # character. according to the standard, trigraphs are supposed to be handled as one of the first steps in processing (in phase 1 - before the preprocessor handles directives),so:
??=include "whatever"
Should be equivalent to:
#include "whatever"
so you should be able to use that form (I wonder why the trigraph was put there in the first place - some sort of evil joke perhaps?)
However, trigraphs cause problems and confusion (probably more than they help), so compilers seem to be moving towards warning about them and/or defaulting to not handling them. The compiler in VS 2010 has trigraph processing turned off by default - you have to use the /Zc:trigraphs option to turn it on.
See Purpose of Trigraph sequences in C++? for more details.
Ah, Einar, good man. Doing flash and Sharepoint stuff these days, ouch. Norwegian, might explain the trigraphs.
Anyhoo, nothing complicated, you just forgot to tell the linker to look at some libraries. Right-click your project, Project Dependencies, tick the Thunk project. That makes sure that Thunk32.lib gets looked at and resolves the ctor and dtor.
Right-click again, Properties, Linker, Additional dependencies, add "winmm.lib". That resolves the capCreateCaptureWindow symbol.
Do you have a constructor and a destructor declared in the indev::Thunk32Base class that you forgot to define in its cpp file?
Ok, so I have managed to solve this now.
Michael Burr nicley said that ??= is basically the same as typing # but in a way that people who dont have the hash symbol can type it, see Purpose of Trigraph sequences in C++?
Hans Passant then got the ball rolling for me buy letting me know that I had not fully linked in stuff. I needed to right click on my main project, select 'Project Dependencies' and select my other project that has the thunk32 code. I also needed to tell my main project to look at where the Thunk project is saving the lib, which turned out to be in a folder in my documents (explain that one!). I also needed to add the Thunk32d.lib (note the 'd' because I was/am in debug mode. Hans said that I needed winmm.lib but it turned out (when googling the function that was giving me the error that I needed Vfw32.lib instead.
Thanks guys! I hope that by giving the full answer like this it can help some one else who has a similar problem.