'How to use llvm target initialize function

My Host System

: Default target: x86_64-unknown-linux-gnu

: Host CPU: skylake

LLVM/Clang built with LLVM_TARGETS_TO_BUILD=all option.

How to Use another target's Initialize Function in My code?

I modifying klee (symbolic execution tool) to run cross-platform Target's IR.

#include "llvm/Support/TargetSelect.h"

int main () {
    ...
    // llvm::InitializeAllTargets(); -> Error    
    llvm::InitializeNativeTargets(); -> Success
    ...
}

In this case, error

${LLVM}/build/include/llvm/Config/Targets.def:28: undefined reference to `LLVMInitializeARMTargetInfo'
${LLVM}/build/include/llvm/Config/Targets.def:29: undefined reference to `LLVMInitializeBPFTargetInfo'
...


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source