Using JsonCPP to parse API requests but the code wont compile [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 9 days ago.
Improve this question
#include<string>
#include<iostream>
#include<json/json.h>
#include<cpr/cpr.h>
using namespace std;
using namespace cpr;
int main() {
Response r = Get(Url{ "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd" });
Json::Value data;
Json::Reader reader;
reader.parse(r.text, data);
cout << data << endl;
}
I'm trying to get print out the response {"Bitcoin" {"USD: 23000"}}.
When I just use response and cout r.text it runs perfectly. But when I use jsoncpp it says "There were build errors, would you like to run previous build?"
Build errors:
Build started... 1>------ Build started: Project: Project 1,
Configuration: Debug x64 ------ 1>Main.obj : error LNK2019: unresolved
external symbol "public: __cdecl Json::Value::Value(enum
Json::ValueType)" (??0Value#Json##QEAA#W4ValueType#1##Z) referenced in
function main 1>Main.obj : error LNK2019: unresolved external symbol
"public: __cdecl Json::Value::~Value(void)" (??1Value#Json##QEAA#XZ)
referenced in function main 1>Main.obj : error LNK2019: unresolved
external symbol "public: __cdecl Json::Reader::Reader(void)"
(??0Reader#Json##QEAA#XZ) referenced in function main 1>Main.obj :
error LNK2019: unresolved external symbol "public: bool __cdecl
Json::Reader::parse(class std::basic_string<char,struct
std::char_traits,class std::allocator > const &,class
Json::Value &,bool)"
(?parse#Reader#Json##QEAA_NAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEAVValue#2#_N#Z)
referenced in function main 1>Main.obj : error LNK2019: unresolved
external symbol "class std::basic_ostream<char,struct
std::char_traits > & __cdecl Json::operator<<(class
std::basic_ostream<char,struct std::char_traits > &,class
Json::Value const &)"
(??6Json##YAAEAV?$basic_ostream#DU?$char_traits#D#std###std##AEAV12#AEBVValue#0##Z)
referenced in function main

It appears that you treat JsonCPP as a header-only library, when it's enough to simply #include that header file.
However, looks like https://github.com/open-source-parsers/jsoncpp contains some source code, too. So you should probably build that library and link it.

Related

Reading from HDF5 file linker issue

I am trying to read HDF5 file, this's the first time I come across this file format so please bare with me. The issue that I am having right now is linking the hdf5 lib to my project on Visual Studio 2017.
This's what I've done so far:
Linker > Input > Additional Dependencies contains hdf5.lib
Linker > General > Additional Libraries Directories contains path to lib directory of my HDF5 installation
C/C++ > General > Additional Include Directories contains path to include directory of my HDF5 installation
I've add to PATH variable bin directory of my HDF5 installation
Following the steps of the solution proposed here.
However, I still have the following linker errors when I try to build my project.
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: __cdecl H5::DataSpace::DataSpace(int,unsigned __int64 const *,unsigned __int64 const *)" (??0DataSpace#H5##QEAA#HPEB_K0#Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: int __cdecl H5::DataSpace::getSimpleExtentDims(unsigned __int64 *,unsigned __int64 *)const " (?getSimpleExtentDims#DataSpace#H5##QEBAHPEA_K0#Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl H5::DataSpace::~DataSpace(void)" (??1DataSpace#H5##UEAA#XZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: class H5::DataSet __cdecl H5::H5Location::openDataSet(char const *,class H5::DSetAccPropList const &)const " (?openDataSet#H5Location#H5##QEBA?AVDataSet#2#PEBDAEBVDSetAccPropList#2##Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: enum H5T_class_t __cdecl H5::AbstractDs::getTypeClass(void)const " (?getTypeClass#AbstractDs#H5##QEBA?AW4H5T_class_t##XZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual class H5::DataSpace __cdecl H5::DataSet::getSpace(void)const " (?getSpace#DataSet#H5##UEBA?AVDataSpace#2#XZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: void __cdecl H5::DataSet::read(void *,class H5::DataType const &,class H5::DataSpace const &,class H5::DataSpace const &,class H5::DSetMemXferPropList const &)const " (?read#DataSet#H5##QEBAXPEAXAEBVDataType#2#AEBVDataSpace#2#2AEBVDSetMemXferPropList#2##Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl H5::DataSet::~DataSet(void)" (??1DataSet#H5##UEAA#XZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: __cdecl H5::H5File::H5File(char const *,unsigned int,class H5::FileCreatPropList const &,class H5::FileAccPropList const &)" (??0H5File#H5##QEAA#PEBDIAEBVFileCreatPropList#1#AEBVFileAccPropList#1##Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl H5::H5File::close(void)" (?close#H5File#H5##UEAAXXZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl H5::H5File::~H5File(void)" (??1H5File#H5##UEAA#XZ) referenced in function main
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::DataSpace const & const H5::DataSpace::ALL" (?ALL#DataSpace#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::FileAccPropList const & const H5::FileAccPropList::DEFAULT" (?DEFAULT#FileAccPropList#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::FileCreatPropList const & const H5::FileCreatPropList::DEFAULT" (?DEFAULT#FileCreatPropList#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::DSetMemXferPropList const & const H5::DSetMemXferPropList::DEFAULT" (?DEFAULT#DSetMemXferPropList#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::DSetAccPropList const & const H5::DSetAccPropList::DEFAULT" (?DEFAULT#DSetAccPropList#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::PredType const & const H5::PredType::NATIVE_FLOAT" (?NATIVE_FLOAT#PredType#H5##2AEBV12#EB)
1>C:\Users\maxim\source\repos\EigenExperiment\x64\Debug\EigenExperiment.exe : fatal error LNK1120: 17 unresolved externals
1>Done building project "EigenExperiment.vcxproj" -- FAILED.
Also, I've attached the code I'm using, just in case I missed something.
Any hep is highly appreciated :)
#include <iostream>
#include <Eigen/Dense>
#include <filesystem>
#include <math.h>
#include "H5Cpp.h"
#include <vector>
#include <string>
using namespace std;
using namespace H5;
int main()
{
string ifn = "basler.h5";
string datasetPath = "/face_g_tobii/data";
// Open HDF5 file handle, read only
H5File fp(ifn.c_str(), H5F_ACC_RDONLY);
// access the required dataset by path name
DataSet dset = fp.openDataSet(datasetPath.c_str());
// get the dataspace
DataSpace dspace = dset.getSpace();
// get the dataset type class
H5T_class_t type_class = dset.getTypeClass();
// According to HDFView, this is a 32-bit floating-point
// get the size of the dataset
hsize_t rank;
hsize_t dims[2];
rank = dspace.getSimpleExtentDims(dims, NULL); // rank = 1
cout << "Datasize: " << dims[0] << endl; // this is the correct number of values
// Define the memory dataspace
hsize_t dimsm[1];
dimsm[0] = dims[0];
DataSpace memspace(1, dimsm);
// create a vector the same size as the dataset
vector<float> data;
data.resize(dims[0]);
cout << "Vectsize: " << data.size() << endl;
float data_out[65341];
for (int i = 0; i < 65341; i++)
{
data_out[i] = 0;
}
// pass pointer to the array (or vector) to read function, along with the data type and space.
dset.read(data_out, PredType::NATIVE_FLOAT, memspace, dspace); // FAILS
dset.read(data_out, PredType::NATIVE_FLOAT, dspace); // FAILS
dset.read(data.data(), PredType::NATIVE_FLOAT, memspace, dspace); // FAILS
// close the HDF5 file
fp.close();
}
It turned out the external libraries should be named first, what worked for me was:
1.4 Select Linker->Input and beginning with the
"Additional Dependencies" line, enter the library names. The
external libraries should be listed first, followed by the HDF5
library, and then optionally the HDF5 High Level, Fortran or C++
libraries. For example, to compile a C++ application, enter:
szip.lib zlib.lib hdf5.lib hdf5_cpp.lib
This's from the documentation of HDF5, which I completely overlooked :/
i am trying with hdf5 for c++ on vs2019 and i did the stuff of adding
szip.lib zlib.lib hdf5.lib hdf5_cpp.lib but then i canĀ“t find both libs szip and zlib. Of course i did "H5_BUILT_AS_DYNAMIC_LIB" at preprocessor, but nothing.
According to the error, the project you built is the x64 version, I suggest you check whether the linked hdf5.lib is 32-bit or 64-bit? You should use the 64-bit hdf5.
And I suggest you could try to check whether the platform and the Configuration selection in the property page is x64 and debug.
I suggest you could select "All Platforms" for the platform and select "All Configurations" for the Configuration when changing the properties.

VS2013 Error: LNK2019 When trying to build ZeroMQ server

I'm trying to build this simple ZeroMQ server in C++ on Visual Studio 2013.
#include "stdafx.h"
#include "zmq.hpp"
#include <string>
#include <iostream>
#include <windows.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// Prepare context and socket
zmq::context_t ctx(1);
zmq::socket_t sckt(ctx, ZMQ_REP);
sckt.bind("tcp://*:5555");
while (true) {
zmq::message_t request;
// Wait for next request from client
sckt.recv(&request);
std::cout << "Received Hello" << endl;
Sleep(1);
// Send reply back to client
zmq::message_t reply(5);
memcpy((void*)reply.data(), "World", 5);
sckt.send(reply);
}
return EXIT_SUCCESS;
}
However, I'm getting error LNK2019 when I try to build the VS project. Below is the compiler output:
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_errno referenced in function "public: __thiscall zmq::error_t::error_t(void)" (??0error_t#zmq##QAE#XZ)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_strerror referenced in function "public: virtual char const * __thiscall zmq::error_t::what(void)const " (?what#error_t#zmq##UBEPBDXZ)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_ctx_new referenced in function "public: __thiscall zmq::context_t::context_t(int,int)" (??0context_t#zmq##QAE#HH#Z)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_ctx_set referenced in function "public: __thiscall zmq::context_t::context_t(int,int)" (??0context_t#zmq##QAE#HH#Z)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_ctx_destroy referenced in function "public: void __thiscall zmq::context_t::close(void)" (?close#context_t#zmq##QAEXXZ)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_init referenced in function "public: __thiscall zmq::message_t::message_t(void)" (??0message_t#zmq##QAE#XZ)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_init_size referenced in function "public: __thiscall zmq::message_t::message_t(unsigned int)" (??0message_t#zmq##QAE#I#Z)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_send referenced in function "public: bool __thiscall zmq::socket_t::send(class zmq::message_t &,int)" (?send#socket_t#zmq##QAE_NAAVmessage_t#2#H#Z)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_recv referenced in function "public: bool __thiscall zmq::socket_t::recv(class zmq::message_t *,int)" (?recv#socket_t#zmq##QAE_NPAVmessage_t#2#H#Z)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_close referenced in function "public: __thiscall zmq::message_t::~message_t(void)" (??1message_t#zmq##QAE#XZ)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_data referenced in function "public: void * __thiscall zmq::message_t::data(void)" (?data#message_t#zmq##QAEPAXXZ)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_socket referenced in function "public: __thiscall zmq::socket_t::socket_t(class zmq::context_t &,int)" (??0socket_t#zmq##QAE#AAVcontext_t#1#H#Z)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_close referenced in function "public: void __thiscall zmq::socket_t::close(void)" (?close#socket_t#zmq##QAEXXZ)
1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_bind referenced in function "public: void __thiscall zmq::socket_t::bind(char const *)" (?bind#socket_t#zmq##QAEXPBD#Z)
1>D:\[ Source Code ]\C++\ZeroMQServer\Debug\ZeroMQServer.exe : fatal error LNK1120: 14 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have installed the ZeroMQ binary v4.0.4 and updated the VS project properties to point to ZeroMQ's include and lib paths. Specifically, this is what I have updated in the project properties (I suspect some of these settings may be redundant):
Configuration Properties > VC++ Directories > Include Directories: Added '$(ZEROMQ_HOME)\include'
Configuration Properties > VC++ Directories > Library Directories: Added '$(ZEROMQ_HOME)\lib'
Configuration Properties > C/C++ > General > Additional Include Directories: Added '$(ZEROMQ_HOME)\include'
Configuration Properties > Linker > Input > Additional Dependencies: Added 'libzmq-v120-mt-4_0_4.lib;libzmq-v120-mt-gd-4_0_4.lib'
I'm on Win 7, 64-bit Edition.
Please help me resolve this.
According to the library names on zeromq.org, you are trying to link the same library twice: first with the release version, and then with the debug versions.
Remove libzmq-v120-mt-gd-4_0_4.lib from your Release configuration, and remove libzmq-v120-mt-4_0_4.lib from your Debug configuration.
[edit]
Your application probably is 32bit, and the library you are trying to link with is 64bit. (You can use dumpbin to determine what architecture a .lib file is for, see this answer for an example. Please use the 32bit library, or change your application to 64bit.
I had to define ZMQ_STATIC since I wanted to link zmq statically.
By default all these functions defined as
elif defined DLL_EXPORT
define ZMQ_EXPORT __declspec(dllexport)
I had the same errors. But for me they were produced by a wrong set calling convention.
(Just wanted to mention it here because it cost me more than a hour to track it.)

C++ NetLink Sockets Error

I recently started again on a C++ application. I am using NetLink for Sockets and Visual Studio for developing.
I made a small code but I got some errors. I've included the files from NetLink and I added ws2_32.lib (in linker/general & as pragma comment), but I still got these errors:
Error 1 error LNK2019: unresolved external symbol "void __cdecl NL::init(void)" (?init#NL##YAXXZ) referenced in function _main c:\Users\Joshua\documents\visual studio 2012\Projects\OBPP\OBPP\Main.obj
Error 4 error LNK2019: unresolved external symbol "public: class NL::Socket * __thiscall NL::Socket::accept(void)" (?accept#Socket#NL##QAEPAV12#XZ) referenced in function "private: virtual void __thiscall OnAccept::exec(class NL::Socket *,class NL::SocketGroup *,void *)" (?exec#OnAccept##EAEXPAVSocket#NL##PAVSocketGroup#3#PAX#Z) c:\Users\Joshua\documents\visual studio 2012\Projects\OBPP\OBPP\Main.obj
Error 6 error LNK2019: unresolved external symbol "public: bool __thiscall NL::SocketGroup::listen(unsigned int,void *)" (?listen#SocketGroup#NL##QAE_NIPAX#Z) referenced in function _main c:\Users\Joshua\documents\visual studio 2012\Projects\OBPP\OBPP\Main.obj
Error 5 error LNK2019: unresolved external symbol "public: __thiscall NL::SocketGroup::SocketGroup(void)" (??0SocketGroup#NL##QAE#XZ) referenced in function _main c:\Users\Joshua\documents\visual studio 2012\Projects\OBPP\OBPP\Main.obj
Error 2 error LNK2019: unresolved external symbol "public: __thiscall NL::Socket::Socket(unsigned int,enum NL::Protocol,enum NL::IPVer,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int)" (??0Socket#NL##QAE#IW4Protocol#1#W4IPVer#1#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##I#Z) referenced in function _main c:\Users\Joshua\documents\visual studio 2012\Projects\OBPP\OBPP\Main.obj
Error 3 error LNK2019: unresolved external symbol "public: __thiscall NL::Socket::~Socket(void)" (??1Socket#NL##QAE#XZ) referenced in function _main c:\Users\Joshua\documents\visual studio 2012\Projects\OBPP\OBPP\Main.obj
Error 7 error LNK1120: 6 unresolved externals c:\users\joshua\documents\visual studio 2012\Projects\OBPP\Debug\OBPP.exe
Code I'm using (just wanted to try out accepting):
#include <iostream>
#include "netlink\socket.h"
#include "netlink\socket_group.h"
#pragma comment(lib, "Ws2_32.lib")
#define PORT 30000
class OnAccept: public NL::SocketGroupCmd {
void exec(NL::Socket* socket, NL::SocketGroup* group, void* reference) {
NL::Socket* newConnection = socket->accept();
group->add(newConnection);
std::cout << "\nConnection " << newConnection->hostTo() << ":" << newConnection->portTo() << " added...";
std::cout.flush();
}
};
int main()
{
NL::init();
NL::Socket s(PORT);
NL::SocketGroup group;
group.setCmdOnAccept(&OnAccept());
group.add(&s);
if (group.listen(2000))
{
std::cout << "Listening on Sockets, port " << PORT << std::endl;
}
getchar();
}
I am the developer of the library. It can't be used with the headers only, you need to link the static/dynamic compiled library.
You have to build the library first, to generate the .lib file. Once you have the netLink.lib file built (or whatever you name it) you have to add that dependency to the linker.
I am not visual studio developer, But error message says unresolved external symbol means linker is not able to find some symbols.
Look at you linking command does it include Netlink library?

How do I read an unresolved external symbol error in Visual Studio?

How do I read this error message from Visual Studio? Any clues as to what exactly is missing? This is a complex project and guessing is a rather ineffective approach - I'd prefer to know exactly what to look for.
1>------ Build started: Project: Crypto, Configuration: debug_shared
x64 ------
1> Creating library ..\lib64\PocoCryptod.lib and object
..\lib64\PocoCryptod.exp 1>CipherImpl.obj : error LNK2019: unresolved
external symbol EVP_CIPHER_CTX_block_size referenced in function
"public: virtual unsigned __int64 __cdecl Poco::Crypto::`anonymous
namespace'::CryptoTransformImpl::blockSize(void)const "
(?blockSize#CryptoTransformImpl#?A0xbc3e4780#Crypto#Poco##UEBA_KXZ)
1>CipherImpl.obj : error LNK2019: unresolved external symbol
EVP_CipherInit referenced in function "public: __cdecl
Poco::Crypto::anonymous
namespace'::CryptoTransformImpl::CryptoTransformImpl(struct
evp_cipher_st const *,class std::vector<unsigned char,class
std::allocator<unsigned char> > const &,class std::vector<unsigned
char,class std::allocator<unsigned char> > const &,enum
Poco::Crypto::A0xbc3e4780::CryptoTransformImpl::Direction)"
(??0CryptoTransformImpl#?A0xbc3e4780#Crypto#Poco##QEAA#PEBUevp_cipher_st##AEBV?$vector#EV?$allocator#E#std###std##1W4Direction#0123##Z)
1>CipherImpl.obj : error LNK2019: unresolved external symbol
EVP_CipherUpdate referenced in function "public: virtual __int64
__cdecl Poco::Crypto::anonymous namespace'::CryptoTransformImpl::transform(unsigned char const
*,__int64,unsigned char *,__int64)" (?transform#CryptoTransformImpl#?A0xbc3e4780#Crypto#Poco##UEAA_JPEBE_JPEAE1#Z)
Full error list here
https://gist.github.com/anonymous/91a76564651be4ac43fc
You read it as
error LNK2019: unresolved external symbol EVP_CIPHER_CTX_block_size
The symbol EVP_CIPHER_CTX_block_size cannot be found.
referenced in function "public: virtual unsigned __int64 __cdecl Poco::Crypto::`anonymous namespace'::CryptoTransformImpl::blockSize(void)const " (?blockSize#CryptoTransformImpl#?A0xbc3e4780#Crypto#Poco##UEBA_KXZ)
You are attempting to use it in CryptoTransformImpl::blockSize(void)const (which is inside an anonymous namespace inside Poco::Crypto.
This can mean you didn't link against the library that exports that symbol.
EVP_.... are define in OpenSSL.
So you have to link with OpenSSL statically or dynamically.
You are missing the dll containing the EVP_CipherInit function in your library path.

MFC used in library causing error console application

I'm trying to use Task Schedule throulg Visual c++. I'm using Ctask.h (from here)
to do the task. However, when I build the solution (using Visual Studio 11), it says
fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
When I switch to /MD, it gives this error
ConsoleApplication12.obj : error LNK2019: unresolved external symbol "public: __thiscall CTask::CTask(void)" (??0CTask##QAE#XZ) referenced in function _wmain
1>ConsoleApplication12.obj : error LNK2019: unresolved external symbol "public: void __thiscall CTask::SetStartDateTime(class ATL::CTime const &)" (?SetStartDateTime#CTask##QAEXABVCTime#ATL###Z) referenced in function _wmain
1>ConsoleApplication12.obj : error LNK2019: unresolved external symbol "public: void __thiscall CTask::SetFrequency(enum CTask::ETaskFrequency)" (?SetFrequency#CTask##QAEXW4ETaskFrequency#1##Z) referenced in function _wmain
1>ConsoleApplication12.obj : error LNK2019: unresolved external symbol "public: void __thiscall CTask::SetProgram(wchar_t const *)" (?SetProgram#CTask##QAEXPB_W#Z) referenced in function _wmain
1>ConsoleApplication12.obj : error LNK2019: unresolved external symbol "public: void __thiscall CTask::SetAccountName(wchar_t const *)" (?SetAccountName#CTask##QAEXPB_W#Z) referenced in function _wmain
1>ConsoleApplication12.obj : error LNK2019: unresolved external symbol "public: long __thiscall CTask::SaveTask(wchar_t const *,int)const " (?SaveTask#CTask##QBEJPB_WH#Z) referenced in function _wmain
1>ConsoleApplication12.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CTask::~CTask(void)" (??1CTask##UAE#XZ) referenced in function _wmain
same is the case with other linking option. This is thecode I've typed:
#include "stdafx.h"
#include "CTask.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CTask task;
CTime time(2013, 03, 15, 7, 11, 0);
LPCTSTR sTaskName( L"Task Name" );
BOOL replace = TRUE;
task.SetProgram( L"E:\\aaa.txt" );
task.SetAccountName( L"harshilsharma63" );
task.SetStartDateTime( time );
task.SetFrequency( CTask::freqOnce );
if( S_OK == task.SaveTask( sTaskName, replace))
{
cout << "task successfully created!";
return 0;
}
else
{
cout << "task creation failed!";
return 1;
}
return 0;
}
I have already set "Use MFC in" to "Use MFC in shared DLL".
I don't see any indication that you actually have put the CTask.cpp into your project. Including the header only will result in the linker errors you see, you need the .cpp, too.
You need add to your project the CTask.cpp as well as CTask.h. The original project http://www.codeproject.com/Articles/13089/Harnessing-the-task-scheduler can be compiled without any trouble - I just checked it!