×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    19

    minimal console application with GCCE

    Hi all,

    I'm having trouble building a minimalistic test case composed only by an empty function main():

    Code:
    // main.cpp
    int main(int argc, char* argv[])
    {
      return 0;
    }
    The WINSCW target compiles and links correctly (I've included ecrt0.lib to the mmp file), while the GCCE target fails to link:

    ..\..\..\9.1\S60_3rd_MR_2\EPOC32\RELEASE\ARMV5\UREL\usrt2_2.lib(callfirstprocessfn.o): In function `$p': symaehabi\Callfirstprocessfn.cpp.text+0x48): undefined reference to `E32Main()'
    arm-none-symbianelf-ld: ..\..\..\9.1\S60_3rd_MR_2\EPOC32\BUILD\Symbian\Librerie\STLport-5.1.0\_temp\PROVA\GCCE\UREL\prova.exe: hidden symbol `_Z7E32Mainv' isn't defined
    arm-none-symbianelf-ld: final link failed: Nonrepresentable section on output

    I thought ecrt0.lib was supposed to provide E32Main(), but this doesn't seem to happen when GCCE target is selected. What am I missing?

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    200

    Re: minimal console application with GCCE

    Quote Originally Posted by polo78
    The WINSCW target compiles and links correctly (I've included ecrt0.lib to the mmp file), while the GCCE target fails to link:

    ..\..\..\9.1\S60_3rd_MR_2\EPOC32\RELEASE\ARMV5\UREL\usrt2_2.lib(callfirstprocessfn.o): In function `$p': symaehabi\Callfirstprocessfn.cpp.text+0x48): undefined reference to `E32Main()'
    arm-none-symbianelf-ld: ..\..\..\9.1\S60_3rd_MR_2\EPOC32\BUILD\Symbian\Librerie\STLport-5.1.0\_temp\PROVA\GCCE\UREL\prova.exe: hidden symbol `_Z7E32Mainv' isn't defined
    arm-none-symbianelf-ld: final link failed: Nonrepresentable section on output

    I thought ecrt0.lib was supposed to provide E32Main(), but this doesn't seem to happen when GCCE target is selected. What am I missing?
    I can get past this point by adding

    Code:
    STATICLIBRARY usrt2_2.lib
    before the ECRT0.LIB line in the mmp (because of ld library ordering rules...), but then I get another undefined symbol error for "exit", which makes it similar to the problem described here:

    http://discussion.forum.nokia.com/fo...ad.php?t=87081

    This one seems to have a different cause, though...

    So it seems to be that right now ECRT0 support for main()-style executables, such as tests, may be broken for the GCCE toolchain.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: minimal console application with GCCE

    You have not implemented E32Main, the mandatory entry point for all Symbian .exe-s. Forget standard C++, you should rather try something like this:
    Code:
    #include <e32base.h>
    #include <e32cons.h>
    
    LOCAL_C void MainL(void);
    
    GLDEF_C TInt E32Main()
    {
        CTrapCleanup* cleanup=CTrapCleanup::New();
        TRAPD(error,MainL());
        delete cleanup;
        return 0;
    }
    
    _LIT(KHello,"Hello");
    LOCAL_C void MainL(void)
    {
        CConsoleBase *console=Console::NewL(KHello,TSize(KConsFullScreen,KConsFullScreen));
        CleanupStack::PushL(console);
        console->Printf(KHello);
        console->Getch();
        CleanupStack::PopAndDestroy();
    }

  4. #4
    Registered User
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    200

    Re: minimal console application with GCCE

    Quote Originally Posted by wizard_hu_
    You have not implemented E32Main, the mandatory entry point for all Symbian .exe-s. Forget standard C++, you should rather try something like this:
    Thanks - doing it this way indeed works. The problem is that the behaviour for main()-style code has changed from 2nd to 3rd Edition. In theory, linking the static library ECRT0 should provide an entry point... the SDK documentation writes in Porting Guide about a sample project:

    The project also links to ecrt0.lib. This file provides the E32Main() entrypoint for a .exe. It also provides other services including command-line parsing, and it calls main().
    This used to work fine in 2nd Edition, but stopped working in 3rd.

    Possibly related to this, I cannot seem to use printf() and friends any more in 3rd Edition. In 2nd Edition, this used to open an automatically maintained console, so that complex console apps with screen output (unit tests) could be ported in a very straightforward way.

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    1

    Re: minimal console application with GCCE

    Hi,
    Try linking with libcrt0 instead of ucrt0
    good luck!

  6. #6
    Registered User
    Join Date
    Aug 2007
    Posts
    5

    Re: minimal console application with GCCE

    the "exit" symbol is defined in estlib.lib, which is present in the SDK but
    for some strange reason the linker cannot find it.

    in the stdlib/hello example the .mmp contains this

    library estlib.lib euser.lib
    staticlibrary ecrt0.lib

    and of course the build fails with "undefined reference to `exit'".
    How can Nokia ship SDKs which are not tested?

    Nokia guys, PLEASE post a suggested fix for this and make sure that
    you fix this bug and includes it in the next SDK release. Thank you.

  7. #7
    Registered User
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    200

    Re: minimal console application with GCCE

    Quote Originally Posted by alfredh View Post
    the "exit" symbol is defined in estlib.lib, which is present in the SDK but
    for some strange reason the linker cannot find it.
    Much later...

    It seems that this is resolved in the 3rd Ed FP2 version of ecrt0, so if anyone ever comes across this thread again, and needs to build with an older SDK, it may be worth checking whether including the new version of ecrt0 already fixes things. It seems to do for me.

    Of course, this applies only if you aren't using Open C anyway.

    ciao marcus

Similar Threads

  1. console application to handle incoming query
    By cypher181 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-07-08, 07:58
  2. Replies: 4
    Last Post: 2006-06-21, 16:33
  3. Replies: 0
    Last Post: 2005-05-28, 10:20
  4. console application
    By jack44 in forum Symbian
    Replies: 1
    Last Post: 2003-02-17, 14:06
  5. Replies: 0
    Last Post: 2003-02-03, 08:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×