undefined reference - Help first time external header library QT C++ [Linux]
-
@JonB said in undefined reference - Help first time external header library QT C++ [Linux]:
@LudoFR
Does it help if you write it as::DapiOpenModuleEx(...)?
As @SGaist says below. I didn't notice it was a linker error.@SGaist said in undefined reference - Help first time external header library QT C++ [Linux]:
Hi,
Aren't you forgetting to link to the library that provided these symbols ?
damn yea right..
I have the added full library folder into my project folder like this :

Now my *.pro file :
QT += quick SOURCES += \ main.cpp resources.files = main.qml resources.prefix = /$${TARGET} RESOURCES += resources # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target & unix:!macx: LIBS += -L$$PWD/delib/lib/build_x64/ -lDelibTcp INCLUDEPATH += $$PWD/delib DEPENDPATH += $$PWD/deliband my compile ouput window :
08:54:36: Running steps for project DeditecQuickCpp... 08:54:36: Configuration unchanged, skipping qmake step. 08:54:36: Starting: "/usr/bin/make" -j20 g++ -c -pipe -g -Wall -Wextra -fPIC -D_REENTRANT -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QMLINTEGRATION_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../DeditecQuickCpp -I. -I../DeditecQuickCpp/delib -I../../../../Qt/6.4.2/gcc_64/include -I../../../../Qt/6.4.2/gcc_64/include/QtQuick -I../../../../Qt/6.4.2/gcc_64/include/QtOpenGL -I../../../../Qt/6.4.2/gcc_64/include/QtGui -I../../../../Qt/6.4.2/gcc_64/include/QtQmlModels -I../../../../Qt/6.4.2/gcc_64/include/QtQml -I../../../../Qt/6.4.2/gcc_64/include/QtQmlIntegration -I../../../../Qt/6.4.2/gcc_64/include/QtNetwork -I../../../../Qt/6.4.2/gcc_64/include/QtCore -I. -I../../../../Qt/6.4.2/gcc_64/mkspecs/linux-g++ -o main.o ../DeditecQuickCpp/main.cpp In file included from ../DeditecQuickCpp/main.cpp:5: ../DeditecQuickCpp/delib/library/delib/delib.h:347:53: note: ‘#pragma message: DELIB.H Mode for C++ used’ 347 | #pragma message ("DELIB.H Mode for C++ used") | ^ g++ -Wl,-rpath,/home/ludo/Qt/6.4.2/gcc_64/lib -Wl,-rpath-link,/home/ludo/Qt/6.4.2/gcc_64/lib -o DeditecQuickCpp main.o qrc_qmake_resources.o -L/home/ludo/Documents/Dev_C/QT/DeditecQuickCpp/delib/lib/build_x64/ -lDelibTcp /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Quick.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6OpenGL.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Gui.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6QmlModels.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Qml.so -pthread /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Network.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Core.so -lpthread -lGL /usr/bin/ld: main.o: in function `main': /home/ludo/Documents/Dev_C/QT/build-DeditecQuickCpp-Desktop_Qt_6_4_2_GCC_64bit-Debug/../DeditecQuickCpp/main.cpp:23: undefined reference to `DapiOpenModuleEx' collect2: error: ld returned 1 exit status make: *** [Makefile:211: DeditecQuickCpp] Error 1 08:54:37: The process "/usr/bin/make" exited with code 2. Error while building/deploying project DeditecQuickCpp (kit: Desktop Qt 6.4.2 GCC 64bit) When executing step "Make" 08:54:37: Elapsed time: 00:01. -
@LudoFR
What files are in/home/ludo/Documents/Dev_C/QT/DeditecQuickCpp/delib/lib/build_x64/? How were the libraries there built, and who built them?Here the script for compiling the *.so library :
#!/bin/bash flags="-Wall -Werror" lib_name=./build_x64/libDelibTcp list_of_source_files=" blowfish.c deditec_encryption_utils.c delib_io_tcp_encryption.c -g" list_of_object_files=" blowfish.o deditec_encryption_utils.o delib_io_tcp_encryption.o -g" echo now compiling $lib_name gcc -c $flags -fpic $list_of_source_files if [ $? != "0" ] then echo echo "error(s) found while compiling" exit 100 else echo gcc -shared -o $lib_name.so $list_of_object_files rm *.o echo "lib created" fiFollowing the documentation
Here the files used for compilation.

