Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4040

General discussion • what to place in a make file to use libgpiod

$
0
0
Ii have a makefile that is pre-configured for a graphics display interface. I want to add the libgpiod interface to it, but am doing an excellent job of failing at it right now!

In the preconfigured makefile I put GPIO_DIR_LIB = -L /usr/lib/aarch64-linux-gnu which is where the libgpiod.a and libgpiod.so are located. Yet when I run the makefile, I get an error:
pi@raspberrypi:~/projects/StepperRoutines $ make -f makefile.david
( gcc -L/home/pi/glg/lib -L /usr/lib/aarch64-linux-gnu -L. -o main main.o BSP.o ADC.o Move.o \
-lglg_ext -lglg -lglg_map_stub \ -lgpiod \
-lXm -lXt -lX11 \
-lXft -lfontconfig -lfreetype -ljpeg -lz -lpng \
-lm -ldl -lpthread -lgpiod \
|| ( rm main ; exit 1 ) )
/usr/bin/ld: cannot find -lgpiod: No such file or directory
collect2: error: ld returned 1 exit status
rm: cannot remove 'main': No such file or directory
make: *** [makefile.david:163: main] Error 1

I know gpiod is loaded, because if I compile an example named blink ->gcc -o blink blink.c -lgpiod, it compiles cleanly and runs as expected.

Here is the preconfigured makefile - if anyone can break me out of the excellent job of failing, I would appreciate it. Being a Loser is such a drag!
Kind regards,
David
#########################################################################
# INTENDED USE
#
# This makefile may be used to compile and link individual source files
# in a directory that contains several versions of the same example,
# such as examples in the examples_c_cpp/Dashboard directory.
#
# The makefile uses the X11 version of the GLG library. Use a makefile
# with the "_gtk" suffix to use the GTK version of the GLG library.
#
# USING THE FILE
#
# This file assumes GNU make is used as a make utility.
# It compiles a single .c or .cpp file (with the basename defined by
# TARGET) as well as any additional files specified by ADD_FILES.
# Edit TARGET and ADD_FILES variables as needed.
#
# This file must be edited by adjusting directory path as well as
# uncommenting additional options depending on the platform.
# By default, Linux options are used.
#
# Edit the GLG_LIB_DIR line to use either GLG EVALUATION or PRODUCT
# libraries.
#########################################################################

# Default compiler
CC = gcc
#CC = g++

# Place any additional compiler options here.
OPTS = -g

# Place any additional linker options here.
# On Linux, -no-pie option may be used to get around relocation errors with
# libraries that were not build with -fPIC or -fPIE options.
#LD_OPTS =

###########################################################################
# Edit the next line to specify location of the GLG installation directory.
###########################################################################
GLG_DIR = /home/pi/glg
GLG_INC = -I$(GLG_DIR)/include
######## GPIOD_INC is the location of gpiod.h
GPIOD_INC = -I/usr/include
GPIOD_LIB_DIR = -L /usr/lib/aarch64-linux-gnu
#GPIOD_LIB_DIR = -L/lib/arch64-linux-gnu
########libgpiod.a & libgpiod.so appear in /usr/lib/aarch64-linux-gnu
######## and in /lib/aarch64-linux-gnu
######################################################################
# Uncomment one GLG_LIB_DIR line for linking with the GLG evaluation,
# product or Community Edition libraries.
######################################################################

# To use GLG EVALUATION libraries
#GLG_LIB_DIR = -L$(GLG_DIR)/eval/lib

# To use GLG PRODUCT or COMMUNITY EDITION libraries
GLG_LIB_DIR = -L$(GLG_DIR)/lib

######################################################################
# Uncomment one of the GLG_EXT_LIB lines for linking with either the
# intermediate or extended library in addition to the GLG Standard API.
# For C++, also uncomment a corresponding GLG_CPP_API_OPTS option below.
######################################################################

# Linking with the GLG Intermediate API.
#GLG_EXT_LIB = -lglg_int

# Linking with the GLG Extended API.
GLG_EXT_LIB = -lglg_ext

