hzeller / rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
GNU General Public License v2.0
3.67k stars 1.17k forks source link

Impossible linking in C customizing c-example ??? #959

Open gege13007 opened 4 years ago

gege13007 commented 4 years ago

Hello, I first like to thank HZeller and all contributors for this great RGBMatrix work ! I'm doing a mix of a simple RGBMatrix implementation, and the raspi2png C program, wich is using lippng librairy... I can customize and compile the 2 progs separatly , but impossible to assemble the two. Starting from raspi2png or from c-example demo, give me the compilation errors.

Here is my Make for raspi2png.c (using RGBMatrix) : CFLAGS=-Wall -O3 -g -Wextra -Wno-unused-parameter CXXFLAGS=$(CFLAGS)

OBJS=raspi2png.o BIN=raspi2png

Where our library resides. You mostly only need to change the

RGB_LIB_DISTRIBUTION, this is where the library is checked out.

RGB_LIB_DISTRIBUTION=.. RGB_INCDIR=./include RGB_LIBDIR=./lib RGB_LIBRARY_NAME=rgbmatrix RGB_LIBRARY=$(RGB_LIBDIR)/lib$(RGB_LIBRARY_NAME).a LDFLAGS+=-L$(RGB_LIBDIR) -l$(RGB_LIBRARY_NAME) -lrt -lm -lpthread

CFLAGS+= $(shell libpng-config --cflags) LDFLAGS+=-L/opt/vc/lib/ -lbcm_host $(shell libpng-config --ldflags)

INCLUDES+=-I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux

all: $(BIN)

$(RGB_LIBRARY): FORCE $(MAKE) -C $(RGB_LIBDIR)

install: $(BIN) install -d -m 755 $(DESTDIR)/usr/bin/ install -m 755 $(BIN) $(DESTDIR)/usr/bin/raspi2png

All the binaries that have the same name as the object file.q

% : %.o $(RGB_LIBRARY) $(CXX) $< -o $@ $(LDFLAGS)

raspi2png : raspi2png.o $(RGB_LIBRARY) $(CC) $< -o $@ $(LDFLAGS) -lstdc++

%.o: %.c $(CC) $(CFLAGS) $(INCLUDES) -I$(RGB_INCDIR) -xc++ -g -c $< -o $@ -Wno-deprecated-declarations

$(BIN): $(OBJS) $(CC) -o $@ -Wl,--whole-archive $(OBJS) $(LDFLAGS) -Wl,--no-whole-archive -rdynamic

clean: @rm -f $(OBJS) @rm -f $(BIN)

FORCE: .PHONY: FORCE

And here are a part of the linking errors :

(g++ compilation ok for the RGBMatrix library) g++ -I../include -Wall -O3 -g -fPIC -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o pixel-mapper.o pixel-mapper.cc g++ -I../include -Wall -O3 -g -fPIC -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o multiplex-mappers.o multiplex-mappers.cc ar rcs librgbmatrix.a gpio.o led-matrix.o options-initialize.o framebuffer.o thread.o bdf-font.o graphics.o transformer.o led-matrix-c.o hardware-mapping.o content-streamer.o pixel-mapper.o multiplex-mappers.o g++ -shared -Wl,-soname,librgbmatrix.so.1 -o librgbmatrix.so.1 gpio.o led-matrix.o options-initialize.o framebuffer.o thread.o bdf-font.o graphics.o transformer.o led-matrix-c.o hardware-mapping.o content-streamer.o pixel-mapper.o multiplex-mappers.o -lpthread -lrt -lm -lpthread make[1]: AVERTISSEMENT : décalage d'horloge détecté. La construction peut être incomplète. make[1] : on quitte le répertoire « /home/pi/raspi2png/lib »

AND Now stop !

cc -o raspi2png -Wl,--whole-archive raspi2png.o -L./lib -lrgbmatrix -lrt -lm -lpthread -L/opt/vc/lib/ -lbcm_host -lpng16 -Wl,--no-whole-archive -rdynamic ./lib/librgbmatrix.a(gpio.o) : Dans la fonction « gnu_cxx::new_allocator::deallocate(int, unsigned int) » : /usr/include/c++/6/ext/new_allocator.h:110 : référence indéfinie vers « operator delete(void) » /usr/include/c++/6/ext/new_allocator.h:110 : référence indéfinie vers « operator delete(void) » ./lib/librgbmatrix.a(gpio.o) : Dans la fonction « rgb_matrix::(anonymous namespace)::TimerBasedPinPulser::~TimerBasedPinPulser() » : /home/pi/raspi2png/lib/gpio.cc:364 : référence indéfinie vers « operator delete(void, unsigned int) » ./lib/librgbmatrix.a(gpio.o) : Dans la fonction « __gnu_cxx::new_allocator::deallocate(int, unsigned int) » : /usr/include/c++/6/ext/new_allocator.h:110 : référence indéfinie vers « operator delete(void) » ./lib/librgbmatrix.a(gpio.o) : Dans la fonction « gnu_cxx::new_allocator::deallocate(unsigned int, unsigned int) » : /usr/include/c++/6/ext/new_allocator.h:110 : référence indéfinie vers « operator delete(void) »

gege13007 commented 4 years ago

Ok , it's ok. I solved the problem. It was a problem in the Makefile (too much options)....