Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Global Functions and Variables in shared Library
ranger0 last edited by
I'd like to use some global functions and variables.
At first time, I've done that using a header and .cpp files which was included in all application files.
But now, I'd like to use it as a shared library.
The files are like this:
extern void func1();
extern void func2();
extern QString var1;
extern int var2;
I've seen same instructions at http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application but it seems to work just to classes.
Does any one knows how to do that?
AquilaDev last edited by
just use it like that:
@extern int var = 0;
extern QString aa = "";@
then use it in your cp file like any other var.. but don't re-initialize them, not like what you wrote..
Also... avoid extern and static use in Oriented object languages... classes are here to make everything easier, when you're using global variable you're breaking it. (It's like never use private statement in classes)..