| | |
What is it meaned [Linker error] undefined reference to `MAPILogon@24'
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2006
Posts: 1
Reputation:
Solved Threads: 0
C++ Code:
//====================================================================
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 ?
C++ Syntax (Toggle Plain Text)
/* readmail.c */ #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <windowsx.h> #include <mapi.h> #include <string.h> int readmail(); long err; LHANDLE lhSession; lpMapiMessage FAR *lppMessage; lpMapiMessage lpMessage; char szSeedMessageID[512]; char szMessageID[512]; char szTmp[4096]; char szTmp2[50]; LPSTR lpszSeedMessageID=&szSeedMessageID[0]; LPSTR lpszMessageID=&szMessageID[0]; int main() { readmail(); return(0); } int readmail() { /************ Logon **********************/ err = MAPILogon(0L, "", "", MAPI_LOGON_UI, 0L, &lhSession); if(err != SUCCESS_SUCCESS) { MessageBox(0, "Error logging on", "Error", MB_OK); return(0); } /********* Find Messages ********************/ *lpszSeedMessageID = '\0'; // reset MAPIFindNext back to the top again err = MAPIFindNext(lhSession, 0L, "IPM.Microsoft Mail.Note", lpszSeedMessageID, 0L, 0L, lpszMessageID); if(err != SUCCESS_SUCCESS) { MessageBox(0, "Error finding first message", "Error", MB_OK); err = MAPILogoff(lhSession, 0L, 0L, 0L); return(0); } do { lppMessage=(lpMapiMessage FAR *) &lpMessage; /******** Read Message *************/ err = MAPIReadMail(lhSession, 0L, lpszMessageID, MAPI_PEEK, 0L, lppMessage); if(err != SUCCESS_SUCCESS) { MessageBox(0, "Error during message read", "Error", MB_OK); err = MAPILogoff(lhSession, 0L, 0L, 0L); return(0); } /******* copy Subject and NoteText into string *************/ if((lpMessage->lpszSubject) != NULL){ _fstrcpy(szTmp2, lpMessage->lpszSubject); // Check for NULL strings } else _fstrcpy(szTmp2,"No subject text"); if((lpMessage->lpszNoteText) != NULL){ if(_fstrlen(lpMessage->lpszNoteText)>4096){ // Check for large message body MessageBox(0, "Message body to large", "MAPI2.C", MB_OK); } _fstrcpy(szTmp, lpMessage->lpszNoteText); } else _fstrcpy(szTmp, "No message body"); printf("\nSUBJECT: %s\n", szTmp2); printf("\nNOTETEXT: \n%s\n", szTmp); /****** free memory used by MAPI *********************/ err = MAPIFreeBuffer(lpMessage); if(err != SUCCESS_SUCCESS) { MessageBox(0, "Error freeing memory", "Error",MB_OK); } //get next message ID. lstrcpy(lpszSeedMessageID, lpszMessageID); err = MAPIFindNext(lhSession, 0L, "IPM.Microsoft Mail.Note", lpszSeedMessageID, 0L, 0L, lpszMessageID); if(err != SUCCESS_SUCCESS) { MessageBox(0, "No more messages", "Warning", MB_OK); err = MAPILogoff(lhSession, 0L, 0L, 0L); return(0); } lppMessage=(lpMapiMessage FAR *) &lpMessage; }while(err == SUCCESS_SUCCESS); /************** Logoff ***************/ err = MAPILogoff(lhSession, 0L, 0L, 0L); return(0); }
//====================================================================
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.
That means you are not linking the libraries with the object code for those functions. RTFM and find the required library.
バルサミコ酢やっぱいらへんで
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.
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.
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.
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.
•
•
•
•
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
![]() |
Similar Threads
- Dev C++ linker errors, undefined reference (C++)
- [Linker error] undefined reference to `CQTMovieFile::CQTMovieFile()' (C++)
- Dev-C++, GLUI linker error, undefined reference (C++)
- Linker Error>Undefined reference error to xyz (C++)
Other Threads in the C++ Forum
- Previous Thread: Exponents: whats double etc?
- Next Thread: Cannot Get Dev-C++ to compile correctly
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






