PDA

View Full Version : (SOLVED) Different compile sequence in Windows and Linux



rittchat
27th June 2014, 07:38
This is more of a reporting than a question! Hope somebody will find it useful.

I have a project which produces a executable say pro (in Linux or pro.exe in Windows). This executable, when run, searches for its plugins in a predefined folder. Suppose that in that folder there is plugin say plu.so (in Linux or plu.dll in Windows). This plugin again linked with sqlite3.so (in Linux or sqlite3.dll in Windows). The plugin and the program have different pro files and compiler one after the other using a 3rd pro files which has


SUBDIRS = pro plu

The plugin source code is divided in to two classes A (a.h and a.cpp) and B (b.h and b.cpp). class B wraps sqlite3 library to provide class A some sqlite3 functions in C++ way. So a.h starts with


#include "b.h"

What happens is that for windows I have to set the sequence of cpp files in pro file of the plugin like


SOURCES += a.cpp b.cpp

Whereas in Linux the sequence is


SOURCES += b.cpp a.cpp

So, my QMake files has


win32:SOURCES += a.cpp b.cpp
unix:SOURCES += b.cpp a.cpp

The problem is if I change the sequence in a platform to the sequence of the other platform - the plugin as well as the program crash!!!

Can anyone tell me why this is happening? My code is large so I can't post everything here, sorry for that.

By the way - I am using Windows 7 32bit and Fedora LXDE 64bit both have Qt 5.2 installed.

anda_skoa
27th June 2014, 09:14
There is definitely something very wrong when the order of compilation matters.

Do you get anything from the stack trace when it crashes?

Cheers,
_

rittchat
27th June 2014, 09:23
Please tell me how to get the stack trace.

_________

@anda_skoa

You are absolutely right. In class B's ctor I was clearing a global vector! So stupid of me! Thanks a million for pointing me on stack trace. I have fixed my problem.

Infinity
28th June 2014, 01:41
If you're using Qt Creator simply use its debugging feature: http://qt-project.org/doc/qtcreator-3.0/creator-debugging.html

But if the "compile sequence" matters you're definitely something wrong, eg. the "static initialization order fiasco": http://www.parashift.com/c++-faq/static-init-order-on-first-use.html