Help : Segmentation fault when using a 3rd library



  • I am a windows user and new to Qt with mingw32. Now I'm trying to use a library 'smile' (which builds up a bayesian network and then do references), I have put everything including .a file and .h file in the root directory and added them in the .pro file (though I don't know whether I have done it right):
    @QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = trysmile
    TEMPLATE = app

    SOURCES += main.cpp
    widget.cpp
    buildnetwork.cpp
    filecommu.cpp
    inference.cpp
    para_learn.cpp
    stru_learn.cpp

    HEADERS += widget.h
    libheader.h

    FORMS += widget.ui

    DEFINES += NDEBUG

    QMAKE_CFLAGS_RELEASE -= -O2
    QMAKE_CFLAGS_RELEASE += -O3
    QMAKE_CFLAGS_RELEASE += -ffast-math
    QMAKE_CXXFLAGS_RELEASE -= -O2
    QMAKE_CXXFLAGS_RELEASE += -O3
    QMAKE_CXXFLAGS_RELEASE += -ffast-math
    QMAKE_CFLAGS_DEBUG -= -O2
    QMAKE_CFLAGS_DEBUG += -O3
    QMAKE_CFLAGS_DEBUG += -ffast-math
    QMAKE_CXXFLAGS_DEBUG -= -O2
    QMAKE_CXXFLAGS_DEBUG += -O3
    QMAKE_CXXFLAGS_DEBUG += -ffast-math

    LIBS += -L$$PWD/ -lsmile
    PRE_TARGETDEPS += $$PWD/libsmile.a
    LIBS += -L$$PWD/ -lsmilearn
    PRE_TARGETDEPS += $$PWD/libsmilearn.a
    INCLUDEPATH += $$PWD/
    DEPENDPATH += $$PWD/
    @
    I included "smile.h" and was trying to run a tutorial program, but I received a signal 'SIGSEGV' when trying to declare a new variable.

    BTW the compiler tells me that there are many unused parameters in my program. Is it normal for a well-included library?



  • One more thing, I saw an instruction on the smile website:

    Distributions built with gcc use the following compiler switches:
    -O3 -DNDEBUG -ffast-math

    Does anyone know how to add these codes?


  • Lifetime Qt Champion

    Hi,

    What exact error are you getting ?

    @DEFINES += NDEBUG@



  • Message I received:

    The inferior stopped becaquse it received a signal from the Operating System.
    Signal name: SIGSEGV
    Signal meaning: Segmentation fault

    I was using a tutorial code, trying to create a new object, but was stopped by Qt Creator.


  • Lifetime Qt Champion

    You should run it using a debugger, this would tell you where it happens



  • Thany you for your reply. I'm new to Qt and I don't know what is a degubber. Now I am using Qt Creator and press F5 to debug my project. The debugging process stops at the line where I am going to declare a new object contained in the library.


  • Lifetime Qt Champion

    Then I suppose you are also new at programming ?

    Can you show the code ?



  • I have some basic knowledge in C++ programming and one semester's course in data structure and algorithm, but I'm ignorant in interface development.

    I downloaded my library on this website:
    http://genie.sis.pitt.edu/index.php/downloads
    followed tutorial on this website:
    http://genie.sis.pitt.edu/wiki/SMILE_Documentation
    and wrote my own code:
    @#include "widget.h"
    #include <QApplication>
    #include "smile.h"

    int main(int argc, char *argv[])
    {
    DSL_network myNetwork;
    QApplication a(argc, argv);
    Widget w;
    w.show();

    return a.exec&#40;&#41;;
    

    }
    @

    Debugging process stopped at
    @DSL_network myNetwork;@


  • Lifetime Qt Champion

    And what error are you getting ?



  • A message box with a title "Signal received", reading

    The inferior stopped because it received a signal from the Operating System.
    Signal name: SIGSEGV
    Signal meaning: Segmentatio fault


  • Lifetime Qt Champion

    Since you are using MinGW, your should already have a debugger then just click on the other green arrow, then one with the little bug, you should get more information



  • Application Output:
    Debugging starts
    can't find linker symbol for virtual table for 'QApplication' value

    There are many warnings. Some read 'ignoring #pragma comment' while others 'unused parameter'. What is the problem?


  • Lifetime Qt Champion

    Did you download the MinGW version ? If so, it's been compiled with MinGW 4.6.2 which is not compatible with 4.8



  • Oh, I am now using Qt creator 5.2.0 and MinGW4.8. How can I reduce MinGW to a 4.6.2 version?


  • Lifetime Qt Champion

    You would need to install it by hand and also recompile Qt with it


  • Lifetime Qt Champion

    However, the download page also mention that you can request a build, so you could try to ask them about a version using MinGW 4.8



  • Thx for your reply! I have downloaded Mingw32 4.6.2, but I want to ask how to recompile Qt with it.


  • Lifetime Qt Champion

    Just follow the "documentation":http://qt-project.org/doc/qt-5/windows-building.html

    However, I would recommend trying to ask a build for MinGW 4.8



  • I've tried to follow the instruction, but it is complex for me. I just copied and pasted MinGW4.6.2 in the directory, and compiled the program. Now it stops at the very beginning and the Application Output window says
    Debugging starts
    (Internal error: pc 0x54f558 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f615 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f616 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f615 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f615 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406a80 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adc in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f615 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f558 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f615 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f616 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f615 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x54f615 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406a80 in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adc in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)
    (Internal error: pc 0x406adb in read in psymtab, but not in symtab.)


  • Lifetime Qt Champion

    Did you also compile Qt with that version of MinGW ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.