944,131 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4509
  • C++ RSS
Aug 28th, 2006
0

What is it meaned [Linker error] undefined reference to `MAPILogon@24'

Expand Post »
C++ Code:


C++ Syntax (Toggle Plain Text)
  1. /* readmail.c */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <windows.h>
  5. #include <windowsx.h>
  6. #include <mapi.h>
  7. #include <string.h>
  8. int readmail();
  9. long err;
  10. LHANDLE lhSession;
  11. lpMapiMessage FAR *lppMessage;
  12. lpMapiMessage lpMessage;
  13. char szSeedMessageID[512];
  14. char szMessageID[512];
  15. char szTmp[4096];
  16. char szTmp2[50];
  17. LPSTR lpszSeedMessageID=&szSeedMessageID[0];
  18. LPSTR lpszMessageID=&szMessageID[0];
  19. int main()
  20. {
  21. readmail();
  22. return(0);
  23. }
  24.  
  25. int readmail()
  26. {
  27.  
  28. /************ Logon **********************/
  29. err = MAPILogon(0L, "", "", MAPI_LOGON_UI, 0L,
  30. &lhSession);
  31. if(err != SUCCESS_SUCCESS)
  32. {
  33. MessageBox(0, "Error logging on", "Error", MB_OK);
  34. return(0);
  35. }
  36. /********* Find Messages ********************/
  37. *lpszSeedMessageID = '\0';
  38. // reset MAPIFindNext back to the top again
  39. err = MAPIFindNext(lhSession, 0L, "IPM.Microsoft Mail.Note",
  40. lpszSeedMessageID, 0L, 0L, lpszMessageID);
  41. if(err != SUCCESS_SUCCESS)
  42. {
  43. MessageBox(0, "Error finding first message", "Error",
  44. MB_OK);
  45. err = MAPILogoff(lhSession, 0L, 0L, 0L);
  46. return(0);
  47.  
  48. }
  49. do
  50. {
  51. lppMessage=(lpMapiMessage FAR *) &lpMessage;
  52. /******** Read Message *************/
  53. err = MAPIReadMail(lhSession, 0L, lpszMessageID,
  54. MAPI_PEEK, 0L, lppMessage);
  55. if(err != SUCCESS_SUCCESS)
  56. {
  57. MessageBox(0, "Error during message read", "Error",
  58. MB_OK);
  59. err = MAPILogoff(lhSession, 0L, 0L, 0L);
  60. return(0);
  61. }
  62. /******* copy Subject and NoteText into string *************/
  63. if((lpMessage->lpszSubject) != NULL){
  64. _fstrcpy(szTmp2, lpMessage->lpszSubject); // Check for NULL strings
  65. }
  66. else _fstrcpy(szTmp2,"No subject text");
  67. if((lpMessage->lpszNoteText) != NULL){
  68. if(_fstrlen(lpMessage->lpszNoteText)>4096){ // Check for large message body
  69. MessageBox(0, "Message body to large", "MAPI2.C", MB_OK);
  70. }
  71. _fstrcpy(szTmp, lpMessage->lpszNoteText);
  72. }
  73. else _fstrcpy(szTmp, "No message body");
  74. printf("\nSUBJECT: %s\n", szTmp2);
  75. printf("\nNOTETEXT: \n%s\n", szTmp);
  76. /****** free memory used by MAPI *********************/
  77. err = MAPIFreeBuffer(lpMessage);
  78. if(err != SUCCESS_SUCCESS)
  79. {
  80. MessageBox(0, "Error freeing memory", "Error",MB_OK);
  81. }
  82. //get next message ID.
  83. lstrcpy(lpszSeedMessageID, lpszMessageID);
  84. err = MAPIFindNext(lhSession, 0L, "IPM.Microsoft Mail.Note",
  85. lpszSeedMessageID, 0L, 0L, lpszMessageID);
  86. if(err != SUCCESS_SUCCESS)
  87. {
  88. MessageBox(0, "No more messages", "Warning",
  89. MB_OK);
  90. err = MAPILogoff(lhSession, 0L, 0L, 0L);
  91. return(0);
  92. }
  93. lppMessage=(lpMapiMessage FAR *) &lpMessage;
  94.  
  95. }while(err == SUCCESS_SUCCESS);
  96.  
  97. /************** Logoff ***************/
  98. err = MAPILogoff(lhSession, 0L, 0L, 0L);
  99. return(0);
  100. }










//====================================================================
Error in Dev C++ compile

[Linker error] undefined reference to `MAPILogon@24'
[Linker error] undefined reference to `MAPIFindNext@28'
[Linker error] undefined reference to `MAPILogoff@16'
[Linker error] undefined reference to `MAPIReadMail@24'
[Linker error] undefined reference to `MAPILogoff@16'
[Linker error] undefined reference to `MAPIFreeBuffer@4'
[Linker error] undefined reference to `MAPIFindNext@28'
[Linker error] undefined reference to `MAPILogoff@16'
[Linker error] undefined reference to `MAPILogoff@16'
ld returned 1 exit status
C:\Dev-Cpp\project4\Makefile.win [Build Error] [Project4.exe] Error 1

