Segfault in C++ standard library from call of function in external library
Hi, I'm new to Qt, and am using Qt Creator.
I'm using Windows 8.1 and am using the non-Qt MinGW to compile.
I have a program that is currently working perfectly fine as a non-Qt terminal application, built with Cmake. I was planning on using Qt to act as a frontend, with the Qt project itself using sources and headers from the original non-Qt project and using qmake.
I am statically linking the library "xlslib" to use to output .xls files. However, I run into a problem whenever I run the Qt application: a segmentation fault occurs whenever I call the "Dump()" function in xlslib to actually create the .xls file.
Using the debugger, I found that the segfault was occurring in basic_ofstream, at the instruction "lock subl $0x1,(%ebx)" in "libstdc++-6!ZNSt6localeaSERKS".
This does not occur in the non-Qt terminal application and has no issues when "Dump()" is called. Even if I use the Qt Creator Qt Terminal application project template and using the same main() the segfault occurs at the call of the "Dump()" function of "xlslib".
The only compiler flag used was "-std=c++11" for the non-Qt application; for the Qt one "CONFIG += c++11" was added to the .pro.
All the other functions in "xlslib" appear to be working fine.
I was wondering if anything could be done for this segfault, and if it may have to do with some settings in Qt Creator or .pro that I was unaware of.
Hi and welcome to devnet
What compiler is used when your terminal application runs perfectly?
The compiler I'm using is MinGW 3.21 with G++4.8.1
You have installed this compiler separately?
Which version of Qt are you using?
I would recommend trying a compilation the same MinGW compiler as distributed with your Qt version. MinGW is in most cases compatible between versions (in contrast to MSVC), but possibly the different compiler might be the cause of your problem.
With your c++11 settings I would expect a compile error rather than a seg fault. There are a couple of posts relating to using c++11 flag in this forum. Unfortunately the tag flag does not work for this tag. Try to use the find functionality for fitting posts.
I know, I too hate when people propose an alternative instead of answering the actual question but please forgive me this time.
QXlsxWriter is a Qt based library to read and write excel files and I did not have many problems with it so far