Root Version: 6.26/10
Platform: AlmaLinux 8.7
Compiler: g++
Issue to address:
I’ve written a simple program with the goal of learning how to generate dictionaries for use in ROOT programs using a Makefile. However, when I try to make the program in its current state, I receive the following error:
/usr/bin/ld: cannot find -lDict
collect2: error: ld returned 1 exit status
make: *** [Makefile:16: test] Error 1
My guess is that I’ve probably made a simple mistake here, but I’ve so far been unable to figure it out.
Steps to reproduce:
I am unfortunately unable to post links as a first time poster, so I have pasted my Makefile below.
Makefile:
SRC = src
BIN = bin
CC = g++
CFLAGS = -c -w -std=c++14 -I$(shell root-config --incdir)
CFLAGSDICT = -c -w -I$(shell root-config --incdir)
LINKOPTION = $(shell root-config --libs)
test : $(BIN)/test.o $(BIN)/simple_struct.so
@echo "Linking..."
$(CC) $^ -o$@ $(LINKOPTION) -L./$(BIN) -lDict
@echo "Finished"
$(BIN)/simple_struct.so : simple_struct.cxx
$(CC) -shared -fPIC -o$@ $(CFLAGS) -I$(ROOTSYS)/include $^ `root-config --ldflags --libs`
simple_struct.cxx : $(SRC)/simple_struct.h $(SRC)/LinkDef.h
rootcling -f $@ $(CFLAGSDICT) -p $^
$(BIN)/test.o : $(SRC)/test.cpp
@echo "Compiling..."
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(BIN)/*.o
rm -f $(BIN)/*.so
rm -f *.cxx
rm -f *.pcm
.PHONY: $(SRC)/simple_struct.h $(SRC)/Linkdef.h test clean
Additional comments:
First time forum-poster here. I have moderate experience with ROOT and C++, and usually spend time researching issues like this before I resort to the forums route. However, I have been banging my head against a wall on this one for a while now with no discernible progress, so here I am.
The most useful references I’ve encountered so far include the manual page on “I/O of custom classes” and an old forum post on “Using rootcint to generate dictionaries for standalone progs.”
I would like to be able to generate some shared object dictionary files from some header files and compile them into an executable program. However, the official ROOT documentation on how to do this is not very thorough, and most of the forum posts I’ve found are either 10 years old or don’t provide adequate code references for me to be able to understand what they are doing.
The step I’m struggling with is generating the executable program while referencing the previously generated shared object dictionary files correctly. What is the proper way to do this?