MikiBelavista
MikiBelavista

Reputation: 2728

C code Makefile,how to include path?

I am trying to compile bottledwater

~/bottledwater-pg$ make
make -C ext all
make[1]: Entering directory '/home/jholmes/bottledwater-pg/ext'
Package avro-c was not found in the pkg-config search path.
Perhaps you should add the directory containing `avro-c.pc'
to the PKG_CONFIG_PATH environment variable
No package 'avro-c' found

Avro-c is here

/home/jholmes/avro-c-1.8.2

Makefile

MODULE_big = bottledwater
EXTENSION = bottledwater

AVRO_CFLAGS = $(shell pkg-config --cflags avro-c)
AVRO_LDFLAGS = $(shell pkg-config --libs avro-c)

PG_CPPFLAGS += $(AVRO_CFLAGS) -std=c99
SHLIB_LINK += $(AVRO_LDFLAGS)

OBJS = io_util.o error_policy.o logdecoder.o oid2avro.o schema_cache.o protocol.o protocol_server.o snapshot.o
DATA = bottledwater--0.1.sql

PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

How does shell expand PG_CONFIG? What should I do to enable main code to detect avro-c folder? I have compiled avro-c, on Ubunutu 16.04. My avrolib path /home/jholmes/avro-c-1.8.2/build/avrolib

~/avro-c-1.8.2/build/avrolib$ ls
bin  include  lib

There is no avro-c.pc inside. Bin content

/avro-c-1.8.2/build/avrolib/bin$ ls
avroappend  avrocat  avromod  avropipe

Upvotes: 0

Views: 1414

Answers (1)

Nikos C.
Nikos C.

Reputation: 51832

Since you have installed the library in a non-standard location, you need to tell pkg-config about that non-standard location. The easiest way to do that, is to set the PKG_CONFIG_PATH environment variable. You can do that when running make:

PKG_CONFIG_PATH="/home/jholmes/avro-c-1.8.2/lib/pkgconfig" make

This assumes that /home/jholmes/avro-c-1.8.2/lib/pkgconfig is where the .pc file resides.

Anyway, overall, I would instead recommend installing libraries in /usr/local instead. This should result in everything just working without manual intervention. /usr/local is a location used specifically for this purpose.

Upvotes: 1

Related Questions