Can not create/use DLL
-
@Paul-Colby I need to make DLL for my project build with qmake, but thanks for pointing out
should I add to MyLib.pro lines below?
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/release/ -lmylib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/debug/ -lmylib
else:unix: LIBS += -L$$OUT_PWD/../../../projects/mylib/ -lmylib
INCLUDEPATH += $$PWD/../../../projects/mylib
DEPENDPATH += $$PWD/../../../projects/mylib
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/release/mylib.lib
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/debug/mylib.lib
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/libmylib.a@JacobNovitsky said in Can not create/use DLL:
should I add to MyLib.pro lines below?
No, to userDll.pro as @Paul-Colby wrote
-
@JacobNovitsky said in Can not create/use DLL:
should I add to MyLib.pro lines below?
No, to userDll.pro as @Paul-Colby wrote
@jsulm great, ty
build folder
home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
source files folder
/home/supernova/MyLibI'm I correct:
"If I use Ubuntu, I can somehow ignore win32 lines and keep it as in asample -> rest to be amended EXACTlLY like that".win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/release/ -lmylib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/debug/ -lmylib
else:unix: LIBS += -L$$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lmylib
INCLUDEPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
DEPENDPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/release/mylib.lib
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/debug/mylib.lib
else:unix: PRE_TARGETDEPS += $$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-DebugPlease confirm, big thanks in advance
-
@jsulm great, ty
build folder
home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
source files folder
/home/supernova/MyLibI'm I correct:
"If I use Ubuntu, I can somehow ignore win32 lines and keep it as in asample -> rest to be amended EXACTlLY like that".win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/release/ -lmylib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/debug/ -lmylib
else:unix: LIBS += -L$$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lmylib
INCLUDEPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
DEPENDPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/release/mylib.lib
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/debug/mylib.lib
else:unix: PRE_TARGETDEPS += $$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-DebugPlease confirm, big thanks in advance
@JacobNovitsky If you don't plan to build for Windows then you can remove all the win32 lines, but don't forget to alter other lines (like removing else:).
-
@JacobNovitsky If you don't plan to build for Windows then you can remove all the win32 lines, but don't forget to alter other lines (like removing else:).
@jsulm is this correct?
LIBS += -L$$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lmylib
INCLUDEPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
DEPENDPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
PRE_TARGETDEPS += $$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-DebugNot sure If i need to include project source files, if need please advise where to include
-
@jsulm is this correct?
LIBS += -L$$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lmylib
INCLUDEPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
DEPENDPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
PRE_TARGETDEPS += $$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-DebugNot sure If i need to include project source files, if need please advise where to include
@JacobNovitsky said in Can not create/use DLL:
Not sure If i need to include project source files
If you want to link against a pre build lib then of course you do not have to include the lib sources in the project which links against it.
-
@JacobNovitsky said in Can not create/use DLL:
Not sure If i need to include project source files
If you want to link against a pre build lib then of course you do not have to include the lib sources in the project which links against it.
just delete both projects and created new
pro:
QT -= gui
TEMPLATE = lib
DEFINES += MYLIB_LIBRARYCONFIG += c++17
You can make your code fail to compile if it uses deprecated APIs.
In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
mylib.cppHEADERS +=
MyLib_global.h
mylib.hLIBS += -L$$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lmylibINCLUDEPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
DEPENDPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
PRE_TARGETDEPS += $$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-DebugDefault rules for deployment.
unix {
target.path = /usr/lib
}
!isEmpty(target.path): INSTALLS += targetcompile output:
:-1: error: No rule to make target '/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug', needed by 'libMyLib.so.1.0.0'. Stop.path correct, supernova@supernova-BOHB-WAX9:~/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug$ ls
libMyLib.so libMyLib.so.1.0 Makefile
libMyLib.so.1 libMyLib.so.1.0.0 mylib.oplease assist
-
just delete both projects and created new
pro:
QT -= gui
TEMPLATE = lib
DEFINES += MYLIB_LIBRARYCONFIG += c++17
You can make your code fail to compile if it uses deprecated APIs.
In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
mylib.cppHEADERS +=
MyLib_global.h
mylib.hLIBS += -L$$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lmylibINCLUDEPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
DEPENDPATH += $$PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
PRE_TARGETDEPS += $$OUT_PWD/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-DebugDefault rules for deployment.
unix {
target.path = /usr/lib
}
!isEmpty(target.path): INSTALLS += targetcompile output:
:-1: error: No rule to make target '/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug', needed by 'libMyLib.so.1.0.0'. Stop.path correct, supernova@supernova-BOHB-WAX9:~/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug$ ls
libMyLib.so libMyLib.so.1.0 Makefile
libMyLib.so.1 libMyLib.so.1.0.0 mylib.oplease assist
any ideas how to fix that?
compile output:
:-1: error: No rule to make target '/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug', needed by 'libMyLib.so.1.0.0'. Stop. -
any ideas how to fix that?
compile output:
:-1: error: No rule to make target '/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug', needed by 'libMyLib.so.1.0.0'. Stop.Remove
$$PWDfrom the corresponding lines.Side question: are you going to use that library in any other project ?
-
Remove
$$PWDfrom the corresponding lines.Side question: are you going to use that library in any other project ?
@SGaist not this, but after I learn how to use this, I gonna use it, for sure
-
@SGaist not this, but after I learn how to use this, I gonna use it, for sure
@SGaist side question too :)
where can I read about QMAKE? -
@SGaist side question too :)
where can I read about QMAKE?In the qmake manual
-
In the qmake manual
Libtest.pro
QT = coreCONFIG += c++17 cmdline
You can make your code fail to compile if it uses deprecated APIs.
In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cppDefault rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetLIBS +=/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
INCLUDEPATH +=/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
DEPENDPATH +=/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
PRE_TARGETDEPS +=/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-DebugQT -= gui
TEMPLATE = lib
DEFINES += MYLIB_LIBRARYCONFIG += c++17
You can make your code fail to compile if it uses deprecated APIs.
In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
mylib.cppHEADERS +=
MyLib_global.h
mylib.hDefault rules for deployment.
unix {
target.path = /usr/lib
}
!isEmpty(target.path): INSTALLS += target:-1: error: cannot find /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug: file format not recognized
How to fix error above? There is still no DLL, if I comply with syntax, shall I get dll?
-
Libtest.pro
QT = coreCONFIG += c++17 cmdline
You can make your code fail to compile if it uses deprecated APIs.
In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cppDefault rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetLIBS +=/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
INCLUDEPATH +=/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
DEPENDPATH +=/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug
PRE_TARGETDEPS +=/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-DebugQT -= gui
TEMPLATE = lib
DEFINES += MYLIB_LIBRARYCONFIG += c++17
You can make your code fail to compile if it uses deprecated APIs.
In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
mylib.cppHEADERS +=
MyLib_global.h
mylib.hDefault rules for deployment.
unix {
target.path = /usr/lib
}
!isEmpty(target.path): INSTALLS += target:-1: error: cannot find /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug: file format not recognized
How to fix error above? There is still no DLL, if I comply with syntax, shall I get dll?
@JacobNovitsky You should really read the link @SGaist gave you.
In LIBS you need to also specify the lib you want to link. -
@JacobNovitsky You should really read the link @SGaist gave you.
In LIBS you need to also specify the lib you want to link.@jsulm if I use in the LIBS line something with prefix -lmylib it does not work :)
what should I exactly insert to LIBS line? -
@jsulm if I use in the LIBS line something with prefix -lmylib it does not work :)
what should I exactly insert to LIBS line?changed to
LIBS += -L/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lMyLib INCLUDEPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug DEPENDPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug PRE_TARGETDEPS += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debugit builds, but how to gett .dll file?
-
changed to
LIBS += -L/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lMyLib INCLUDEPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug DEPENDPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug PRE_TARGETDEPS += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debugit builds, but how to gett .dll file?
If I just link header which includes other project headers, it means my program auto include all headers which increase building and execution time?
same going to happen if I use dll, I'm I correct? -
changed to
LIBS += -L/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lMyLib INCLUDEPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug DEPENDPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug PRE_TARGETDEPS += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debugit builds, but how to gett .dll file?
@JacobNovitsky said in Can not create/use DLL:
changed to
LIBS += -L/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lMyLib INCLUDEPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug DEPENDPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug PRE_TARGETDEPS += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debugit builds, but how to gett .dll file?
If after building, you don't have any dll then it means you are not exporting anything from your code.
-
If I just link header which includes other project headers, it means my program auto include all headers which increase building and execution time?
same going to happen if I use dll, I'm I correct?@JacobNovitsky said in Can not create/use DLL:
If I just link header which includes other project headers, it means my program auto include all headers which increase building and execution time?
same going to happen if I use dll, I'm I correct?Build time, yes hence only include what you use in your headers and for the rest use forward declarations. As for execution time, no, it's not directly related.
What do you mean by "if I use dll".
-
@JacobNovitsky said in Can not create/use DLL:
changed to
LIBS += -L/home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug -lMyLib INCLUDEPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug DEPENDPATH += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debug PRE_TARGETDEPS += /home/supernova/build-MyLib-Desktop_Qt_6_2_4_GCC_64bit-Debugit builds, but how to gett .dll file?
If after building, you don't have any dll then it means you are not exporting anything from your code.
@SGaist It feels like I'm close to solve this, what am I missing? What I need to do in order to get dll?
-
@SGaist It feels like I'm close to solve this, what am I missing? What I need to do in order to get dll?
@JacobNovitsky as I wrote: check that you are properly exporting stuff from your library code.