?
Solved

how do i resovle this problem in a dll?

Posted on 2015-01-07
1
Medium Priority
?
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
sarabande earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

752 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