0

I am trying to compile some C code with gcc, but I keep getting undefined reference to 'function_name()' for some functions that I call in my code. I am using the Pylon C SDK, and the undefined functions are from that. Initially, I noticed that gcc could not even find the PylonC.h header file, so I had to add -I/opt/pylon/include to the compilation command.

The full command that I am using for compiling is this:

gcc -I/opt/pylon/include -Wall -pthread -o initialization.o initialization.c -lpigpio -lrt

The full error message is this:

/usr/bin/ld: /tmp/ccPxifSn.o: in function `init_camera':
initialization.c:(.text+0x135): undefined reference to `PylonInitialize'
/usr/bin/ld: initialization.c:(.text+0x150): undefined reference to `PylonEnumerateDevices'
/usr/bin/ld: initialization.c:(.text+0x198): undefined reference to `PylonTerminate'
/usr/bin/ld: initialization.c:(.text+0x1c7): undefined reference to `PylonCreateDeviceByIndex'
/usr/bin/ld: initialization.c:(.text+0x207): undefined reference to `PylonDeviceSetFloatFeature'
/usr/bin/ld: initialization.c:(.text+0x247): undefined reference to `PylonDeviceSetFloatFeature'
/usr/bin/ld: initialization.c:(.text+0x278): undefined reference to `PylonDeviceGetIntegerFeature'
/usr/bin/ld: initialization.c:(.text+0x2a9): undefined reference to `PylonDeviceSetIntegerFeature'
/usr/bin/ld: initialization.c:(.text+0x2da): undefined reference to `PylonDeviceGetIntegerFeature'
/usr/bin/ld: initialization.c:(.text+0x30b): undefined reference to `PylonDeviceSetIntegerFeature'
/usr/bin/ld: initialization.c:(.text+0x33f): undefined reference to `PylonDeviceFeatureFromString'
/usr/bin/ld: initialization.c:(.text+0x35b): undefined reference to `PylonTerminate'
/usr/bin/ld: /tmp/ccPxifSn.o: in function `PrintErrorAndExit':
initialization.c:(.text+0x3a2): undefined reference to `GenApiGetLastErrorMessage'
/usr/bin/ld: initialization.c:(.text+0x3c5): undefined reference to `GenApiGetLastErrorMessage'
/usr/bin/ld: initialization.c:(.text+0x407): undefined reference to `GenApiGetLastErrorDetail'
/usr/bin/ld: initialization.c:(.text+0x42a): undefined reference to `GenApiGetLastErrorDetail'
/usr/bin/ld: initialization.c:(.text+0x45d): undefined reference to `PylonTerminate'
collect2: error: ld returned 1 exit status

It seems that ld cannot find the Pylon functions... Seems to be a linkage issue. What is the solution for this?

Anthony K.
  • 11
  • 4

0 Answers0