# Makefile errors when compiling executable program using rootcling-generated dictionaries

**URL:** <https://root-forum.cern.ch/t/makefile-errors-when-compiling-executable-program-using-rootcling-generated-dictionaries/59740>\
**Category:** Newbie\
**Created:** [June 22, 2024, 12:29am UTC](https://root-forum.cern.ch/t/makefile-errors-when-compiling-executable-program-using-rootcling-generated-dictionaries/59740 "2024-06-22T00:29:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![crafter312](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crafter312/32/36890_2.png) [@crafter312](https://root-forum.cern.ch/u/crafter312)\
**Post date:** [June 22, 2024, 12:29am UTC](https://root-forum.cern.ch/t/makefile-errors-when-compiling-executable-program-using-rootcling-generated-dictionaries/59740/1 "2024-06-22T00:29:14Z")

</div>

**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:

```auto
/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:**

```auto
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?

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 22, 2024, 5:31am UTC](https://root-forum.cern.ch/t/makefile-errors-when-compiling-executable-program-using-rootcling-generated-dictionaries/59740/2 "2024-06-22T05:31:57Z")

</div>

Hi Henry,

thanks for the post and welcome to the ROOT Community!

Your question is not really related to ROOT but seems rather a general Makefile question. You seem to try to link against a library called `libDict.so` but you do not generate it anywhere. Perhaps it’s there by mistake.

Best,  
D

---

<div class="post-metadata">

**Author:** ![crafter312](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crafter312/32/36890_2.png) [@crafter312](https://root-forum.cern.ch/u/crafter312)\
**Post date:** [June 24, 2024, 3:52pm UTC](https://root-forum.cern.ch/t/makefile-errors-when-compiling-executable-program-using-rootcling-generated-dictionaries/59740/3 "2024-06-24T15:52:01Z")

</div>

Thank you for the response! I guess you’re right that this is more of a Makefile question than a ROOT specific question, but I’ll gladly take your help if you’re still willing to offer it.

I don’t see `libDict.so` explicitly anywhere in my Make file, but I’m guessing this has something to do with the `-lDict` flag in the `test` rule? I looked this one up before posting, and I think I understand that this is looking for a library called `Dict`. However, I instead want to point to the `simple_struct.so` library. This is created from the `simple_struct.cxx` file generated by `rootcling`, but I’m not sure what “name” `rootcling` gives the shared library after compilation.

I’ve tried using the name of the file (i.e. `-lsimple_struct`), but this leads to the same error as before. What is the correct way to link against a `rootcling`-generated library in a Makefile?

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 24, 2024, 6:39pm UTC](https://root-forum.cern.ch/t/makefile-errors-when-compiling-executable-program-using-rootcling-generated-dictionaries/59740/4 "2024-06-24T18:39:00Z")

</div>

Hi,

In general libraries are called `libXYZ.so`, they are linked as `-l XYZ` and can be found in an env variable called `LD_LIBRARY_PATH`.

Cheers,  
Danilo

---

<div class="post-metadata">

**Author:** ![crafter312](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crafter312/32/36890_2.png) [@crafter312](https://root-forum.cern.ch/u/crafter312)\
**Post date:** [June 24, 2024, 8:00pm UTC](https://root-forum.cern.ch/t/makefile-errors-when-compiling-executable-program-using-rootcling-generated-dictionaries/59740/5 "2024-06-24T20:00:05Z")

</div>

After I generate the `simple_struct.cxx` file using `rootcling`, I then compile it into `simple_struct.so` library file. However, as mentioned above, when I try to use the `-l simple_struct` option to link this particular library, I get the same error as before.

One other thing I tried is using the `-s` option in `rootcling` to specify a library name. However, if I do this and use the same specified library name with the `-l` option, I also still get the same error.

How then do I figure out what library name to use with the `-l` option?
