PDA

View Full Version : Program won't run with library



K4ELO
28th December 2012, 16:37
I have a Qt program that needs to use two C libraries. One of them I can call functions from and it works fine. The other one, when I add a call to a function in that library, the program won't run in the ide. The process stub window comes up with no qDebug output and the application does not run. Both library files are dlls - I am running under Windows. Both libraries look ok in dependency checker.
They are both set up the same way in the pro file.



DEPENDPATH += C:/development/QT_Projects/HRLogger_Dev_Spots/debug/Hamlib
INCLUDEPATH += C:/development/QT_Projects/HRLogger_Dev_Spots/debug/Hamlib
LIBS += -L"C:/development/QT_Projects/HRLogger_Dev_Spots/debug/Hamlib"
LIBS += -llibhamlib


DEPENDPATH += "C:/development/qt_projects/hrlogger_dev_spots/debug/tqsllib/include"
INCLUDEPATH += "C:/development/qt_projects/hrlogger_dev_spots/debug/tqsllib/include"
LIBS += -L"C:/development/QT_Projects/HRLogger_Dev_Spots/debug/tqsllib/lib"
LIBS += -ltqsllib2


Headers for both libraries are included:


extern "C"
{
#include "tqsllib.h"
#include "tqslerrno.h"
#include "tqslconvert.h"
#include "adif.h"
}
extern "C" {
#include "rig.h"
#include "rig_dll.h"
#include "riglist.h"
#include "rigclass.h"
#include "rotator.h"
#include "rotlist.h"
}


libhamlib works fine with my program. tqsllib2 causes it not to run. Makes no difference where in my program I put a call to a function in tqsllib2, even though that code is not executed at startup, my application fails to run. This happens with either the tqsllib I compiled using gcc, or the tqsllib file that is supplied with the windows application that uses the library.

Probably some simple explanation but I can't see it.

wysota
28th December 2012, 16:58
Please define "don't run" and "fail to run". Do you get any errors? Where are the libraries located? Can the main executable see them both?

K4ELO
28th December 2012, 17:48
Wysota - I'm probably not using the correct terms. What I mean is that when I put in a function call to the tqsllib, the main window fails to open when I run the application. The libraries are located in directories below the debug directory (see .pro code in first post)

With no function call, the main window opens and the console looks like this:
8543
With the function call, the main window fails to open and the console looks like this:
8544

Hope the images show up.

wysota
28th December 2012, 18:57
the main window fails to open when I run the application.

You mean the application continues to run but there is no window open?

K4ELO
28th December 2012, 21:03
The window does not open and the Application Output says the program exited with code 0.

amleto
28th December 2012, 21:38
Wysota - I'm probably not using the correct terms. What I mean is that when I put in a function call to the tqsllib, the main window fails to open when I run the application. The libraries are located in directories below the debug directory (see .pro code in first post)

is that the same location as the debug app exe? Since the libs are in different places, how can the app see the dlls at run time?

wysota
28th December 2012, 21:58
The window does not open and the Application Output says the program exited with code 0.

If you modify your main() function so that at the beginning it prints some text and before returning it prints some more text, do you get the textual output? If not then your program was never running and the problem is not that a window fails to open but rather that your program fails to run (probably because of missing libraries). I don't know what you checked in the dependency checker and how you checked it but apparently your check was invalid. Try running your program by double-clicking its icon and see if you get any useful response from Windows (e.g. about the program failing to start because of missing libraries).

K4ELO
28th December 2012, 23:37
no text output Wysota. Tried double clicking the exe and I get the same response, no output. When I run the dependency checker on my exe, both libraries show up, however, in the hamlib, it lists all of the library functions, but in tqsllib, it only lists one, tqsl_init(), but there should be many. Maybe this library file is corrupt?

wysota
28th December 2012, 23:56
I get the same response
I'm not a trueseer. I don't know what "the same response" is.

Maybe this library file is corrupt?
No idea. Left my crystal ball in the other pants.

In general, if there is something wrong with starting the program from file explorer, Windows should pop up a dialog stating what the problem is (more or less). If it doesn't display anything then there is a chance your program executes but we have no way of knowing that as you didn't provide any useful source code to look at.