Sorry I'm kind of beginner with Linux and C++ globally (too much time on windows and C# sadly for me)
-
Here the script for compiling the *.so library :
#!/bin/bash flags="-Wall -Werror" lib_name=./build_x64/libDelibTcp list_of_source_files=" blowfish.c deditec_encryption_utils.c delib_io_tcp_encryption.c -g" list_of_object_files=" blowfish.o deditec_encryption_utils.o delib_io_tcp_encryption.o -g" echo now compiling $lib_name gcc -c $flags -fpic $list_of_source_files if [ $? != "0" ] then echo echo "error(s) found while compiling" exit 100 else echo gcc -shared -o $lib_name.so $list_of_object_files rm *.o echo "lib created" fiFollowing the documentation
Here the files used for compilation.

Sorry I'm kind of beginner with Linux and C++ globally (too much time on windows and C# sadly for me)
-
@LudoFR
These are the files in thelibdirectory. I asked to see the files in thelib/build_x64subdirectory. -
-
@LudoFR
Umm, if there are no files in that folder then there is no library to link against....!Did you actually run the script to build the library?
lib_name=./build_x64/libDelibTcpI am expecting to see that created at least
build_x64/libDelibTcp.so.Yes I run the script :
0_make_tcp_encryption_lib_x64.shSorry my fault, there is no files except the libDelibTcp.so

Compilation output from QT look different, (I do not have change anything)
09:47:57: Running steps for project DeditecQuickCpp... 09:47:57: Configuration unchanged, skipping qmake step. 09:47:57: Starting: "/usr/bin/make" -j20 g++ -Wl,-rpath,/home/ludo/Qt/6.4.2/gcc_64/lib -Wl,-rpath-link,/home/ludo/Qt/6.4.2/gcc_64/lib -o DeditecQuickCpp main.o qrc_qmake_resources.o -L/home/ludo/Documents/Dev_C/QT/DeditecQuickCpp/delib/lib/build_x64/ -lDelibTcp /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Quick.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6OpenGL.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Gui.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6QmlModels.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Qml.so -pthread /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Network.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Core.so -lpthread -lGL /usr/bin/ld: main.o: in function `main': /home/ludo/Documents/Dev_C/QT/build-DeditecQuickCpp-Desktop_Qt_6_4_2_GCC_64bit-Debug/../DeditecQuickCpp/main.cpp:23: undefined reference to `DapiOpenModuleEx' collect2: error: ld returned 1 exit status make: *** [Makefile:211: DeditecQuickCpp] Error 1 09:47:57: The process "/usr/bin/make" exited with code 2. Error while building/deploying project DeditecQuickCpp (kit: Desktop Qt 6.4.2 GCC 64bit) When executing step "Make" 09:47:57: Elapsed time: 00:00. -
Yes I run the script :
0_make_tcp_encryption_lib_x64.shSorry my fault, there is no files except the libDelibTcp.so

