plasma-umass / coz

Coz: Causal Profiling
Other
4.05k stars 160 forks source link

Linking issue #134

Closed jesperpedersen closed 4 years ago

jesperpedersen commented 4 years ago

A linking problem

[jpedersen@localhost libcoz]$ ldd ./libcoz.so 
    linux-vdso.so.1 (0x00007ffeb151a000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f70e342c000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f70e3422000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f70e3401000)
    libelf++.so.0 => not found
    libdwarf++.so.0 => not found
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f70e3207000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f70e30bf000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f70e30a5000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f70e2edf000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f70e34db000)
[jpedersen@localhost libcoz]$ locate libelf++.so
/usr/local/lib/libelf++.so
/usr/local/lib/libelf++.so.0

Adding

-       @$(CXX) -shared $(LDFLAGS) -o $@ $^ $(LDLIBS)
+       @$(CXX) -shared $(LDFLAGS) -o $@ $^ $(LDLIBS) -Wl,-rpath,/usr/local/lib

fixes the linking issue.

ccurtsinger commented 4 years ago

What distribution and version of Linux are you running? Did you install libelfin-dev with apt, or from source?

jesperpedersen commented 4 years ago

Fedora 30, installed from source. Kernel is Linux version 5.2.17-200.fc30.x86_64 atm

jesperpedersen commented 4 years ago

An idea could be to switch to a cmake build environment using find macros for the libraries, and let cmake handle the relocation paths

miguelraz commented 4 years ago

I had the same issue as @jesperpedersen on both Ubuntu 18 and latest Fedora stable.

ccurtsinger commented 4 years ago

Pull request #140 switches to using pkg-config to generate libelfin flags, which should account for the installation directory. Hopefully that resolves your issue. If not, then there may be some quirk in libelfin's install target.

jesperpedersen commented 4 years ago

While pkg-config --cflags / --libs solves the compile time problem it doesn't the linking issue, as the relocation paths aren't correctly defined. E.g.

-       @$(CXX) -shared $(LDFLAGS) -o $@ $^ $(LDLIBS)
+       @$(CXX) -shared $(LDFLAGS) -o $@ $^ $(LDLIBS) -Wl,-rpath,/usr/local/lib