Solved

how do i resovle this problem in a dll?

Posted on 2015-01-07
1
379 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 34

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

726 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