Solved

how do i resovle this problem in a dll?

Posted on 2015-01-07
1
350 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 33

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

911 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

20 Experts available now in Live!

Get 1:1 Help Now