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

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2006
Posts: 1
Reputation: jacove is an unknown quantity at this point 
Solved Threads: 0
jacove jacove is offline Offline
Newbie Poster

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

 
0
  #1
Aug 28th, 2006
C++ Code:


  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

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

 
0
  #2
Aug 28th, 2006
That means you are not linking the libraries with the object code for those functions. RTFM and find the required library.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,342
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1460
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #3
Aug 28th, 2006
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
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 24
Reputation: ishwar is an unknown quantity at this point 
Solved Threads: 0
ishwar's Avatar
ishwar ishwar is offline Offline
Newbie Poster

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

 
0
  #4
Aug 28th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,342
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1460
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #5
Aug 28th, 2006
Originally Posted by ishwar View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 24
Reputation: ishwar is an unknown quantity at this point 
Solved Threads: 0
ishwar's Avatar
ishwar ishwar is offline Offline
Newbie Poster

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

 
0
  #6
Aug 29th, 2006
Originally Posted by Ancient Dragon View Post
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, 21 views)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC