Linking issue in halld_recon

14 views
Skip to first unread message

Boris Grube

unread,
Jul 14, 2025, 5:01:04 PMJul 14
to gluex-s...@googlegroups.com
Dear all,

I'd like to add a class to one of the libraries in `halld_recon` and I
want to use this class in a `JEventProcessor`-based JANA plugin.
However, doing so I run into a linker issue that I have no clue how to
resolve. Maybe one of you has an idea.

As an example: I want to add the following trivial class

*foo.h*
```
#ifndef FOO_H
#define FOO_H

class Foo {
public:
Foo();
~Foo();

void doSomething();
};

#endif // FOO_H
```

*foo.cc*
```
#include <iostream>

#include "foo.h"

Foo::Foo() {}

Foo::~Foo() {}

void Foo::doSomething() {
std::cout << "Doing something in Foo!" << std::endl;
}

```

to the library in `src/libraries/KINFITTER`. If I add the two source
files above to this directory, compilation works and running `nm -C
Linux_Alma9-x86_64-gcc11.5.0/lib/libKINFITTER.a` gives

```
...
foo.o:
U __cxa_atexit
U __dso_handle
U _GLOBAL_OFFSET_TABLE_
0000000000000000 t _GLOBAL__sub_I_foo.cc
0000000000000000 r .LC0
0000000000000020 T Foo::doSomething()
0000000000000000 T Foo::Foo()
0000000000000000 T Foo::Foo()
0000000000000010 T Foo::~Foo()
0000000000000010 T Foo::~Foo()
...

```
So the class definition was correctly written into the static library.

When instantiating `Foo` in a JANA plugin class, compilation works and
the `.so` file of the plugin contains an undefined symbol for `Foo`, i.e.

```
U Foo::Foo()
```

I was expecting that this is not a problem as `hd_root` is linked
against all static libraries and should contain the respective
definitions for `Foo`. However, running the plugin using `hd_root` I get
the error message
`hd_root: symbol lookup error:
/home/bgrube/halld_my/Linux_Alma9-x86_64-gcc11.5.0/plugins/eta_ana.so:
undefined symbol: _ZN3FooC1Ev`
Here, `_ZN3FooC1Ev` is the constructor `Foo::Foo()`.

Running `nm -C Linux_Alma9-x86_64-gcc11.5.0/bin/hd_root` does indeed
show that there are no definitions for `Foo` in `hd_root`.

Any ideas of what I could try to resolve this would be highly
appreciated. I'm using a pretty recent version of `halld_recon`:
```
> git describe
offmon-2017_01-ver60-2-gae33f4ead
```


Many thanks and best regards,
Boris
Reply all
Reply to author
Forward
0 new messages