Search code examples
c++linuxg++intel-pin

Compiling PIN tool with dependencies


As the title states, I am looking for a way to make compile my PIN tool with some dependencies. So for example if I #include "somefile.h" in my PIN tool, and generate some object file g++ -c somefile.cpp, how do I link my object file to compile with my PIN tool so I can use it's functionality in my PIN tool?


Solution

  • So I was able to find some documentation on altering the "makefile.rules" under PIN's website here. For my situation these 6 lines below would be added to the end of "makefile.rules".

    $(OBJDIR)"somefile"$(OBJ_SUFFIX): "somefile".cpp "somefile".h
        $(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
    
    $(OBJDIR)"PinFile"$(OBJ_SUFFIX): "pin_tool".cpp
        $(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
    
    $(OBJDIR)"pin_tool"$(PINTOOL_SUFFIX): $(OBJDIR)"somefile"$(OBJ_SUFFIX) $(OBJDIR)"PinFile"$(OBJ_SUFFIX) "somefile".h
        $(LINKER) $(TOOL_LDFLAGS_NOOPT) $(LINK_EXE)$@ $(^:%.h=) $(TOOL_LPATHS) $(TOOL_LIBS)
    

    The only thing that would change from one make file to another would be the words I put in quotes. Note that the quoted words should not have quotes around them in the actual "makefile.rules"