Skip to content

Add link flags from pkg-config for libusb-1.0#97

Open
mikeage wants to merge 1 commit into
antirez:masterfrom
mikeage:ldflags_libusb-1.0
Open

Add link flags from pkg-config for libusb-1.0#97
mikeage wants to merge 1 commit into
antirez:masterfrom
mikeage:ldflags_libusb-1.0

Conversation

@mikeage

@mikeage mikeage commented Jan 6, 2016

Copy link
Copy Markdown

Needed when using Mac OS X 10.11, with libusb installed through homebrew

Needed when using Mac OS X 10.11, with libusb installed through homebrew
@yuvadm

yuvadm commented Jan 6, 2016

Copy link
Copy Markdown
Collaborator

On Linux I'm getting:

$ pkg-config --libs librtlsdr
-lrtlsdr -lusb-1.0

Is this not the case on OS X 10.11?

@mikeage

mikeage commented Jan 6, 2016

Copy link
Copy Markdown
Author

I do have the lib, but I'm missing the path.

$ pkg-config --libs libusb-1.0
-L/usr/local/Cellar/libusb/1.0.20/lib -lusb-1.0
$ pkg-config --libs librtlsdr
-L/usr/local/Cellar/librtlsdr/0.5.3/lib -lrtlsdr -lusb-1.0

If we had -L/usr/local/lib, that would also be good enough, but this is not in the default search path for libs.

@yuvadm

yuvadm commented Jan 6, 2016

Copy link
Copy Markdown
Collaborator

On OS X 10.9 I get:

$ pkg-config --libs librtlsdr
-L/usr/local/Cellar/librtlsdr/0.5.3/lib -lrtlsdr -lusb-1.0

and a successful build. Are you sure this isn't a local issue? Does this repro on other 10.11 boxes?

Also check:

$ pkg-config --cflags librtlsdr
-I/usr/local/Cellar/librtlsdr/0.5.3/include/ -I/usr/local/Cellar/libusb/1.0.18/include/libusb-1.0

@mikeage

mikeage commented Jan 6, 2016

Copy link
Copy Markdown
Author

I don't have any other machines to test on. Where does your OS X machine have libusb-1.0.*? I didn't have it in /usr/local/Cellar/librtlsdr/0.5.3/lib, but only in /usr/local/Cellar/libusb/1.0.20/lib.

@yuvadm

yuvadm commented Jan 6, 2016

Copy link
Copy Markdown
Collaborator

I have libusb in the same location (granted, version 1.0.18)

@mikeage

mikeage commented Jan 6, 2016

Copy link
Copy Markdown
Author

Interesting. I'll poke around in the homebrew recipe a bit later to see if I can see what's going on.

@mikeage

mikeage commented Jan 6, 2016

Copy link
Copy Markdown
Author

No clue. Doesn't seem like an earlier version of the recipe would have done this, nor does building from source. Maybe some version of the bottle included it; can I ask what you get if you remove and reinstall librtlsdr? (not sure how much time / effort you want to put into this...)

@mikeage

mikeage commented Jan 18, 2016

Copy link
Copy Markdown
Author

FWIW, the root cause seems to be https://www.mail-archive.com/osmocom-sdr@lists.osmocom.org/msg00955.html . I recently replaced homebrew's librtlsdr with https://github.com/keenerd/rtl-sdr, where it has this fix (see keenerd/rtl-sdr@bc872cb) , and now pkg-config --libs librtlsdr returns a -L for libusb-1.0 as well.

@yuvadm

yuvadm commented Jan 18, 2016

Copy link
Copy Markdown
Collaborator

@mikeage great news! Can we consider this issue closed? Or is there anything you think we should change (only if it won't break other environments, of course)?

@mikeage

mikeage commented Jan 18, 2016

Copy link
Copy Markdown
Author

Given that the "official" homebrew version seems to be broken, out of the box, I'm not sure it's really closed. dump1090 does depend on both libusb-1.0 and librtlsdr, and even if one often includes the other, I think it's more proper to include an explicit dependency. I presume pkg-config --libs libusb-1.0 doesn't break anything on Linux, does it?

OTOH, most packages that use librtlsdr don't include libusb-1.0, and I've had to patch all of them as well. I understand the forks of dump1090, but I've seen others as well, so maybe I'm missing something. Or maybe most users are on Linux :)

@JoeMatt

JoeMatt commented Jun 28, 2023

Copy link
Copy Markdown

This worked for me on OS X 14.0 ARM

CC?=clang
CFLAGS?=-O2 -g -Wall -W $(shell pkg-config --cflags librtlsdr)

LDLIBS+= \
 $(shell pkg-config --libs libusb-1.0) \
 $(shell pkg-config --libs librtlsdr) \
 -lpthread \
 -lm

PROGNAME=dump1090

all: $(PROGNAME)

%.o: %.c
	$(CC) $(CFLAGS) -c $<

dump1090: $(PROGNAME).o anet.o
	$(CC) -g -o $(PROGNAME) $(PROGNAME).o anet.o $(LDFLAGS) $(LDLIBS)

clean:
	rm -f *.o $(PROGNAME)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants