undefined reference to extern variables

Hi All,

I defined some variables in tools/clang/lib/Frontend/CompilerInstance.cpp. Then I tried to refer these variables in lib/Bitcode/Writer/BitCodeWriter.cpp with extern keyword.

'make' reports errors while linking opt. (error: undefined reference to "var_name"). I think I need modify some Makefiles to figure out that opt is depended on Frontend.

But I have no idea about how to modify. Any suggestion?

Thanks,
Haopeng

From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu] On
Behalf Of Haopeng Liu
Sent: Saturday, July 11, 2015 8:24 PM
To: LLVM Developers Mailing List
Subject: [LLVMdev] undefined reference to extern variables

Hi All,

I defined some variables in
tools/clang/lib/Frontend/CompilerInstance.cpp. Then I tried to refer
these variables in lib/Bitcode/Writer/BitCodeWriter.cpp with extern
keyword.

Clang is layered on top of LLVM. You cannot make LLVM depend on Clang
in this way. You will need to find some other way to pass data from
Clang to LLVM. Common tactics include defining "backend" options using
the cl::opt mechanism, and you pass command-line strings from Clang to
LLVM; or add new fields in an existing structure that Clang already
passes to LLVM.
--paulr