How to compile a so file in order to load it as a library.
-
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
But no so file was created.
So, then the compiler/linker failed, right? What about posting errors? Or did you only rerun "g++ -fPIC -shared -o mylib.so mylib.o
" - you of course have to rebuild mylib.oNo failure. It compiled OK but no so file was created.
@jenya7 said in How to compile a so file in order to load it as a library.:
It compiled OK but no so file was created
Then it did NOT compiled OK!
Did you rebuild mylib.o as I wrote? -
@jenya7 said in How to compile a so file in order to load it as a library.:
It compiled OK but no so file was created
Then it did NOT compiled OK!
Did you rebuild mylib.o as I wrote?@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
It compiled OK but no so file was created
Then it did NOT compiled OK!
Did you rebuild mylib.o as I wrote?OK. To make sure I delete the object file, compile (rebuild with Q_DECL_EXPORT option).
Then I do again
g++ -fPIC -shared -o mylib.so mylib.o
And see a new so file. However the same problem exists - mylib.so: undefined symbol: _ZTI9QRunnable -
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
It compiled OK but no so file was created
Then it did NOT compiled OK!
Did you rebuild mylib.o as I wrote?OK. To make sure I delete the object file, compile (rebuild with Q_DECL_EXPORT option).
Then I do again
g++ -fPIC -shared -o mylib.so mylib.o
And see a new so file. However the same problem exists - mylib.so: undefined symbol: _ZTI9QRunnable@jenya7 said in How to compile a so file in order to load it as a library.:
QRunnable
QRunnable is part of QtCore Qt module, so your lib needs to link against QtCore.
-
@jenya7 said in How to compile a so file in order to load it as a library.:
QRunnable
QRunnable is part of QtCore Qt module, so your lib needs to link against QtCore.
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
QRunnable
QRunnable is part of QtCore Qt module, so your lib needs to link against QtCore.
That is my question - how to compile recursively to include all related objects?
-
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
QRunnable
QRunnable is part of QtCore Qt module, so your lib needs to link against QtCore.
That is my question - how to compile recursively to include all related objects?
@jenya7 said in How to compile a so file in order to load it as a library.:
how to compile recursively to include all related objects?
You do not compile recursevly, you link against libraries you depend on. Something like:
g++ -fPIC -shared -o mylib.so mylib.o -LPATH_TO_QT_LIB_FOLDER -lqtcore
-
@jenya7 said in How to compile a so file in order to load it as a library.:
how to compile recursively to include all related objects?
You do not compile recursevly, you link against libraries you depend on. Something like:
g++ -fPIC -shared -o mylib.so mylib.o -LPATH_TO_QT_LIB_FOLDER -lqtcore
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
how to compile recursively to include all related objects?
You do not compile recursevly, you link against libraries you depend on. Something like:
g++ -fPIC -shared -o mylib.so mylib.o -LPATH_TO_QT_LIB_FOLDER -lqtcore
Too much to include I have in the source file
#include <QObject>
#include <QTime>
#include <QtConcurrent/QtConcurrent>
#include <QThread>
#include <QElapsedTimer>
#include <QApplication>It in its turn has its own dependencies. Is it doable at all?
-
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
how to compile recursively to include all related objects?
You do not compile recursevly, you link against libraries you depend on. Something like:
g++ -fPIC -shared -o mylib.so mylib.o -LPATH_TO_QT_LIB_FOLDER -lqtcore
Too much to include I have in the source file
#include <QObject>
#include <QTime>
#include <QtConcurrent/QtConcurrent>
#include <QThread>
#include <QElapsedTimer>
#include <QApplication>It in its turn has its own dependencies. Is it doable at all?
@jenya7 said in How to compile a so file in order to load it as a library.:
Is it doable at all?
What is doable?
As I wrote: if you use a library then you have to link against that library... -
@jenya7 said in How to compile a so file in order to load it as a library.:
Is it doable at all?
What is doable?
As I wrote: if you use a library then you have to link against that library...@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
Is it doable at all?
What is doable?
As I wrote: if you use a library then you have to link against that library...I see. Where is LPATH_TO_QT_LIB_FOLDER located on Linux?
I can no t find -lqtcore library. -
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
Is it doable at all?
What is doable?
As I wrote: if you use a library then you have to link against that library...I see. Where is LPATH_TO_QT_LIB_FOLDER located on Linux?
I can no t find -lqtcore library.@jenya7 said in How to compile a so file in order to load it as a library.:
PATH_TO_QT_LIB_FOLDER
This was apparently just a placeholder for the real path. It needs to be the folder where libqtcore.so file is located.
See https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html for example. -
@jenya7 said in How to compile a so file in order to load it as a library.:
PATH_TO_QT_LIB_FOLDER
This was apparently just a placeholder for the real path. It needs to be the folder where libqtcore.so file is located.
See https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html for example.@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
PATH_TO_QT_LIB_FOLDER
This was apparently just a placeholder for the real path. It needs to be the folder where libqtcore.so file is located.
See https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html for example.I did a search in all folders
find / libqtcore.so
no such file reported.
What I've managed to find is
/usr/lib/arm-linux-gnueabihf/libQt5Core.so.5
and it's a shortcut file which I can not open. -
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
PATH_TO_QT_LIB_FOLDER
This was apparently just a placeholder for the real path. It needs to be the folder where libqtcore.so file is located.
See https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html for example.I did a search in all folders
find / libqtcore.so
no such file reported.
What I've managed to find is
/usr/lib/arm-linux-gnueabihf/libQt5Core.so.5
and it's a shortcut file which I can not open.@jenya7 said in How to compile a so file in order to load it as a library.:
and it's a shortcut file which I can not open
Why do you want to open it?
Did you try:g++ -fPIC -shared -o mylib.so mylib.o -L/usr/lib/arm-linux-gnueabihf -lQt5Core
?
Are you on ARM platform or are you doing cross compilation? -
@jenya7 said in How to compile a so file in order to load it as a library.:
and it's a shortcut file which I can not open
Why do you want to open it?
Did you try:g++ -fPIC -shared -o mylib.so mylib.o -L/usr/lib/arm-linux-gnueabihf -lQt5Core
?
Are you on ARM platform or are you doing cross compilation?@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
and it's a shortcut file which I can not open
Why do you want to open it?
Did you try:g++ -fPIC -shared -o mylib.so mylib.o -L/usr/lib/arm-linux-gnueabihf -lQt5Core
?
Are you on ARM platform or are you doing cross compilation?It's Raspberry Pi - Debian. Qt installed on board and I build directly on board.
-
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 said in How to compile a so file in order to load it as a library.:
and it's a shortcut file which I can not open
Why do you want to open it?
Did you try:g++ -fPIC -shared -o mylib.so mylib.o -L/usr/lib/arm-linux-gnueabihf -lQt5Core
?
Are you on ARM platform or are you doing cross compilation?It's Raspberry Pi - Debian. Qt installed on board and I build directly on board.
-
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 Then -lQt5Core should be enough, no need for -L
Thank you.
g++ -fPIC -shared -o mylib.so mylib.o -L/usr/lib/arm-linux-gnueabihf -lQt5Core
It works. Now it's quit a nightmare - it's like a chain reaction - demands more and more dependencies. I include each time, hope it'll come till the end eventually. My command line string takes the full screen already. -
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 Then -lQt5Core should be enough, no need for -L
Thank you.
g++ -fPIC -shared -o mylib.so mylib.o -L/usr/lib/arm-linux-gnueabihf -lQt5Core
It works. Now it's quit a nightmare - it's like a chain reaction - demands more and more dependencies. I include each time, hope it'll come till the end eventually. My command line string takes the full screen already. -
@jenya7 You should use a proper build system like QMake or CMake instead of hacking around with all these manually...
-
@jsulm
One dependence I can't resolve - undefined symbol: _ZN7QAction16staticMetaObjectE
Where could it be - QAction - is it a separate library?@jenya7 If you go to https://doc.qt.io/qt-6/qaction.html you will see what Qt module it is (hint: qmake: QT += gui)
-
@jenya7 If you go to https://doc.qt.io/qt-6/qaction.html you will see what Qt module it is (hint: qmake: QT += gui)
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 If you go to https://doc.qt.io/qt-6/qaction.html you will see what Qt module it is (hint: qmake: QT += gui)
sorry to bother but I included
-L/usr/lib/arm-linux-gnueabihf/ -lQt5Gui
and QAction is good now but I get
undefined symbol: _ZN12QActionGroup16staticMetaObjectE
but I see QAction and QActionGroup in the same library (QT += gui)
Do I miss some lib? -
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 If you go to https://doc.qt.io/qt-6/qaction.html you will see what Qt module it is (hint: qmake: QT += gui)
sorry to bother but I included
-L/usr/lib/arm-linux-gnueabihf/ -lQt5Gui
and QAction is good now but I get
undefined symbol: _ZN12QActionGroup16staticMetaObjectE
but I see QAction and QActionGroup in the same library (QT += gui)
Do I miss some lib?@jenya7
Same as before --- you need to look at the doc page! You are now getting an error aboutQActionGroup
instead ofQAction
. So you need to look at theQActionGroup
page for what it tells you you will need to add, just like before. And note that you are using Qt5 so you will need to be careful to look at that documentation, https://doc.qt.io/qt-5/qactiongroup.html, because at Qt6 (the default now when you search online)QActionGroup
actually changed module!but I see QAction and QActionGroup in the same library (QT += gui)
Yes in Qt6, not in Qt5!
-
@jsulm said in How to compile a so file in order to load it as a library.:
@jenya7 If you go to https://doc.qt.io/qt-6/qaction.html you will see what Qt module it is (hint: qmake: QT += gui)
sorry to bother but I included
-L/usr/lib/arm-linux-gnueabihf/ -lQt5Gui
and QAction is good now but I get
undefined symbol: _ZN12QActionGroup16staticMetaObjectE
but I see QAction and QActionGroup in the same library (QT += gui)
Do I miss some lib?@jenya7 said in How to compile a so file in order to load it as a library.:
but I see QAction and QActionGroup
This is wrong, please look again...