[LLVMdev] LLVM Hello Pass load error when using opt -load Hello.so

Chuck Zhao czhao at eecg.toronto.edu
Fri Jul 17 08:48:57 PDT 2009

While learning to write LLVM passes and following the precise 
instructions under http://llvm.org/docs/WritingAnLLVMPass.html, 
I got this error when loading the hello pass to run the test program:

opt -load ./Release/lib/Hello.so -hello < test/test.bc > /dev/null
Error opening './Release/lib/Hello.so': ./Release/lib/Hello.so: 
undefined symbol: 
  -load request ignored.
  opt: Unknown command line argument '-hello'.  Try: 'opt --help'
  make: *** [run_lib] Error 1

I think I might have missed a LLVM lib file, but can't figure out which.

I double checked the Makefile, it does have the libLLVMCore.a, 
libLLVMSystem.a and libLLVMSupport.a specified.

Could people suggest?

All are based on the LLVM  2.5 release, running on Debian4-i386.

Thank you very much


Hello.cpp file:
#include "llvm/Pass.h"
#include "llvm/Function.h"

using namespace llvm;

namespace {
  struct Hello : public FunctionPass {
    static char ID;
    Hello() : FunctionPass(&ID) {}

    virtual bool runOnFunction(Function &F) {
      llvm::cerr << "Hello: " << F.getName() << "\n";
      return false;
  char Hello::ID = 0;
  RegisterPass<Hello> X("hello", "Hello World Pass");

# Makefile for hello pass

# Path to top level of LLVM heirarchy

# Name of the library to build

# Make the shared library become a loadable module so the tools can
# dlopen/dlsym on the resulting library.

# Tell the build system which LLVM libraries your pass needs. You'll 
# need at least LLVMSystem.a, LLVMSupport.a, LLVMCore.a but possibly several
# others too.
LLVMLIBS = LLVMCore.a LLVMSupport.a LLVMSystem.a

# Include the makefile implementation stuff
include $(LEVEL)/Makefile.common

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090717/28c1bd3c/attachment.html>

More information about the llvm-dev mailing list