#####################################################################
# For C++ compiling, uncomment one of the GLG_CPP_API_OPTS lines
# to match the GLG library used for linking (Standard, Intermediate or
# Extended).
######################################################################
#GLG_CPP_API_OPTS = -DGLG_CPP_STANDARD_API
#GLG_CPP_API_OPTS = -DGLG_CPP_INTERMEDIATE_API
#GLG_CPP_API_OPTS = -DGLG_CPP_EXTENDED_API

######################################################################
# Uncomment one of the GLG_MAP_LIBS lines for linking with or without
# a map server.
######################################################################

# Linking without the map server.
GLG_MAP_LIBS = -lglg_map_stub

# Linking with the map server.
#GLG_MAP_LIBS = -lglg_map -lfreetype -ltiff

######################################################################
# Uncomment OPENGL_LIBS line for linking with OpenGL libraries
# if the application uses OpenGL outside of the GLG drawing.
######################################################################
#OPENGL_LIBS = -lGLU -lGL

######################################################################

# On Linux, uncomment the lines below for additional libraries.
# Due to a known bug in ldd/dlopen, -lpthread is required to avoid a crash
# when OpenGL is used.
# Comment out the next lines on non-linux platforms.
EXTRA_LIBS = -lpthread -lgpiod
FREETYPE_LIBS = -lXft -lfontconfig -lfreetype

# If -ljpeg causes a warning about conflicting versions of libjpeg on Linux,
# use a specific version of libjpeg. For example, for libjpeg.so.62, use:
# JPEG_LIB = -l:libjpeg.so.62
JPEG_LIB = -ljpeg

# On non-linux platforms, uncomment the next line for additional support
# libraries.
#SYS_LIB = -L$(GLG_LIB_DIR)/syslib

# On Solaris, uncomment the next line for additional libraries
#EXTRA_LIBS = -lnsl -lsocket

# On AIX, uncomment the next line for additional libraries
#EXTRA_LIBS = -liconv

# To use static Motif library (libXm.a), uncomment the next line for additional
# libraries.
#EXTRA_LIBS_STATIC = -lXmu -lXext

# Name of the main .c or .cpp file to compile and link
# (without the .c or .cpp extension)
# If both C and C++ versions of the file are present, the C version will
# be used by default.
TARGET = main

# Uncomment to list additional .o files here. They will be compiled from the
# corresponding .c or .cpp files.
# To compile the C++ version of the example, add GlgClass.o to ADD_FILES
# directory to build C++ version of the example.
########### BSP.o is BoardSupportPackage where global variables are located
########### ADC.o is for the Analog to Digital Converter
########### Move.o are routines for a pair of stepper motors
ADD_FILES = BSP.o ADC.o Move.o

######## Don't edit below ############################################

CFLAGS = $(OPTS) $(GLG_CPP_API_OPTS) $(GLG_INC) $(GPIOD_INC)

LD_FLAGS = $(LD_OPTS) $(GLG_LIB_DIR) $(SYS_LIB) $(GPIOD_LIB_DIR) -L.

OBJECTS = $(TARGET).o $(ADD_FILES)

INCLUDES := $(sort $(wildcard *.h))

all: $(TARGET)

%.o : %.c $(INCLUDES)
$(CC) -c $(CFLAGS) \
$< -o $@;

%.o : %.cpp $(INCLUDES)
$(CC) -c $(CFLAGS) \
$< -o $@;

$(TARGET) : $(OBJECTS)
( $(CC) $(LD_FLAGS) -o $@ $(OBJECTS) \
$(GLG_EXT_LIB) -lglg $(GLG_MAP_LIBS) \ -lgpiod \
-lXm -lXt -lX11 $(EXTRA_LIBS_STATIC) \
$(FREETYPE_LIBS) $(JPEG_LIB) -lz -lpng \
$(OPENGL_LIBS) -lm -ldl $(EXTRA_LIBS) \
|| ( rm $@ ; exit 1 ) )

######################################################################
# Include dependencies file, generate it on the first build.
# Remove depend.mk to regenerate dependencies file.
######################################################################

include depend.mk

depend.mk :
@echo "making $@" ; $(CC) -MM $(CFLAGS) $(SRCS) > $@

.PHONY : clean
clean :
rm -f depend.mk ; :
rm -f *.o ; :

Statistics: Posted by DFansler — Fri Sep 27, 2024 1:03 am



Viewing all articles
Browse latest Browse all 4040

Trending Articles