How to add cpp files to Visual Studio 2008? - c++

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.

Related

CppSQLite throwing "LNK2019: unresolved external symbol" error

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

Google Protocol buffer c++ link error when trying to use it in project

I am trying to get protocol buffer to work but linking problems occurs.
All the errors looks something along like this
error LNK2019: unresolved external symbol "public: bool __cdecl google::protobuf::MessageLite::ParseFromArray(void const *,int)" (?ParseFromArray#MessageLite#protobuf#google##QEAA_NPEBXH#Z) referenced in function "void __cdecl ReceiveRequest(bool *)" (?ReceiveRequest##YAXPEA_N#Z)
I am using visual studio pro 2013 and this is what I have done:
I compiled the protocol buffer and added the libprotobuf.lib to the project(Add->Existing Item->libprotobuf.lib)
I've added the header files in C/C++ -> General -> "Additional Include Directories"
I have tried to add the library all the different ways I know but I still get these linking errors...
Any idea what I might have done wrong?
// Eric
You need to include the generated protocol buffer .cc (and maybe the .h) file (ie the file with the specific getters and setters for your specific proto) in your VS project (ie there has to be a little icon for them in the solution explorer) or else visual studio won't generate the code for it and thus there's nothing to link to.
Make sure you have the correct libraries for your architecture (e.g. x86 / x64).
That has caught me out a few times.

error LNK2019: unresolved external symbol. c file to cpp

There is a project made in C, its file is RawInput.c from http://www.codeproject.com/Articles/185522/Using-the-Raw-Input-API-to-Process-Joystick-Input. I have compiled it and it works perfect in vs2012. But when i pasted the same code within a cpp of a a new project i get 4 of these errors, just different decleration names.
error LNK2019: unresolved external symbol "long __stdcall HidP_GetCaps(struct _HIDP_PREPARSED_DATA ....
fatal error LNK1120: 4 unresolved externals
i guess it has something todo with me trying to run c code within a c++ compiler without telling it the right way. Perhaps there must be extern "C" somewhere? I wouldnt know even tho i tryed my best to search the webb for solutions. Help would be appreciated. Thank you.
It seems that Hidsdh.h is not a C++ compatible header. Include it like this:
//This is not a C++ header
extern "C"
{
#include <Hidsdi.h>
}
You probably need to add the library file hidparse.lib, which contains the HidP_GetCaps function. Right-click the project in the solution explorer, select Properties, and under the Linker section (Input) add hidparse.lib to the 'Additional Dependencies'.
Adds library paths for project properties as following.
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x64
Add a library "hid.lib" file.

Qt Link Issue with MyClass::metaobject VS2005

Just quickly before I start, I have searched SO and Google for a length of time trying to solve this and have been unsuccessful.
I am trying to compile my project, which used to use a certain library for providing GUI functionality based on Windows Forms. Now my company has started to move to Qt, and I decided I would start to convert my small application to support Qt also.
At first it would not compile at all, due to missing headers. Now that is sorted, I am stuck with my final .exe not being able to link due to the following errors.
Creating library Bin\VS_V8\Win32\Debug\Disp.lib and object Bin\VS_V8\Win32\Debug\Disp.exp
QtMainMenu.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QtMainMenu::metaObject(void)const " (?metaObject#QtMainMenu##UBEPBUQMetaObject##XZ)
QtMainMenu.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QtMainMenu::qt_metacast(char const *)" (?qt_metacast#QtMainMenu##UAEPAXPBD#Z)
QtMainMenu.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QtMainMenu::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#QtMainMenu##UAEHW4Call#QMetaObject##HPAPAX#Z)
Bin\VS_V8\Win32\Debug\Disp.exe : fatal error LNK1120: 3 unresolved externals
Our company has a small "Qt Test App" that was written to play around with, which is where I have based my import from. I can compile and link that fine. From what I have gathered, the following properties must be met with Qt files:
Make sure QTDir is included
Add to the UI Files the UIC Compiler
Add to the Resoruce Files the Resource Compiler
Add to the created Header Files the MOC compiler.
I noticed I was missing the MOC Build Tool commands, so I have added them to my UI File's header. However this didnt change the linking problem. I read that I should delete all built files and do a clean to solve it. This didnt work either.
I have checked, and Q_OBJECT is defined in the class.
I am using VS2005 with the Qt Addin. I did not start a new project for Qt however, I am just using the old Visual Studio Solution / VCProj.
Any ideas where to go next?
#Cameron Stubber you need moc object .. You need to modify Custom Build Step.
You can find Custom Build Step in header file (which has Q_OBJECT) Properties by right click. Then type this commands ;
Command Line = $(QTDIR)\bin\moc.exe -I"$(QTDIR)\include\QtCore" -I"$(QTDIR)\include\QtGui" -I"$(QTDIR)\include" -I"$(QTDIR)\mkspecs\$(QMAKESPEC)" finddialog.h -o debug\moc_finddialog.cpp
Description = MOC finddialog.h
Outputs = debug\moc_finddialog.cpp
Additional Dependencies = $(QTDIR)\bin\moc.exe;finddialog.h
But carefull by writing this types you need to change somethings here like $(QTDIR) it is my enviroment variables you need to write full form of where your QT located like D:\qt_5\
and also you need to be carefull finddialog you should write your .h and .cpp files name
And then you need to create a folder by right clicking solution explorer Add\New Filter .. Make folder name as Generated Files
And last step right click Generated Files add\existing item and you will see Debug folder in your solution Project and add moc_"projectName".cpp
Then re-build your solution. Problem will be solved.
Also you should add C/C++ /General/Additional Library Directories
$(QTDIR)\include
$(QTDIR)\include\QtGui
$(QTDIR)\include\QtCore
And Link/General/Additional Library Directories
$(QTDIR)\lib
Link/Input/Additional Dependencies
qtmaind.lib
QtCored4.lib
QtGuid4.lib
But dont forget to change $(QTDIR) to your enviroment variables or location of your qt folder. Like D:\qt_4.7.4

Unresolved external symbol

Help me guys,
I've been searching for a really long time.
I'm using visual studio 2010 and I tried to include an external lib but I get an unresolved external error.
The external project is composed of files in the following way
backend.cpp
//some functions
frontend.cpp
//some functions
header.h
I build this project using SCons then I includes the .lib file in the project and refered to its path and I copied the .h file to msvc directory .
VS seems to access and read the functions in backend.cpp(from the auto complete) but when I run the project it says that there is an unresolved external # the called function
I'm not a Visual Studio expert, but I guess that it being able to auto complete your code is associated with it finding the headers of your source code.
Unresolved external means that the compiler can't find the object files in the linking process. This could mean that you failed to add the lib files correctly, or that you are missing some .cpp file.
That may happen for a variety of reasons. But all of them end up being one of the following:
You are not linking the correct .lib file.
The symbol name you are using in your program is not identical to the one provided in the .lib.
The first one is easy enough to check, so please, double check it.
The second one is trickier. The symbol name used in your program is output in the error message "unresolved external symbol abc", or whatever. The symbols available in the library can be listed with the command: dumpbin /all name.lib.
If you cannot find the problem, please post the exact error you are getting and the output of the dumpbin program.