C++ NetLink Sockets Error - c++

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?

Related

visual studio foobar2000 component build errors

I've been following a development tutorial for foobar2000 components, but keep getting build errors with only minimal code. My VS solution includes these projects from the foobar2000 SDK: foobar2000_component_client, foobar200_SDK, and pfc.
foo_playlists_tag.cpp:
#include "U:\SDK\Foobar2000-music-player\foobar2000\SDK\foobar2000.h"
DECLARE_COMPONENT_VERSION("Playlists tagger","0.0.1","About text here");
VALIDATE_COMPONENT_FILENAME("foo_playlists_tag.dll");
Build ouput:
1>------ Build started: Project: foo_playlists_tag, Configuration: Debug x64 ------
1> foo_playlists_tag.cpp
1>u:\sdk\foobar2000-music-player\foobar2000\shared\fb2kdebug.h(80): warning C4838: conversion from 'int' to 'const ULONG_PTR' requires a narrowing conversion
1>foo_playlists_tag.obj : error LNK2019: unresolved external symbol "void __cdecl pfc::myassert_win32(wchar_t const *,wchar_t const *,unsigned int)" (?myassert_win32#pfc##YAXPEB_W0I#Z) referenced in function __catch$??$service_add_ref_safe#Vcomponent_installation_validator####YAXPEAVcomponent_installation_validator###Z$0
1>foo_playlists_tag.obj : error LNK2019: unresolved external symbol "char const * __cdecl core_api::get_my_file_name(void)" (?get_my_file_name#core_api##YAPEBDXZ) referenced in function "public: virtual void __cdecl `anonymous namespace'::componentversion_myimpl::get_file_name(class pfc::string_base &)" (?get_file_name#componentversion_myimpl#?A0xa2c48e39##UEAAXAEAVstring_base#pfc###Z)
1>foo_playlists_tag.obj : error LNK2019: unresolved external symbol "bool __cdecl core_api::are_services_available(void)" (?are_services_available#core_api##YA_NXZ) referenced in function "protected: __cdecl service_factory_base::service_factory_base(struct _GUID const &,class service_factory_base * &)" (??0service_factory_base##IEAA#AEBU_GUID##AEAPEAV0##Z)
1>foo_playlists_tag.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl component_installation_validator::test_my_name(char const *)" (?test_my_name#component_installation_validator##SA_NPEBD#Z) referenced in function "public: virtual bool __cdecl component_installation_validator_filename::is_installed_correctly(void)" (?is_installed_correctly#component_installation_validator_filename##UEAA_NXZ)
1>foo_playlists_tag.obj : error LNK2001: unresolved external symbol "public: static class service_factory_base * service_factory_base::__internal__list" (?__internal__list#service_factory_base##2PEAV1#EA)
1>foo_playlists_tag.obj : error LNK2001: unresolved external symbol "public: static struct _GUID const componentversion::class_guid" (?class_guid#componentversion##2U_GUID##B)
1>foo_playlists_tag.obj : error LNK2001: unresolved external symbol "public: static struct _GUID const component_installation_validator::class_guid" (?class_guid#component_installation_validator##2U_GUID##B)
1>U:\Repositories\foo_playlists_tag\x64\Debug\foo_playlists_tag.dll : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========
Where are these errors coming from? and how can I resovle them?
Any assistance is greatly appreciated.
Found my answer on hydrogenaud.io by user kode54:
In Visual Studio 2010, you must add all dependencies directly to the project you are trying to link, as references. You may find the references list in the Properties dialog for the project, under Common Properties, Frameworks and References. The old style Dependencies dialog doesn't seem to function for that purpose past Visual Studio 2008.
Thank you for your assistance; helped me find that lib file.

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++11 and Visual Studio - unresolved external symbol [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 8 years ago.
I try to run my C++ code in Visual Studio 2013.
The code was running in the past the gcc 4.9
I don't know why the code is in Visual Studio not running.
I upload the code to GitHub so that everyone can take a look at it. Please help me. I really don't know why the code is not running in Visual Studio.
Error 1 error LNK2019: unresolved external symbol "public: __thiscall ********::Property::Property<int,1>::Property<int,1>(class std::function<int __cdecl(void)> const &,class std::function<void __cdecl(int)> const &)" (??0?$Property#H$00#Property#********##QAE#ABV?$function#$$A6AHXZ#std##ABV?$function#$$A6AXH#Z#4##Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 2 error LNK2019: unresolved external symbol "public: __thiscall ********::Property::Property<int,1>::operator int const (void)" (??B?$Property#H$00#Property#********##QAE?BHXZ) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 3 error LNK2019: unresolved external symbol "public: int __thiscall ********::Property::Property<int,1>::operator=(int const &)" (??4?$Property#H$00#Property#********##QAEHABH#Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 4 error LNK2019: unresolved external symbol "public: int __thiscall ********::Property::Property<int,1>::operator+=(int const &)" (??Y?$Property#H$00#Property#********##QAEHABH#Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 5 error LNK2019: unresolved external symbol "public: int __thiscall ********::Property::Property<int,1>::operator-=(int const &)" (??Z?$Property#H$00#Property#********##QAEHABH#Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 6 error LNK2019: unresolved external symbol "public: int __thiscall ********::Property::Property<int,1>::operator*=(int const &)" (??X?$Property#H$00#Property#********##QAEHABH#Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 7 error LNK2019: unresolved external symbol "public: int __thiscall ********::Property::Property<int,1>::operator/=(int const &)" (??_0?$Property#H$00#Property#********##QAEHABH#Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 8 error LNK2019: unresolved external symbol "public: int __thiscall ********::Property::Property<int,1>::operator%=(int const &)" (??_1?$Property#H$00#Property#********##QAEHABH#Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 9 error LNK2019: unresolved external symbol "public: __thiscall ********::Property::Property<int,2>::Property<int,2>(class std::function<int __cdecl(void)> const &)" (??0?$Property#H$01#Property#********##QAE#ABV?$function#$$A6AHXZ#std###Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 10 error LNK2019: unresolved external symbol "public: __thiscall ********::Property::Property<int,2>::operator int const (void)" (??B?$Property#H$01#Property#********##QAE?BHXZ) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 11 error LNK2019: unresolved external symbol "public: __thiscall ********::Property::Property<int,3>::Property<int,3>(class std::function<void __cdecl(int)> const &)" (??0?$Property#H$02#Property#********##QAE#ABV?$function#$$A6AXH#Z#std###Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 12 error LNK2019: unresolved external symbol "public: void __thiscall ********::Property::Property<int,3>::operator=(int)" (??4?$Property#H$02#Property#********##QAEXH#Z) referenced in function _main C:\Users\#######\documents\visual studio 2013\Projects\********\Property\PropertyTest.obj Property
Error 13 error LNK1120: 12 unresolved externals C:\Users\#######\documents\visual studio 2013\Projects\********\Debug\Property.exe Property
[Closed]
Like Praetorian wrote, Template Classes can not be easiely splited into Header (.h) and Source (.cpp) Files. The reason is that "the compiler creates a new class with the given template argument." quote
My Solution to split Template Classes into Header (.h) and Source (.cpp) Files looks like this:
// HEADER File test.h
#ifndef __TEST_FH__
#define __TEST_FH__
template<typename T>
class test {
public:
T object;
test();
~test();
};
#include "test.cpp"
#endif
// SOURCE File test.cpp
#ifdef __TEST_FH__
#ifndef __TEST_SOURCE_FH__
#define __TEST_SOURCE_FH__
template<typename T>
test::test() {
//code
}
template<typename T>
test::~test() {
//code
}
#endif
#endif
Once more thank you very much Praetorian.

link error while open dicom image in .net using open cv

#include <dcmtk\oflog\config.h>
#include <dcmtk\dcmimgle\dcmimage.h>
#include <dcmtk\dcmnet\dicom.h>
#include <dcmtk\config\osconfig.h>
#include <iostream>
#include <fstream>
#include <ostream>
#include <iomanip>
#include<dcmtk\ofstd\ofstream.h>
#include<dcmtk\dcmdata\dctk.h>
int main(int argc, char *argv[])
{
OFLog::configure(OFLogger::INFO_LOG_LEVEL);
DicomImage *image = new DicomImage("E:\\datamining project\\dataset\\Lung CT image\\nodules\\nodules\\23.dcm", CIF_UsePartialAccessToPixelData, 0, 10 /* fcount */);
if (image->getStatus() == EIS_Normal)
{
do {
DCMIMGLE_INFO("processing frame " << image->getFirstFrame() + 1 << " to "<< image->getFirstFrame() + image->getFrameCount());
} while (image->processNextFrames());
}
delete image;
return 0;
}
Error 1 error LNK2019: unresolved external symbol "public: __thiscall OFString::~OFString(void)" (??1OFString##QAE#XZ) referenced in function _main c:\Users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\dcmimage\dcmimage.obj dcmimage
Error 2 error LNK2019: unresolved external symbol "public: __thiscall OFString::OFString(char const *)" (??0OFString##QAE#PBD#Z) referenced in function _main c:\Users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\dcmimage\dcmimage.obj dcmimage
Error 3 error LNK2019: unresolved external symbol "class OFLogger __cdecl DCM_dcmimgleGetLogger(void)" (?DCM_dcmimgleGetLogger##YA?AVOFLogger##XZ) referenced in function _main c:\Users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\dcmimage\dcmimage.obj dcmimage
Error 4 error LNK2019: unresolved external symbol "public: __thiscall DicomImage::DicomImage(char const *,unsigned long,unsigned long,unsigned long)" (??0DicomImage##QAE#PBDKKK#Z) referenced in function _main c:\Users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\dcmimage\dcmimage.obj dcmimage
Error 5 error LNK2019: unresolved external symbol "public: static void __cdecl OFLog::configure(enum OFLogger::LogLevel)" (?configure#OFLog##SAXW4LogLevel#OFLogger###Z) referenced in function _main c:\Users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\dcmimage\dcmimage.obj dcmimage
Error 6 error LNK2019: unresolved external symbol "public: bool __thiscall log4cplus::Logger::isEnabledFor(int)const " (?isEnabledFor#Logger#log4cplus##QBE_NH#Z) referenced in function "public: bool __thiscall OFLogger::isEnabledFor(int)const " (?isEnabledFor#OFLogger##QBE_NH#Z) c:\Users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\dcmimage\dcmimage.obj dcmimage
Error 7 error LNK2019: unresolved external symbol "public: void __thiscall log4cplus::Logger::forcedLog(int,class OFString const &,char const *,int,char const *)const " (?forcedLog#Logger#log4cplus##QBEXHABVOFString##PBDH1#Z) referenced in function "public: void __thiscall OFLogger::forcedLog(int,class OFString const &,char const *,int,char const *)const " (?forcedLog#OFLogger##QBEXHABVOFString##PBDH1#Z) c:\Users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\dcmimage\dcmimage.obj dcmimage
error LNK2019: unresolved external symbol "public: virtual __thiscall log4cplus::Logger::~Logger(void)" (??1Logger#log4cplus##UAE#XZ) referenced in function "public: virtual __thiscall OFLogger::~OFLogger(void)" (??1OFLogger##UAE#XZ) c:\Users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\dcmimage\dcmimage.obj dcmimage
error LNK1120: 8 unresolved externals c:\users\prashant naresh\documents\visual studio 2010\Projects\dcmimage\Debug\dcmimage.exe dcmimage
I don't have CMake installed at the moment on my machine, so I can't try this out myself.
Looks likes you have to build various libraries, this one looks particularly interesting: ofstd.lib. Then there's also oflog.lib.
Please make sure that you linked the following libraries to your project (Project Properties --> Linker --> Input --> Additional Dependencies):
oflog.lib;ofstd.lib;iphlpapi.lib;ws2_32.lib;netapi32.lib;wsock32.lib

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!