Why? and Whatis MAPILogon@24 mean & @16 % @28 ?
Last edited by jacove; Aug 28th, 2006 at 2:35 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jacove is offline Offline
1 posts
since Aug 2006
Aug 28th, 2006
0

Re: What is it meaned [Linker error] undefined reference to `MAPILogon@24'

That means you are not linking the libraries with the object code for those functions. RTFM and find the required library.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Aug 28th, 2006
0

Re: What is it meaned [Linker error] undefined reference to `MAPILogon@24'

Unlike most win32 api functions mapi does not have a library. Instead, you will have to learn how to use LoadLibrary() and GetProcAddress(), as explained in MSDN
Quote ...
To use the Simple MAPI functions, compile your source code with MAPI.H.
MAPI.H contains definitions for all of the functions, return value constants,
and data types. To call a Simple MAPI function, load MAPI.DLL and use the
Win32 GetProcAddress function to acquire an entry point. The function
calling conventions should be FAR PASCAL.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,961 posts
since Aug 2005
Aug 28th, 2006
0

Re: What is it meaned [Linker error] undefined reference to `MAPILogon@24'

It used to happen to me lot of times,

I use Dev C++,

The problem is that you have included the header file that contains this function , but forgot to include the .lib or .a files with your files.

Suppose you want to use winsock with your app,

#include <windows.h>
#include <winsock.h>

run_some_function_in_winsock();

but then you forget to include winsock.lib , it won't work because that function is defined in winsock.h , and is present in the winsock32.dll , and winsock.lib tells your compiler to link that function with your function call in your app.
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ishwar is offline Offline
24 posts
since Jul 2006
Aug 28th, 2006
0

Re: What is it meaned [Linker error] undefined reference to `MAPILogon@24'

Click to Expand / Collapse  Quote originally posted by ishwar ...
It used to happen to me lot of times,
The problem is that you have included the header file that contains this function , but forgot to include the .lib or .a files with your files.
I guess you didn't bother to read any of the other posts. If you had, you would have found out that there is no library for the functions he is calling.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,961 posts
since Aug 2005
Aug 29th, 2006
0

Re: What is it meaned [Linker error] undefined reference to `MAPILogon@24'

I guess you didn't bother to read any of the other posts. If you had, you would have found out that there is no library for the functions he is calling.

ummm , I seem to have it.

mapi32.lib ??

Anyways , you may download the zip file I have included,

It should work, It was in my Dev C++ lib folder,


Ishwar
Attached Files
File Type: zip mapi32.zip (6.6 KB, 89 views)
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ishwar is offline Offline
24 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Exponents: whats double etc?
Next Thread in C++ Forum Timeline: Cannot Get Dev-C++ to compile correctly





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC