[LLVMdev] Invalid bitcode signature

Bill Wendling bwendling at apple.com
Fri Feb 3 16:12:24 PST 2012

On Feb 3, 2012, at 1:47 PM, Fraser Cormack wrote:

> I'm trying to link two modules together using the C++ API, one that's a sort
> of library module and one that's being generated from the source language.
> If I have something like this:
> OwningPtr<MemoryBuffer> owning_ptr;
> if (MemoryBuffer::getFile(StringRef("../hello.bc"), owning_ptr))
>    std::cout << "error opening file" << std::endl;
> Module* Lib = ParseBitcodeFile(owning_ptr.get(), context, &error);
> if (!Lib)
>    std::cout << error << std::endl;
> When I run this (either on a bitcode file generated by llvm-gcc or by
> createBitcodeWriterPass()) I get an error telling me: "invalid bitcode
> signature".
> I'm not sure where this error's coming from. Any help would be appreciated.
The error is coming from the bit-code reader. Make sure that you generated the file with '-emit-llvm' (i.e., it's not an object file) and that it's the binary version of the bit-code file, not the text version.

And, llvm-gcc? really? :-)


More information about the llvm-dev mailing list