Compilation output from QT look different, (I do not have change anything)
09:47:57: Running steps for project DeditecQuickCpp... 09:47:57: Configuration unchanged, skipping qmake step. 09:47:57: Starting: "/usr/bin/make" -j20 g++ -Wl,-rpath,/home/ludo/Qt/6.4.2/gcc_64/lib -Wl,-rpath-link,/home/ludo/Qt/6.4.2/gcc_64/lib -o DeditecQuickCpp main.o qrc_qmake_resources.o -L/home/ludo/Documents/Dev_C/QT/DeditecQuickCpp/delib/lib/build_x64/ -lDelibTcp /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Quick.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6OpenGL.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Gui.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6QmlModels.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Qml.so -pthread /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Network.so /home/ludo/Qt/6.4.2/gcc_64/lib/libQt6Core.so -lpthread -lGL /usr/bin/ld: main.o: in function `main': /home/ludo/Documents/Dev_C/QT/build-DeditecQuickCpp-Desktop_Qt_6_4_2_GCC_64bit-Debug/../DeditecQuickCpp/main.cpp:23: undefined reference to `DapiOpenModuleEx' collect2: error: ld returned 1 exit status make: *** [Makefile:211: DeditecQuickCpp] Error 1 09:47:57: The process "/usr/bin/make" exited with code 2. Error while building/deploying project DeditecQuickCpp (kit: Desktop Qt 6.4.2 GCC 64bit) When executing step "Make" 09:47:57: Elapsed time: 00:00.@LudoFR
Because I am a very nice guy [ ;-) ] I downloaded your "deditec" library stuff for Linux and set up a tiny project to use it. I get the same "undefined" on anyDapi...call as you do.So then I went ran on
lib/build_x64/libDelibTcp.so(I just used the one already compiled there)nm --dynamic libDelibTcp.soThis shows me all the symbols defined/exported in
libDelibTcp.so. And there is nothing even vaguely likeDapi...anything there. Just someBlowfish...anddt_...functions.So.... I don't know what you are supposed to be using (I'm not going to read the whole Delib documenation). But I can only conclude that including the
delib.hstuff which declaresDapi...functions requires something very different from (at least the currently built)libDelibTcp.socontent to link against....The script name indicates to me that it is just for some encryption routines (
0_make_tcp_encryption_lib_x64.sh). I think there is quite some other library you are supposed to be linking against for anythingDapi...??In the
delibdirectory I see all thedelib_Dapi_...source files. I suspect that is what needs building? I see yourDapiOpenModuleEximplementation is defined in filedelib_open_close.cpp.Maybe go look in the supplied
samplesdirectory? There I see e.g.1_compile_usb_sample.sh. Looking in that I see agcccommand which explicitly compiles and links a whole bunch of the source files, including a couple ofdelib_Dapi...ones. Does this indicate how you are supposed to do it? So no library for those source files, rather you are supposed to compile them to.ofiles and link them against your code? Same for the "ethernet" sample, which includes areadme.txt, clarifying thatlibDelibTcp.sois only to do with encryption.... -
@LudoFR
Because I am a very nice guy [ ;-) ] I downloaded your "deditec" library stuff for Linux and set up a tiny project to use it. I get the same "undefined" on anyDapi...call as you do.So then I went ran on
lib/build_x64/libDelibTcp.so(I just used the one already compiled there)nm --dynamic libDelibTcp.soThis shows me all the symbols defined/exported in
libDelibTcp.so. And there is nothing even vaguely likeDapi...anything there. Just someBlowfish...anddt_...functions.So.... I don't know what you are supposed to be using (I'm not going to read the whole Delib documenation). But I can only conclude that including the
delib.hstuff which declaresDapi...functions requires something very different from (at least the currently built)libDelibTcp.socontent to link against....The script name indicates to me that it is just for some encryption routines (
0_make_tcp_encryption_lib_x64.sh). I think there is quite some other library you are supposed to be linking against for anythingDapi...??In the
delibdirectory I see all thedelib_Dapi_...source files. I suspect that is what needs building? I see yourDapiOpenModuleEximplementation is defined in filedelib_open_close.cpp.Maybe go look in the supplied
samplesdirectory? There I see e.g.1_compile_usb_sample.sh. Looking in that I see agcccommand which explicitly compiles and links a whole bunch of the source files, including a couple ofdelib_Dapi...ones. Does this indicate how you are supposed to do it? So no library for those source files, rather you are supposed to compile them to.ofiles and link them against your code? Same for the "ethernet" sample, which includes areadme.txt, clarifying thatlibDelibTcp.sois only to do with encryption....@JonB Wow, really I want to thank you for your effort, this mean a lot seriously.
To be honest, this is why I think for the start because this lib is totally different from the one I use in C#.
So if I understand good I need to compile all files listed here :
#!/bin/bash bin_name=ethernet_sample preprocessor_defines="-D USE_ETH" list_of_files=" source/ethernet_sample.c ../../delib-sources/delib/library/vc/deditec_timer.c ../../delib-sources/delib/library/vc/deditec_tcp_io.c ../../delib-sources/delib/library/vc/deditec_buff_utils.c ../../delib-sources/delib/library/vc/deditec_string_utils.c ../../delib-sources/delib/library/vc/deditec_convert_functions.c ../../delib-sources/delib/library/embedded/deditec_debug_comfort.c ../../delib-sources/delib/delib_hdlmgr.c ../../delib-sources/delib/delib_packet_statistic.c ../../delib-sources/delib/delib_Dapi_di_do_ad_da_befehle.c ../../delib-sources/delib/delib_set_get_error.c ../../delib-sources/delib/delib_Dapi_register_commands.c ../../delib-sources/delib/delib_open_close.c ../../delib-sources/delib/delib_io_tcp.c -g" echo now compiling $bin_name gcc $preprocessor_defines -o $bin_name $list_of_files if [ $? != "0" ] then echo echo "error(s) found while compiling" exit 100 else echo echo "compiling successfull" fiInto a *.o lib?
-
@JonB Wow, really I want to thank you for your effort, this mean a lot seriously.
To be honest, this is why I think for the start because this lib is totally different from the one I use in C#.
So if I understand good I need to compile all files listed here :
#!/bin/bash bin_name=ethernet_sample preprocessor_defines="-D USE_ETH" list_of_files=" source/ethernet_sample.c ../../delib-sources/delib/library/vc/deditec_timer.c ../../delib-sources/delib/library/vc/deditec_tcp_io.c ../../delib-sources/delib/library/vc/deditec_buff_utils.c ../../delib-sources/delib/library/vc/deditec_string_utils.c ../../delib-sources/delib/library/vc/deditec_convert_functions.c ../../delib-sources/delib/library/embedded/deditec_debug_comfort.c ../../delib-sources/delib/delib_hdlmgr.c ../../delib-sources/delib/delib_packet_statistic.c ../../delib-sources/delib/delib_Dapi_di_do_ad_da_befehle.c ../../delib-sources/delib/delib_set_get_error.c ../../delib-sources/delib/delib_Dapi_register_commands.c ../../delib-sources/delib/delib_open_close.c ../../delib-sources/delib/delib_io_tcp.c -g" echo now compiling $bin_name gcc $preprocessor_defines -o $bin_name $list_of_files if [ $? != "0" ] then echo echo "error(s) found while compiling" exit 100 else echo echo "compiling successfull" fiInto a *.o lib?
@LudoFR said in undefined reference - Help first time external header library QT C++ [Linux]:
Wow, really I want to thank you for your effort, this mean a lot seriously.
That's good, because I'm expecting a beer ;-)
Into a *.o lib?
No. Compiling each of those files separately will produce a
.ofile for each of the.csource files. This example does not show any library (.so, or for that matter.a) being generated from them. I presume that is how it is intended to work, author does not want you to create a single library but rather compile them all and link all the.ofiles.Assuming this is so, then I believe you will have to add all whatever necessary
.cfiles (may not be all the ones in this example, might be others, I don't know) into your Qt project as source files, in addition to your own source file(s). Then when you build the project all the.ofiles will be created separately, and all must be included in the link line.I'm afraid it's over to you to do whatever to get all those source files correctly added into the project in Creator/the
.profile. You will have to be careful the paths are right and their header (.h) files are found correctly.P.S.
At this point have you considered dropping this third-party Borland stuff completely and using Qt'sQTcpSocketto do whatever you want from TCP instead? But I'm not offering to change your own source code over from using Borland TCP to Qt's ;-) -
@LudoFR said in undefined reference - Help first time external header library QT C++ [Linux]:
Wow, really I want to thank you for your effort, this mean a lot seriously.
That's good, because I'm expecting a beer ;-)
Into a *.o lib?
No. Compiling each of those files separately will produce a
.ofile for each of the.csource files. This example does not show any library (.so, or for that matter.a) being generated from them. I presume that is how it is intended to work, author does not want you to create a single library but rather compile them all and link all the.ofiles.Assuming this is so, then I believe you will have to add all whatever necessary
.cfiles (may not be all the ones in this example, might be others, I don't know) into your Qt project as source files, in addition to your own source file(s). Then when you build the project all the.ofiles will be created separately, and all must be included in the link line.I'm afraid it's over to you to do whatever to get all those source files correctly added into the project in Creator/the
.profile. You will have to be careful the paths are right and their header (.h) files are found correctly.P.S.
At this point have you considered dropping this third-party Borland stuff completely and using Qt'sQTcpSocketto do whatever you want from TCP instead? But I'm not offering to change your own source code over from using Borland TCP to Qt's ;-)Well not against offering you a beer, or two...(or more :-))
@JonB said in undefined reference - Help first time external header library QT C++ [Linux]:
At this point have you considered dropping this third-party Borland stuff completely and using Qt's QTcpSocket to do whatever you want from TCP instead? But I'm not offering to change your own source code over from using Borland TCP to Qt's ;-)
This APi is used for GPIO manipulation from an ethernet GPIO modules :

What you say seems really true, cause the documentation about the use with Visual studio c++ do not refer at any moment about any library, only cpp/h files. I will try to use this documentation and use into my *.pro file only the files used into Visual Studio.
https://www.deditec.de/media/pdf/manual_e_delib.pdf#page=26&zoom=auto,-329,815
I will made you a feedback of course