nxp-archive / openil_linuxptp

PTP IEEE 1588 stack for Linux
GNU General Public License v2.0
136 stars 60 forks source link

ptp4l linkage fails: undefined reference to print_get_level #28

Open adiel91 opened 2 years ago

adiel91 commented 2 years ago

Trying to compile latest ptp4l (17.02.2022) from git, fails. Head commit ID: 1614aefad3284ba67ea5eb64271e882ad57c2b5a

Compilation: make -j$(nproc)

System: Debian 9 Stretch, GCC 6.3.0

Failures: gcc ts2phc.o config.o clockadj.o hash.o interface.o phc.o print.o linreg.o ntpshm.o nullf.o pi.o servo.o sk.o lstab.o nmea.o serial.o sock.o ts2phc_generic_master.o ts2phc_master.o ts2phc_phc_master.o ts2phc_nmea_master.o ts2phc_slave.o util.o version.o -lm -lrt -pthread -o ts2phc phc2sys.o: In function servo_add': phc2sys.c:(.text+0x105): undefined reference toprint_get_level' phc2sys.c:(.text+0x16e): undefined reference to print_get_level' phc2sys.o: In functionclock_add': phc2sys.c:(.text+0x21d): undefined reference to print_get_level' phc2sys.c:(.text+0x326): undefined reference toprint_get_level' phc2sys.c:(.text+0x387): undefined reference to print_get_level' phc2sys.o:phc2sys.c:(.text+0x67d): more undefined references toprint_get_level' follow collect2: error: ld returned 1 exit status

: recipe for target 'phc2sys' failed make: *** [phc2sys] Error 1 make: *** Waiting for unfinished jobs.... pmc.o: In function `main': pmc.c:(.text+0x1e8e): undefined reference to `print_get_level' config.o: In function `parse_item': config.c:(.text+0x9b5): undefined reference to `print_get_level' config.o: In function `parse_fault_interval': config.c:(.text+0xac5): undefined reference to `print_get_level' config.o: In function `config_get_double': config.c:(.text+0x191d): undefined reference to `print_get_level' config.c:(.text+0x194e): undefined reference to `print_get_level' config.o:config.c:(.text+0x19ce): more undefined references to `print_get_level' follow collect2: error: ld returned 1 exit status : recipe for target 'pmc' failed make: *** [pmc] Error 1
JoshuaThaler commented 2 years ago

Hi, the problem for this might be the inline function definition of print_get_level. Solutions are to either change the function in the print.h and print.c files to a normal non-inline function: print.h:

-- inline int print_get_level(void)
-- {
--         return print_level;
-- }
++ int print_get_level(void);

print.c:

++ int print_get_level(void)
++ {
++         return print_level;
++ }

or set some optimization options for the compiler by adding EXTRA_CFLAGS = -O2 to the makefile.