Menu

#47 Segmentation fault

closed-works-for-me
None
5
2013-03-12
2012-04-05
Anonymous
No

Hello,
I got segmentation fault for this code:

#include <iostream>
#define PACKAGE_VERSION "2.3.4"

#include "xlslib.h"

using namespace std;
using namespace xlslib_core;

int main (int argc, char * const argv[]) {
workbook wb;
worksheet* sh = wb.sheet("Тексты");
worksheet* sh2 = wb.sheet("Контактная информация");

int err = wb.Dump("testCPP.xls");
return 0;
}

Can you please help me.

Discussion

  • David Hoerl

    David Hoerl - 2012-04-05

    This is documented somewhere. you MUST create at least one cell in each sheet. This is a bug in xlslib, but a very difficult bug to find! I have personally fixed it once several years ago but it keeps popping up!

     
  • Anonymous

    Anonymous - 2012-04-05

    Thanks for reply but this code also throws this fault:

    #include <iostream>
    #define PACKAGE_VERSION "2.3.4"
    #include "xlslib.h"

    using namespace std;
    using namespace xlslib_core;

    int main (int argc, char * const argv[]) {
    workbook wb;
    worksheet* sh = wb.sheet("Sheet 1");
    worksheet* sh2 = wb.sheet("Sheet 2");
    worksheet* sh3 = wb.sheet("Sheet 3");
    // Title
    sh->blank(0, 0);
    sh->label(0,1,"test");

    sh2->blank(0, 0);
    sh2->label(0, 1, "test1");

    sh3->blank(0, 0);
    sh3->label(0, 1, "test2");

    int err = wb.Dump("testCPP.xls");
    return 0;
    }

     
  • David Hoerl

    David Hoerl - 2012-04-05

    Your latest code looks fine. I really don't have any clue what the problem might be. Ah, the joy of open source that needs to run on huge numbers of software platforms.

    All I can say is that hundreds of people are using this library and its quite stable now.

    Did the test programs build? You did run ,/configure right? So, assuming you did:

    ./configure
    make

    did you try
    make check

    did it pass?

    If that crashed, then try to bootstrap config:

    ./bootstrap
    ./configure
    make
    make check

    Is the directory you are trying to dump the file to writeable? You might try: wb.Dump("/tmp/testCPP.xls");

    If all else fails,I believe you are going to need to run this program with a debugger like gdb to find out where and why its crashing.

     
  • Anonymous

    Anonymous - 2012-04-05

    I'm quite newby in this area. Maybe it is my fault. I'll investigate. Thanks!

     
  • Anonymous

    Anonymous - 2012-04-20
    • status: open --> closed
     

    Last edit: Anonymous 2017-10-09
  • David Hoerl

    David Hoerl - 2013-03-12
    • status: closed --> closed-works-for-me
     
  • David Hoerl

    David Hoerl - 2013-03-12
    • assigned_to: nobody --> dhoerl
     

Log in to post a comment.