dresden-elektronik / gcfflasher

GCFFlasher is the tool to program the firmware of dresden elektronik's Zigbee products.
BSD 3-Clause "New" or "Revised" License
34 stars 3 forks source link

Unable to compile on Ubuntu 18.04 (undefined reference 'dlclose') #1

Closed robinsmidsrod closed 3 years ago

robinsmidsrod commented 3 years ago

I'm trying to compile on Ubuntu 18.04, and I'm getting this error message:

$ ./build_posix.sh
gcc -Wall -DPL_LINUX -DHAS_LIBGPIOD -ldl -O2 -DNDEBUG
/tmp/ccynS9Kw.o: In function `plUnloadLibGpiod':
main_posix.c:(.text+0x15): undefined reference to `dlclose'
/tmp/ccynS9Kw.o: In function `plLoadLibGpiod':
main_posix.c:(.text+0x25b): undefined reference to `dlopen'
main_posix.c:(.text+0x27d): undefined reference to `dlsym'
main_posix.c:(.text+0x298): undefined reference to `dlsym'
main_posix.c:(.text+0x2b3): undefined reference to `dlsym'
main_posix.c:(.text+0x2ce): undefined reference to `dlsym'
main_posix.c:(.text+0x2e8): undefined reference to `dlsym'
/tmp/ccynS9Kw.o:main_posix.c:(.text+0x301): more undefined references to `dlsym' follow
collect2: error: ld returned 1 exit status

Distro details:

$ uname -a
Linux core 4.15.0-147-generic #151-Ubuntu SMP Fri Jun 18 19:21:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

I've got gpiod and libc headers and build-essential installed:

$ dpkg -l | grep gpio
ii  libgpiod-dev                           1.0-1                                            amd64        C library for interacting with Linux GPIO device - static libraries and headers
ii  libgpiod1:amd64                        1.0-1                                            amd64        C library for interacting with Linux GPIO device - shared libraries

$ dpkg -l | grep libc6-dev
ii  libc6-dev:amd64                        2.27-3ubuntu1.4                                  amd64        GNU C Library: Development Libraries and Header Files
ii  libc6-dev-i386                         2.27-3ubuntu1.4                                  amd64        GNU C Library: 32-bit development libraries for AMD64
ii  libc6-dev-x32                          2.27-3ubuntu1.4                                  amd64        GNU C Library: X32 ABI Development Libraries for AMD64

I feel I'm missing something obvious here...

manup commented 3 years ago

Good point, I think it's good to add some instructions for specific operating systems on build dependencies.

I'm not sure why Ubuntu doesn't find the symbols, I'll do some tests in a VM.

manup commented 3 years ago

Turns out some GCC versions require -Wl,--no-as-needed -ldl to link the lib. I've updated build_posix.sh to reflect that, on my Ubuntu 18 VM this builds correctly now.

robinsmidsrod commented 3 years ago

I've confirmed that building on Ubuntu 18.04 works as expected now. Thanks a bunch for the quick fix!