Undefined Reference to hal_export_funct Linker Error in LinuxCNC HAL Component

More
1 year 3 weeks ago #335840 by takgu
Hello,I am encountering a persistent linker error while building a HAL component for LinuxCNC, despite correctly identifying the location of the required function. I would appreciate any assistance from members who have experience using
Code:
hal_export_funct
. 1. The Problem I am trying to link my component, but the build fails with an "undefined reference" error for a HAL API function. 2. The Setup and Findings ItemDetailsInitial Linker Option
Code:
-L/lib -llinuxcnchal
Error Message
Code:
undefined reference to hal_export_funct
Source of ErrorI confirmed that the function
Code:
hal_export_funct
is not defined in
Code:
liblinuxcnchal.so
.Function LocationI found that
Code:
hal_export_funct
is defined in the real-time library:
Code:
/rtlib/hal_lib.so
.Attempted FixI updated the linker options in my build system (a
Code:
.pro
file using qmake) to include both libraries:
Code:
-L/lib -llinuxcnchal
and
Code:
-L/rtlib -lhal_lib
.Resulting ErrorThe linker now reports that it cannot find the
Code:
-lhal_lib
library.
Sheets로 내보내기 3. The Core Issue The linker path to the directory (
Code:
/rtlib
) is accurate, and the library file (
Code:
hal_lib.so
) containing the function is confirmed to exist there. However, the build system or linker seems unable to successfully link
Code:
-lhal_lib
.Could this issue be related to:
  1. A specific linker flag order required for real-time libraries?
  2. A misunderstanding of how the HAL and RTAPI libraries should be linked together (especially since
    Code:
    hal_init
    is present in both
    Code:
    liblinuxcnchal.so
    and
    Code:
    hal_lib.so
    )?
  3. An incorrect way to specify the library name (
    Code:
    -l
    ) when using an absolute path or a custom library path (
    Code:
    -L
    ) in the build system?
Any guidance on how to correctly force the linker to recognize and use
Code:
hal_lib.so
for
Code:
hal_export_funct
would be greatly appreciated.Thank you.

Please Log in to join the conversation.

More
1 year 3 weeks ago #335842 by unknown
Is there any reason you can not use halcompile to build your component. As that is the "traditional" way to build components outside of the build process.

Please Log in to join the conversation.

More
1 year 3 weeks ago #335843 by takgu
I am currently building a CNC control application using Qt C++ to control servo motors via EtherCAT.

I am encountering errors while attempting to execute the following HAL functions within my Qt code: hal_init, hal_ready, hal_export_funct, and hal_link.

Additionally, when I use the halcmd utility to add components or functions, I am unable to use (access) those resulting HAL pins/fields within my Qt C++ application.

Thank you.

Please Log in to join the conversation.

More
1 year 3 weeks ago #335848 by Hakan
The libs are not actually in /lib and /rtlib are they?

Please Log in to join the conversation.

More
1 year 3 weeks ago #335850 by takgu
/lib/linuxcnchal.so
- hal_export_funct - not exist

/rtlib/hal_lib.so
- hal_export_funct - exist

LIBS += -L$$LINUXCNC_HOME/lib -llinuxcnchal
LIBS += -L$$LINUXCNC_HOME/rtlib -lhal_lib

** Link Error when building qt app ('Not found -lhal_lib')

Thanks

Please Log in to join the conversation.

More
1 year 3 weeks ago #335851 by unknown

Please Log in to join the conversation.

More
1 year 3 weeks ago #335852 by takgu
The reason I am using Qt C++ is that the existing external module, which was developed in C++, is incompatible with Qt Python (QtPy).

Thanks.

Please Log in to join the conversation.

More
1 year 3 weeks ago #335854 by Hakan
LINUXCNC_HOME then, what is its value?

Please Log in to join the conversation.

More
1 year 3 weeks ago #335855 by rodw
A bit left field but how did you install linuxcnc? If installed on Trixie and not the LinuxCNC ISO, did you
sudo apt install linuxcnc-uspace-dev
I think this is needed to get the required libs (certainly for halcompile)
The ISO installs linuxcnc-uspace-dev

Please Log in to join the conversation.

More
1 year 3 weeks ago #335856 by takgu
LINUXCNC_HOME : /home/user1/linuxcnc

The Qt application now works correctly when I comment out the following two lines in the build configuration:

- LIBS += -L/home/user1/linuxcnc/rtlib -lhal_lib

- hal_export_funct.

Thanks

Please Log in to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum