×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Germany
    Posts
    28

    Exclamation File server: Compilation error in carbide.c++

    Hi,

    I'm trying to create a directory/file and write sample data in console mode.

    Here is the code "simple":
    -----------------------------
    // Include Files

    #include "P2PPC_Symbian_81_RF_Console.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h> // Console
    #include <f32file.h> // for file server usage


    // Constants

    _LIT(KTextConsoleTitle, "P2PP-RF");
    _LIT(KTextFailed, " failed, leave code = %d");
    _LIT(KTextPressAnyKey, " [press any key]\n");
    // test data to write
    _LIT8(KDataEntry, "CellID=1234;SignalL=5;\r\n");
    // path for the file
    _LIT(KDataFilePath, "c:\\system\\apps\\P2PPC\\RF.txt");
    _LIT(KNumBytes, "%d bytes\n");


    // Global Variables

    LOCAL_D CConsoleBase* console; // write all messages to this

    // Local Functions

    LOCAL_C void MainL()
    {
    //
    // add your program code here, example code below
    //
    console->Write(_L("Probing...\n"));
    //
    // core engine code/call here
    //
    console->Write(_L("Done.\n"));
    console->Write(_L("Writing to file...\n"));
    // open a session with the file server
    RFs fs;
    // create a sub-session
    User::LeaveIfError(fs.Connect());
    // push the handler in the exception stack
    CleanupClosePushL(fs);
    // parse the complete file path into drive & path
    TParsePtrC parse(KDataFilePath);
    TPtrC pathPtr = parse.DriveAndPath();
    // make all directories specified by KDataFilePath
    User::LeaveIfError(fs.MkDirAll(pathPtr));
    //
    //
    // create a new file object
    RFile file;
    // create a subsession to the file server
    // and open the file specified
    // with Write/WriteStream access
    TInt ret = file.Open(fs, KDataFilePath, EFileWrite | EFileStreamText);
    switch(ret) {
    case KErrNotFound:
    // the file is found. this is the first run, create the file
    User::LeaveIfError(file.Create(fs, KDataFilePath, EFileWrite | EFileStreamText));
    break;
    case KErrNone:
    // Do nothing
    break;
    default:
    // error while creating the file, leave!
    User::Leave(ret);
    break;
    }
    // add the file handler to the exception stack
    CleanupClosePushL(file);
    // offset for the file seek
    TInt offset = 0;
    // seek the file
    User::LeaveIfError(file.Seek(ESeekEnd, offset));
    // write test data
    User::LeaveIfError(file.Write(KDataEntry));
    console->Write(_L("Write done.\n"));
    // get the current file size
    TInt fileSize;
    file.Size(fileSize);
    // clean up the stack
    CleanupStack::PopAndDestroy(2);
    TBuf<20> numBytes;
    // format number to string
    numBytes.Format(KNumBytes, fileSize);
    console->Write(_L("----------\n"));
    console->Write(_L("file size: "));
    console->Write(KNumBytes);
    console->Write(_L("----------\n"));
    }

    LOCAL_C void DoStartL()
    {
    // Create active scheduler (to run active objects)
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    MainL();

    // Delete active scheduler
    CleanupStack::PopAndDestroy(scheduler);
    }


    // Global Functions

    GLDEF_C TInt E32Main()
    {
    // Create cleanup stack
    __UHEAP_MARK;
    CTrapCleanup* cleanup = CTrapCleanup::New();

    // Create output console
    TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
    if (createError)
    return createError;

    // Run application code inside TRAP harness, wait keypress when terminated
    TRAPD(mainError, DoStartL());
    if (mainError)
    console->Printf(KTextFailed, mainError);
    console->Printf(KTextPressAnyKey);
    console->Getch();

    delete console;
    delete cleanup;
    __UHEAP_MARKEND;
    return KErrNone;
    }
    --------------------------------

    When trying to build the project, the following compilation errors appear:

    Undefined symbol: 'classTPtrC16 TParseBase:rive&Path(void) const referenced in MainL.

    NOTE: and other errors for every function I've used from f32file.h (session and file).

    Clearly, there is a problem linking the f32file.h or something like that.
    Any suggestions?

    - Yazan

  2. #2
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    155

    Re: File server: Compilation error in carbide.c++

    Programs don't link to header files, they link to libraries. You're probably not linking to efsrv.lib.
    Last edited by Mr. Buttington; 2007-01-03 at 21:00.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Germany
    Posts
    28

    Re: File server: Compilation error in carbide.c++

    Sorry, forgot to mention that... I'm linking the libs. You can see the MMP file below:

    -------------------------
    TARGET P2PPC_Symbian_81_RF_Console.exe
    TARGETTYPE exe
    UID 0

    USERINCLUDE ..\inc
    SYSTEMINCLUDE \epoc32\include

    SOURCEPATH ..\src
    SOURCE P2PPC_Symbian_81_RF_Console.cpp

    LIBRARY euser.lib
    LIBRARY efsrv.lib
    ----------------------

    The library for file server is efsrv.lib. I mean "problem linking with this lib" :-P

    Thanks,

    - Yazan

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: File server: Compilation error in carbide.c++

    Hi,

    The only thing I can see obviously odd here is that you say the error is:

    Undefined symbol: 'classTPtrC16 TParseBase:rive&Path(void) const referenced in MainL.
    There is no such function, but the one you have called is DriveAndPath. Is this just a typo in your post or have you got some macro redefining "And" to "&"?

    Sorcery

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Germany
    Posts
    28

    Talking Re: File server: Compilation error in carbide.c++

    Hi,

    Yep, this is a typing error. The function is DriveAndPath().

    - Yazan

  6. #6
    Super Contributor
    Join Date
    May 2003
    Location
    Vancouver, Canada
    Posts
    985

    Re: File server: Compilation error in carbide.c++

    Note that the .mmp file is NOT used at all by Carbide.c++. Well, they are just used during importing only.

    If you want to add library from Carbide.c++, you have to do it from the IDE. Right click your project name and then select Properties | C/C++ Build WINSCW Linker Options | Libraries. Add efsrv.lib to the dialog there.

    Antony

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Germany
    Posts
    28

    Smile (Solved) Re: File server: Compilation error in carbide.c++

    100% correct. Problem solved. Thank you ;-)

    - Yazan

Similar Threads

  1. Replies: 3
    Last Post: 2006-05-02, 20:12
  2. Replies: 1
    Last Post: 2005-05-26, 14:22
  3. Replies: 0
    Last Post: 2002-06-10, 12:24
  4. Please help implementing WTLS
    By Nokia_Archived in forum WAP Servers
    Replies: 1
    Last Post: 2002-05-20, 13:27

Posting Permissions

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