[Ace-users] Undefined reference error

S sunnypalsingh at gmail.com
Sun Jan 20 16:54:47 CST 2008


On Jan 20, 11:33 pm, schm... at dre.vanderbilt.edu (Douglas C. Schmidt)
wrote:
> Hi,
>
> >I recently built the ACE framework on my windowsXP service pack 2
> >machine.
>
> To ensure that we have proper version/platform/compiler information,
> please make sure you fill out the appropriate problem report form
> (PRF), which is in
>
> $ACE_ROOT/PROBLEM-REPORT-FORM
> $TAO_ROOT/PROBLEM-REPORT-FORM
>
> or in
>
> $ACE_ROOT/BUG-REPORT-FORM
> $TAO_ROOT/BUG-REPORT-FORM
>
> in older versions of ACE+TAO.  Make sure to include this information
> when asking any questions about ACE+TAO since otherwise we have to
> "guess" what version/platform/compiler/options you've using, which is
> very error-prone and slows down our responsiveness.  If you don't use
> the PRF, therefore, it is less likely that someone from the core
> ACE+TAO developer team will be able to answer your question.
> Naturally, we encourage and appreciate other members of the ACE+TAO
> user community who can respond to questions that they have the answers
> to.
>
> >I am using Codeblocks with MinGW. In the compiler I #defined WIN32 and
> >tried to compile the following code:
>
> There's a MinGW build reported on our auto-build scoreboard at
>
> http://www.dre.vanderbilt.edu/scoreboard/integrated.html
>
> I recommend you take a look at it see what configuration is used and
> apply this to your environment.
>
> Thanks,
>
>         Doug
>
>
>
> >#include "ace/Log_Msg.h"
> >void foo (void);
> >int main(int, char *[])
> >{
> >    ACE_TRACE("main");
> >    ACE_DEBUG ((LM_INFO, "%IHi Mom\n"));
> >    foo();
> >    ACE_DEBUG ((LM_INFO, "%IGoodnight\n"));
> >    return 0;
> >}
> >void foo (void)
> >{
> >    ACE_TRACE ("foo");
> >    ACE_DEBUG ((LM_INFO, "%IHowdy Pardner\n"));
> >}
>
> >I got undefined reference error
>
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:3: undefined reference to
> >`_imp___ZN13ACE_Main_Base3runEiPPc'
> >obj\Debug\main.o: In function `Z10ace_main_iiPPc':
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:6: undefined reference to
> >`_imp___ZN11ACE_Log_Msg18last_error_adapterEv'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:6: undefined reference to
> >`_imp___ZN11ACE_Log_Msg8instanceEv'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:6: undefined reference to
> >`_imp___ZN11ACE_Log_Msg15conditional_setEPKciii'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:6: undefined reference to
> >`_imp___ZN11ACE_Log_Msg3logE16ACE_Log_PriorityPKcz'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:8: undefined reference to
> >`_imp___ZN11ACE_Log_Msg18last_error_adapterEv'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:8: undefined reference to
> >`_imp___ZN11ACE_Log_Msg8instanceEv'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:8: undefined reference to
> >`_imp___ZN11ACE_Log_Msg15conditional_setEPKciii'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:8: undefined reference to
> >`_imp___ZN11ACE_Log_Msg3logE16ACE_Log_PriorityPKcz'
> >obj\Debug\main.o: In function `Z3foov':
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:14: undefined reference to
> >`_imp___ZN11ACE_Log_Msg18last_error_adapterEv'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:14: undefined reference to
> >`_imp___ZN11ACE_Log_Msg8instanceEv'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:14: undefined reference to
> >`_imp___ZN11ACE_Log_Msg15conditional_setEPKciii'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:14: undefined reference to
> >`_imp___ZN11ACE_Log_Msg3logE16ACE_Log_PriorityPKcz'
> >obj\Debug\main.o: In function `main':
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:3: undefined reference to
> >`_imp___ZN13ACE_Main_BaseD2Ev'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:3: undefined reference to
> >`_imp___ZN13ACE_Main_BaseC2Ev'
> >C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
> >ACEProject/main.cpp:3: undefined reference to
> >`_imp___ZN13ACE_Main_BaseD2Ev'
> >collect2: ld returned 1 exit status
> >Process terminated with status 1 (0 minutes, 1 seconds)
> >16 errors, 0 warnings
>
> >Any help on this??
>
> --
> Dr. Douglas C. Schmidt                       Professor and Associate Chair
> Electrical Engineering and Computer Science  TEL: (615) 343-8197
> Vanderbilt University                        WEB:www.dre.vanderbilt.edu/~schmidt
> Nashville, TN 37203                          NET: d.schm... at vanderbilt.edu

Here are the details

ACE VERSION: 5.6

HOST MACHINE and OPERATING SYSTEM:
Windows XP 32 bits SP2, Don't know how to find about Winsock version

TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
 COMPILER NAME AND VERSION (AND PATCHLEVEL):
Same as above

THE $ACE_ROOT/ace/config.h FILE
#include "ace/config-win32.h"

THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE:
include $(ACE_ROOT)/include/makeinclude/platform_mingw32.GNU

CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
There was no default.feature in the folder. There was only default.rel

 AREA/CLASS/EXAMPLE AFFECTED:

I have #defined WIN32 before executing the code

#include "ace/Log_Msg.h"
void foo (void);
int main(int, char *[]) <--------------- Complains about main function
{
    ACE_TRACE("main");
    ACE_DEBUG ((LM_INFO, "%IHi Mom\n"));
    foo();
    ACE_DEBUG ((LM_INFO, "%IGoodnight\n"));
    return 0;
}

void foo (void)
{
    ACE_TRACE ("foo");
    ACE_DEBUG ((LM_INFO, "%IHowdy Pardner\n"));

}
DOES THE PROBLEM AFFECT:
 COMPILATION?   Yes
 LINKING?
 On Unix systems, did you run make realclean first?
 EXECUTION?
 OTHER (please specify)?

 SYNOPSIS:
There are around 16 errors
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:3: undefined reference to
`_imp___ZN13ACE_Main_Base3runEiPPc'
obj\Debug\main.o: In function `Z10ace_main_iiPPc':
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:6: undefined reference to
`_imp___ZN11ACE_Log_Msg18last_error_adapterEv'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:6: undefined reference to
`_imp___ZN11ACE_Log_Msg8instanceEv'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:6: undefined reference to
`_imp___ZN11ACE_Log_Msg15conditional_setEPKciii'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:6: undefined reference to
`_imp___ZN11ACE_Log_Msg3logE16ACE_Log_PriorityPKcz'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:8: undefined reference to
`_imp___ZN11ACE_Log_Msg18last_error_adapterEv'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:8: undefined reference to
`_imp___ZN11ACE_Log_Msg8instanceEv'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:8: undefined reference to
`_imp___ZN11ACE_Log_Msg15conditional_setEPKciii'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:8: undefined reference to
`_imp___ZN11ACE_Log_Msg3logE16ACE_Log_PriorityPKcz'
obj\Debug\main.o: In function `Z3foov':
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:14: undefined reference to
`_imp___ZN11ACE_Log_Msg18last_error_adapterEv'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:14: undefined reference to
`_imp___ZN11ACE_Log_Msg8instanceEv'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:14: undefined reference to
`_imp___ZN11ACE_Log_Msg15conditional_setEPKciii'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:14: undefined reference to
`_imp___ZN11ACE_Log_Msg3logE16ACE_Log_PriorityPKcz'
obj\Debug\main.o: In function `main':
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:3: undefined reference to
`_imp___ZN13ACE_Main_BaseD2Ev'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:3: undefined reference to
`_imp___ZN13ACE_Main_BaseC2Ev'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:3: undefined reference to
`_imp___ZN13ACE_Main_BaseD2Ev'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
16 errors, 0 warnings


When I change int main(int argc, char* argv) to int WINAPI
WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
Errors get reduced to 4. Code fails at ACE_DEBUG line.
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:8: undefined reference to
`_imp___ZN11ACE_Log_Msg18last_error_adapterEv'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:8: undefined reference to
`_imp___ZN11ACE_Log_Msg8instanceEv'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:8: undefined reference to
`_imp___ZN11ACE_Log_Msg15conditional_setEPKciii'
C:/Documents and Settings/Sunny/My Documents/CodeBlockProjects/
ACEProject/main.cpp:8: undefined reference to
`_imp___ZN11ACE_Log_Msg3logE16ACE_Log_PriorityPKcz'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
4 errors, 0 warnings



 DESCRIPTION:


 REPEAT BY:


 SAMPLE FIX/WORKAROUND:


More information about the Ace-users mailing list