When linking to libdyinst on Ubuntu (12.04 64-bit), the BPatch constructor is not found, and the destructor has unresolved symbols:
bash$ g++ -Wall -I/usr/include/dyninst -L/usr/lib -ldyninstAPI -lcommon dyninst_test.cpp /tmp/ccfx3YrL.o: In function `__static_initialization_and_destruction_0(int, int)': dyninst_test.cpp:(.text+0x56): undefined reference to `BPatch::BPatch()' /tmp/ccfx3YrL.o: In function `BPatch::~BPatch()': dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0x2a): undefined reference to `BPatch_eventLock::_Lock(char const*, unsigned int) const' dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0x36): undefined reference to `BPatch_eventLock::lockDepth() const' dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0x5e): undefined reference to `bpatch_printf(char const*, ...)' dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0x6a): undefined reference to `BPatch::BPatch_dtor()' dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0x76): undefined reference to `BPatch_eventLock::lockDepth() const' dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0x99): undefined reference to `bpatch_printf(char const*, ...)' dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0xaf): undefined reference to `BPatch_eventLock::_Unlock(char const*, unsigned int) const' dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0xdf): undefined reference to `BPatch_eventLock::~BPatch_eventLock()' dyninst_test.cpp:(.text._ZN6BPatchD2Ev[_ZN6BPatchD5Ev]+0x136): undefined reference to `BPatch_eventLock::~BPatch_eventLock()' /tmp/cc0U63aL.o:(.rodata._ZTI6BPatch[typeinfo for BPatch]+0x10): undefined reference to `typeinfo for BPatch_eventLock' collect2: ld returned 1 exit status Reviewing the symbols in libdyninstAPI.so shows that these symbols are indeed missing: bash$ nm /usr/lib/libdyninstAPI.so | grep -e 'BPatch[0-9]\+BPatch' 00000000000f0790 T _ZN6BPatch11BPatch_dtorEv bash$ nm /usr/lib/libdyninstAPI.so | grep -e 'BPatch[0-9]\+bpatch_printf' bash$ The same error happens with the Ubuntu .deb packages from http://www.dyninst.org/downloads/dyninst-8.0, and with a build from the source code tarball from the same place. The source code tarball is configured with: ./configure --prefix=/usr/local/dyninst --disable-testsuite --enable-gnu-demangler --with-libdwarf-static ...although it should be noted that the same error happened without the "--enable-gnu-demangler" flag. The '--with-libdwarf-static' flag is necessary to fix the following error when linking to libdwarf on a 64-bit system "relocation R_X86_64_32S against `.rodata' can not be used when making a shared object" Given that this happens both with the .deb files and a build from the tarball, it seems to be a problem with the Ubuntu build (possibly on 64-bit systems) -- or else I am doing something fundamentally wrong when trying to compile against it. Has anyone successfully linked to dyninst 8.0 on a 64-bit Ubuntu 12.04 (or greater) system, and if so, how? System info: bash$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 12.04.2 LTS Release: 12.04 Codename: precise bash$ uname -a Linux glider 3.5.0-18-generic #29-Ubuntu SMP Thu Oct 25 07:26:14 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux bash$ g++ --version g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. bash$ ldd --version ldd (Ubuntu EGLIBC 2.15-0ubuntu10.3) 2.15 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper. The test code, cat dyninst_test.cpp, is as follows: bash$ cat dyninst_test.cpp using namespace std; // no such namespace: //using namespace Dyninst; #include "BPatch.h" BPatch bpatch; int main(int argc, char ** argv) { // this doesn't work either: //BPatch * bpatch = new BPatch(); //if (!bpatch) return -1; return 0; } _______________________________________________ Dyninst-api mailing list [email protected] https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
