Solved

how do i resovle this problem in a dll?

Posted on 2015-01-07
1
337 Views
Last Modified: 2015-01-10
hello sir
im unfarmilar with c++ & have written such following code,i just trying to make a dll & i have a problem ,i have google for this,however the google said it sounds like i have removed the #define variable problem,is it true?it's a #define in dll,#define as well known that meaning of unchangable variable,how do i change the value in #define, for example,i tried to make a #define as a ordinary variable,but the programe occur error,show the codes,did i missing something?

#include "quickmail.h"
#include <stdio.h>
#include "mymail3.h"


#pragma comment(lib, "libquickmail.a")

int   __stdcall sendmyemail(const char* emailservername,const char* senduser ,const char *thepass,const char* myemailaddr,const char* toname,const char* emailsendaddr,const char* thetitle,const  char* thebody,const char* attachaddr )
{

unsigned int SMTPPORT=25;

int returncode;
returncode=0;

quickmail_initialize();
quickmail mailobj = quickmail_create(myemailaddr, thetitle);

quickmail_add_to(mailobj, emailsendaddr);


quickmail_add_header(mailobj, "Importance: Low");
quickmail_add_header(mailobj, "X-Priority: 5");
quickmail_add_header(mailobj, "X-MSMail-Priority: Low");
quickmail_set_body(mailobj, thebody);

quickmail_add_body_memory(mailobj, "text/html", "This is a <b>test</b> e-mail.<br/>\nThis mail was sent using <u>libquickmail</u>.", 80, 0);

quickmail_add_attachment_file(mailobj, attachaddr, NULL);

quickmail_add_attachment_memory(mailobj, "test.log", NULL, "Test\n123", 8, 0);

const char* errmsg;
quickmail_set_debug_log(mailobj, stderr);
if ((errmsg = quickmail_send(mailobj, emailservername, SMTPPORT, senduser, thepass)) != NULL)
returncode=-1;
quickmail_destroy(mailobj);
if (returncode==0)
return 0;
else
return -1;
}


1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_destroy,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_send,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_set_debug_log,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_attachment_memory,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_attachment_file,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_body_memory,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_set_body,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_header,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_to,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_create,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_initialize,referenced in function _sendmyemail@36

please take a look at the original sample

http://sourceforge.net/p/libquickmail/code/HEAD/tree/test_quickmail.c#l27

#include "quickmail.h"
#include <stdio.h>
#define FROM "my@domain.com"
#define TO "someuser@domain.com"
//#define CC "otheruser@domain.com"
//#define BCC "otheruser@domain.com"
#define SMTPSERVER "smtp.mydomain.com"
#define SMTPPORT 25
#define SMTPUSER NULL
#define SMTPPASS NULL
void list_attachment_callback (quickmail mailobj, const char* filename, quickmail_attachment_open_fn email_info_attachment_open, quickmail_attachment_read_fn email_info_attachment_read, quickmail_attachment_close_fn email_info_attachment_close, void* callbackdata)
{
printf("[%i]: %s\n", ++*(int*)callbackdata, filename);
}
int main ()
{
printf("libquickmail %s\n", quickmail_get_version());
quickmail_initialize();
quickmail mailobj = quickmail_create(FROM, "libquickmail test e-mail");
#ifdef TO
quickmail_add_to(mailobj, TO);
#endif
#ifdef CC
quickmail_add_cc(mailobj, CC);
#endif
#ifdef BCC
quickmail_add_bcc(mailobj, BCC);
#endif
quickmail_add_header(mailobj, "Importance: Low");
quickmail_add_header(mailobj, "X-Priority: 5");
quickmail_add_header(mailobj, "X-MSMail-Priority: Low");
quickmail_set_body(mailobj, "This is a test e-mail.\nThis mail was sent using libquickmail.");
//quickmail_add_body_memory(mailobj, NULL, "This is a test e-mail.\nThis mail was sent using libquickmail.", 64, 0);
quickmail_add_body_memory(mailobj, "text/html", "This is a <b>test</b> e-mail.<br/>\nThis mail was sent using <u>libquickmail</u>.", 80, 0);
/**/
quickmail_add_attachment_file(mailobj, "test_quickmail.c", NULL);
quickmail_add_attachment_file(mailobj, "test_quickmail.cbp", NULL);
quickmail_add_attachment_memory(mailobj, "test.log", NULL, "Test\n123", 8, 0);
/**/
/*/
quickmail_fsave(mailobj, stdout);
int i;
i = 0;
quickmail_list_attachments(mailobj, list_attachment_callback, &i);
quickmail_remove_attachment(mailobj, "test_quickmail.cbp");
i = 0;
quickmail_list_attachments(mailobj, list_attachment_callback, &i);
quickmail_destroy(mailobj);
return 0;
/**/
const char* errmsg;
quickmail_set_debug_log(mailobj, stderr);
if ((errmsg = quickmail_send(mailobj, SMTPSERVER, SMTPPORT, SMTPUSER, SMTPPASS)) != NULL)
fprintf(stderr, "Error sending e-mail: %s\n", errmsg);
quickmail_destroy(mailobj);
return 0;
}
0
Comment
Question by:ken yup
1 Comment
 
LVL 32

Accepted Solution

by:
sarabande earned 500 total points
ID: 40537424
#pragma comment(lib, "libquickmail.a")
libraries with .a extension are (most likely) unix libraries which can't be used by visual c++ projects. you have to look for quickmail.lib file which might also be provided by quickmail. if not, try to download quickmail for windows.

instead of the #pragma statement you may consider to add the quickmail.lib to the project properties. for both debug and release configuration add 'quickmail.lib' to Configuration Properties\Linker\Additional Dependencies. for any case, the path of the folder where quickmail.lib resides must be added to Configuration Properties\VC++ Directories\Library Directories (also for both debug and release configuration).

Sara
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now