NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

2019 C/C++ Compile Tools

Solved!
Go to solution

Hi Charlie, 

See below for the results from running the command with the -r option.


admin@NI-cRIO-9033-01A23322:~# ldd -r /C/ni-rt/startup/data/libHIDAPI.so ldd: warning: you do not have execution permission for `/C/ni-rt/startup/data/libHIDAPI.so'
linux-vdso.so.1 (0x00007ffcb7bd3000)
libc.so.6 => /lib/libc.so.6 (0x00007fd8ca484000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd8caa24000)
undefined symbol: udev_new (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_enumerate_scan_devices (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_unref (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_device_get_parent_with_subsystem_devtype (/C/ni-rt/startup/data/libHI DAPI.so)
undefined symbol: udev_enumerate_new (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_enumerate_add_match_subsystem (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_list_entry_get_next (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_device_new_from_syspath (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_enumerate_get_list_entry (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_device_unref (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_enumerate_unref (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_device_new_from_devnum (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_device_get_sysattr_value (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_list_entry_get_name (/C/ni-rt/startup/data/libHIDAPI.so)
undefined symbol: udev_device_get_devnode (/C/ni-rt/startup/data/libHIDAPI.so)

 

This is the output of the permissions query/setting. After running the second command, I retried calling the library and got the same result.


admin@NI-cRIO-9033-01A23322:~# ls -l /C/ni-rt/startup/data/libHIDAPI.so
-rw-rw-r-- 1 lvuser ni 121344 Apr 17 02:15 /C/ni-rt/startup/data/libHIDAPI.so
admin@NI-cRIO-9033-01A23322:~# chmod a+x /C/ni-rt/startup/data/libHIDAPI.so
admin@NI-cRIO-9033-01A23322:~# ls -l /C/ni-rt/startup/data/libHIDAPI.so
-rwxrwxr-x 1 lvuser ni 121344 Apr 17 02:15 /C/ni-rt/startup/data/libHIDAPI.so*

0 Kudos
Message 11 of 17
(2,968 Views)

Follow up responses - this is the output of the nm undefined command:



admin@NI-cRIO-9033-01A23322:~# nm --undefined-only /C/ni-rt/startup/data/libHIDAPI.so
U calloc@@GLIBC_2.2.5
U close@@GLIBC_2.2.5
w __cxa_finalize@@GLIBC_2.2.5
U __errno_location@@GLIBC_2.2.5
U free@@GLIBC_2.2.5
U __fxstat@@GLIBC_2.2.5
w __gmon_start__
U ioctl@@GLIBC_2.2.5
U __isoc99_sscanf@@GLIBC_2.7
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
w _Jv_RegisterClasses
U mbstowcs@@GLIBC_2.2.5
U memset@@GLIBC_2.2.5
U open@@GLIBC_2.2.5
U poll@@GLIBC_2.2.5
U read@@GLIBC_2.2.5
U setlocale@@GLIBC_2.2.5
U strchr@@GLIBC_2.2.5
U strcmp@@GLIBC_2.2.5
U strdup@@GLIBC_2.2.5
U strerror@@GLIBC_2.2.5
U strtok_r@@GLIBC_2.2.5
U strtol@@GLIBC_2.2.5
U __tls_get_addr@@GLIBC_2.3
U udev_device_get_devnode
U udev_device_get_parent_with_subsystem_devtype
U udev_device_get_sysattr_value
U udev_device_new_from_devnum
U udev_device_new_from_syspath
U udev_device_unref
U udev_enumerate_add_match_subsystem
U udev_enumerate_get_list_entry
U udev_enumerate_new
U udev_enumerate_scan_devices
U udev_enumerate_unref
U udev_list_entry_get_name
U udev_list_entry_get_next
U udev_new
U udev_unref
U vsnprintf@@GLIBC_2.2.5
U wcscmp@@GLIBC_2.2.5
U wcsdup@@GLIBC_2.2.5
U wcsncpy@@GLIBC_2.2.5
U write@@GLIBC_2.2.5

Below is the output of the console after running a build in Eclipse.

 

09:14:47 **** Rebuild of configuration Debug for project HIDAPI ****
Info: Internal Builder is used for build
x86_64-nilrt-linux-gcc "-IC:\\build\\19.0\\oecore-i686-core2-64-toolchain-6.0\\sysroots\\core2-64-nilrt-linux\\usr\\include\\c++\\6.3.0\\x86_64-nilrt-linux" "-IC:\\build\\19.0\\oecore-i686-core2-64-toolchain-6.0\\sysroots\\core2-64-nilrt-linux\\usr\\include\\c++\\6.3.0" "-IC:\\build\\19.0\\oecore-i686-core2-64-toolchain-6.0\\sysroots\\core2-64-nilrt-linux\\usr\\include" -O0 -g3 -Wall -c -fmessage-length=0 "--sysroot=C:\\build\\19.0\\oecore-i686-core2-64-toolchain-6.0\\sysroots\\core2-64-nilrt-linux" -fPIC -o "src\\hid.o" "..\\src\\hid.c"
x86_64-nilrt-linux-gcc "--sysroot=C:\\build\\19.0\\oecore-i686-core2-64-toolchain-6.0\\sysroots\\core2-64-nilrt-linux" -shared -o libHIDAPI.so "src\\hid.o"

09:14:51 Build Finished (took 4s.6ms)

0 Kudos
Message 12 of 17
(2,950 Views)
Solution
Accepted by topic author paul.r

Hi Paul,

 

You need to link libc to resolve open/close/write/etc and libudev to resolve udev_* symbols. They're both located at /lib on NI Linux RT controllers. You can link them by adding the following to your gcc command line: -ludev -lc

 

 

Message 13 of 17
(2,931 Views)
Solution
Accepted by topic author paul.r

Haris is correct. You can also do this in Eclipse (though it's a bit of a pain) in the project properties. 

 

  1. In Eclipse, open the properties for your project.
  2. Navigate to C/C++ Build >> Settings.
  3. Select the Tool Settings tab and then Cross GCC Linker >> Libraries. You should see the following:
    GatorBait_0-1587395409822.png
  4. In the Libraries view, click to add a library.
    GatorBait_1-1587395594027.png
  5. Enter the name of the external library you wish to link (e.g., udev) and click OK.
    GatorBait_2-1587395661333.png

     

  6. Repeat the above for each library that will need linked. E.g., you could add c as Haris mentions to manually link libc. 
  7. Click Apply and OK to apply the settings and close the project properties.
  8. Rebuild your shared library.
Charlie J.
National Instruments
Message 14 of 17
(2,924 Views)

Well, that seemed to do the trick! Thanks so much for the help!

0 Kudos
Message 15 of 17
(2,916 Views)

No problem! If you want a different experience than what Eclipse offers, we also recently published a tutorial series for Visual Studio Code. Personally I find the workflow a bit clearer in terms of configuration, but I'm a bit biased on that. 

Charlie J.
National Instruments
0 Kudos
Message 16 of 17
(2,911 Views)

I have recently moved to using LabVIEW 2020 - am I going to need to rebuild my library with an updated toolchain if I am running my application in LV2020? If so, is there a link to an updated version of the toolchain? I certainly hope this isn't the case, as having to rebuild an external library file every time we change versions of LabVIEW would be a nightmare.

 

(I am currently seeing strange behavior that I think may be related to the .so file, trying to figure out if that is the root cause or there is some other problem.)

0 Kudos
Message 17 of 17
(2,547 Views)