Re: [DynInst_API:] Compiling CFGTool using Dyninst Libarary in Ubuntu 16.04


Date: Fri, 10 Feb 2017 13:09:46 -0500
From: Sazzadur Rahaman <sazzad14@xxxxxx>
Subject: Re: [DynInst_API:] Compiling CFGTool using Dyninst Libarary in Ubuntu 16.04
Hi Elsabagh,

Thank you very much! With your suggestions, It works now!

Best Regards,
Sazzadur Rahaman

On Fri, Feb 10, 2017 at 1:06 PM, Mohamed Elsabagh <melsabag@xxxxxxx> wrote:
I think the Makefile for the CFGTool is outdated. It's missing the instructionAPI library. Also GCC (POSIX?) searches libraries in the same order their names are encountered in the g++ command. If the Dyninst libraries are placed *before* CFG.cpp, GCC will search the libraries *before* it resolves any symbols in CFG.cpp, and therefore the compiled CFG object will fail to link to link with Dyninst. I am quoting the following from "https://linux.die.net/man/1/g++":

"It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded."

The following works:Â
g++ -g -O2 -std=gnu++11 -I/usr/local/include -L/usr/local/lib CFG.cpp -o CFG -lparseAPI -linstructionAPI -lsymtabAPI -ldynDwarf -ldynElfÂ-lelf -lcommon -ldwarf


Mohamed

On Fri, Feb 10, 2017 at 6:59 AM Sazzadur Rahaman <sazzad14@xxxxxx> wrote:
Hi All,

I cloned the current Dyninst project (commit id 86d44d2ccdd94506751a71e83f92f6a665c2eba5) in Ubuntu 16.04 and successfully installed it. Then I was trying to build CFGTool (http://www.paradyn.org/html/tools/CFGTool.html) but failed to do so.

Error Message:
g++ -g -O2 -std=gnu++11 -I/usr/local/include -L/usr/local/lib -lparseAPI -lsymtabAPI -lelf -ldynDwarf -ldwarf -lelf -ldynElf -lcommon CFG.cpp -o CFG
/tmp/ccAL926i.o: In function `PrintBlockInfo(Dyninst::ParseAPI::Block*)':
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:82: undefined reference to `Dyninst::InstructionAPI::InstructionDecoder::InstructionDecoder(unsigned char const*, unsigned long, Dyninst::Architecture)'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:88: undefined reference to `Dyninst::InstructionAPI::Instruction::format(unsigned long) const'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:89: undefined reference to `Dyninst::InstructionAPI::Instruction::size() const'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:87: undefined reference to `Dyninst::InstructionAPI::InstructionDecoder::decode()'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:90: undefined reference to `Dyninst::InstructionAPI::InstructionDecoder::~InstructionDecoder()'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:90: undefined reference to `Dyninst::InstructionAPI::InstructionDecoder::~InstructionDecoder()'
/tmp/ccAL926i.o: In function `main':
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:111: undefined reference to `Dyninst::ParseAPI::SymtabCodeSource::SymtabCodeSource(char*)'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:112: undefined reference to `Dyninst::ParseAPI::CodeObject::CodeObject(Dyninst::ParseAPI::CodeSource*, Dyninst::ParseAPI::CFGFactory*, Dyninst::ParseAPI::ParseCallback*, bool)'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:115: undefined reference to `Dyninst::ParseAPI::CodeObject::parse()'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:120: undefined reference to `Dyninst::ParseAPI::Function::blocks()'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:120: undefined reference to `Dyninst::ParseAPI::Function::blocks()'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:149: undefined reference to `Dyninst::ParseAPI::Function::blocks()'
/home/krishnokoli/dyninst-tools/CFGTool/CFG.cpp:150: undefined reference to `Dyninst::ParseAPI::Function::blocks()'
collect2: error: ld returned 1 exit status
Makefile:7: recipe for target 'CFG' failed
make: *** [CFG] Error 1

My make File:

CFLAGS = -g -O2 -std=gnu++11
INC = -I/usr/local/include
LIB = -L/usr/local/lib
DEP = -lparseAPI -lsymtabAPI -lelf -ldynDwarf -ldwarf -lelf -ldynElf -lcommon

CFG: CFG.cpp
ÂÂÂÂÂ g++ $(CFLAGS) $(INC) $(LIB) $(DEP) CFG.cpp -o CFG

My g++ version:

g++ (Ubuntu 4.8.5-4ubuntu2) 4.8.5
Copyright (C) 2015 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.

Thanks in advance!

Best Regards,
Sazzadur Rahaman

_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api

[← Prev in Thread] Current Thread [Next in Thread→]