0

Here is my makefile.

# The intuitive "all" target will be our default.
.DEFAULT_GOAL := all

# Component dir's to search and invoke make.
# (Try preserving the order of directories)
COM := src_dir1 src_dir2 src_dir3 
PROJ_DIR = $(shell pwd)

EXEC := anonymousforconfidentiality
CC := g++
CFLAGS := -g3

LIBS = `pkg-config --cflags --libs glib-2.0 gio-unix-2.0 bluez protobuf lrt`


.PHONY : clean compile link all

all: | clean compile link

link: 
        $(eval $@_ALLOBJECTS := $(shell find . -name '*.o'))
        $(CC) $(CFLAGS) -o $(EXEC) $($@_ALLOBJECTS) $(LIBS)

compile:
    for COMDIR in $(COM) ; do \
    $(MAKE) INCLUDE_PATH=$(PROJ_DIR) -C $$COMDIR ; \
    done

clean:
    for COMDIR in $(COM) ; do \
    rm -f $$COMDIR/bin/*.o ; \
    done

    rm -f $(EXEC)

I am not able to link the library 'lrt'. I make extensive use of POSIX real time such as mq_open(), mq_send(), mq_receive() etc... So it is imperative I link it.

Some of the variations I tried: 1. librt 2. lrt 3. rt 4. librt-dev

However I always get this error:

Package lrt was not found in the pkg-config search path.
Perhaps you should add the directory containing `lrt.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lrt' found

I even tried to manually install "librt" but was unsuccessful in locating the package. Nor did apt-get find it.

I was assuming this lib comes prepackaged with Ubuntu normal kernel (no real time patch). Need help with resolution of this issue.

1 Answer 1

2

You probably want to link rt library. This is done with -lrt. No need to use pkg-config for it.

E.g.:

LIBS := `pkg-config --libs glib-2.0 gio-unix-2.0 bluez protobuf` -lrt
3
  • Is there a reason I cannot use pkg config?
    – Ace
    Jul 18, 2019 at 13:27
  • @Ace Added an example for you. rt is a system-installed library, pkg-config doesn't know anything about it. Jul 18, 2019 at 13:28
  • Ah! Thanks a lot. That makes lot of sense!
    – Ace
    Jul 18, 2019 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.