Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikeage
Copy link

@mikeage mikeage commented Jan 6, 2016

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
Copy link
Collaborator

yuvadm commented Jan 6, 2016

On Linux I'm getting:

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

Is this not the case on OS X 10.11?

@mikeage
Copy link
Author

mikeage commented Jan 6, 2016

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
Copy link
Collaborator

yuvadm commented Jan 6, 2016

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
Copy link
Author

mikeage commented Jan 6, 2016

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
Copy link
Collaborator

yuvadm commented Jan 6, 2016

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

@mikeage
Copy link
Author

mikeage commented Jan 6, 2016

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

@mikeage
Copy link
Author

mikeage commented Jan 6, 2016

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
Copy link
Author

mikeage commented Jan 18, 2016

FWIW, the root cause seems to be https://www.mail-archive.com/[email protected]/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
Copy link
Collaborator

yuvadm commented Jan 18, 2016

@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
Copy link
Author

mikeage commented Jan 18, 2016

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
Copy link

JoeMatt commented Jun 28, 2023

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