Statically linking llvm into a library, results in unresolved externals

I’m not really experienced with cmake, but the last few days I tried to figure out, why I can’t build a static library which contains llvm.

I’m trying to build this on windows.

I’ve created a subdirectory, where I link the library project and build a executable, this executable works fine. But as soon as I try to create a separate project, where I link the library I get a lot of “unresolved external symbol” errors.

I don’t really understand why, it works for the internal project but not for the external one and what I can do, so that the symbols will be exported with the library. Especially since the missing symbols seams to be llvm symbols, which I don’t even use directly in my code.

This is my library Cmakelist.txt file:

cmake_minimum_required(VERSION 3.26)

set(namespace "my_lib")
project("MyLibrary"
        VERSION 0.0.1
)

# Create the compile_commands.json (used so the lsp knows which files to use)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 23)

set(MY_PUBLIC_HEADERS
        include/my_lib/Run.h
)

set(MY_SOURCE_FILES
        lib/my_lib/Run.cpp
)

# LLVM
set(Configuration Release)
find_package(LLVM 17 REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})

add_library(${PROJECT_NAME} STATIC)

target_sources(${PROJECT_NAME}
        PRIVATE
        ${MY_SOURCE_FILES}
        ${MY_PUBLIC_HEADERS}
)

target_include_directories(${PROJECT_NAME}
        PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/lib
        PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

llvm_map_components_to_libnames(
        llvm_libs
        ${LLVM_TARGETS_TO_BUILD}
        orcjit
        support
        core
        irreader
        codegen
        mc
        mcparser
        option
)

target_link_libraries(${PROJECT_NAME}
        PRIVATE ${llvm_libs} # Not sure if this should be private or public or idk
)

add_subdirectory(executable)

This is the internal executableCMakeLists.txt file:

set(MY_LIB_BINARY_TARGET_NAME "${PROJECT_NAME}Executable")

add_executable(${MY_LIB_BINARY_TARGET_NAME} main.cpp)

target_link_libraries(${MY_LIB_BINARY_TARGET_NAME}
        PRIVATE ${PROJECT_NAME}
)

This is the external executable CMakeLists.txt file:

cmake_minimum_required(VERSION 3.26)
project(test_my_library)

set(CMAKE_CXX_STANDARD 23)

add_executable(test_my_library main.cpp)

target_include_directories(test_my_library PRIVATE ".../include")

target_link_libraries(test_my_library ".../MyLibrary.lib")

Then I got the public Run.h file:

#ifndef MY_LIB_RUN_H
#define MY_LIB_RUN_H

#include "string"

namespace my_library {
    void run(std::string moduleName, std::string filePath) ;
}

#endif //MY_LIB_RUN_H

and the Run.cpp:

#include <fstream>
#include <filesystem>

#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"

#include "jit/Jit.h"

namespace my_library {
    void run(std::string moduleName, std::string filePath) {
        std::ifstream stream;
        stream.open(filePath);

        // Parse file and so on

        llvm::InitializeNativeTarget();
        llvm::InitializeNativeTargetAsmPrinter();
        llvm::InitializeNativeTargetAsmParser();

        auto jit = cantFail(JIT::Create(), "Error occurred while initializing JIT");
        current_module->setDataLayout(jit->getDataLayout());
        auto resourceTracker = jit->getMainJITDylib().createResourceTracker();
        auto threadSafeModule = llvm::orc::ThreadSafeModule(std::move(current_module),
                                                            std::move(context));
        cantFail(jit->addModule(std::move(threadSafeModule), resourceTracker), "Failed to add module");

        auto mainLookup = jit->lookup("main");
        if (auto err = mainLookup.takeError()) {
            llvm::logAllUnhandledErrors(std::move(err), llvm::errs(), "[JIT Error] ");
            return;
        }

        auto *main = (int (*)()) mainLookup->getAddress().getValue();
        int result = main();

        cantFail(resourceTracker->remove(), "Error removing resource tracker");
    }
}

The errors I get are:

MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol LLVMInitializeX86TargetInfo referenced in function "bool __cdecl llvm::InitializeNativeTarget(void)" (?InitializeNativeTarget@llvm@@YA_NXZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol LLVMInitializeX86Target referenced in function "bool __cdecl llvm::InitializeNativeTarget(void)" (?InitializeNativeTarget@llvm@@YA_NXZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol LLVMInitializeX86TargetMC referenced in function "bool __cdecl llvm::InitializeNativeTarget(void)" (?InitializeNativeTarget@llvm@@YA_NXZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol LLVMInitializeX86AsmPrinter referenced in function "bool __cdecl llvm::InitializeNativeTargetAsmPrinter(void)" (?InitializeNativeTargetAsmPrinter@llvm@@YA_NXZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol LLVMInitializeX86AsmParser referenced in function "bool __cdecl llvm::InitializeNativeTargetAsmParser(void)" (?InitializeNativeTargetAsmParser@llvm@@YA_NXZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "protected: void __cdecl llvm::SmallVectorBase<unsigned int>::grow_pod(void *,unsigned __int64,unsigned __int64)" (?grow_pod@?$SmallVectorBase@I@llvm@@IEAAXPEAX_K1@Z) referenced in function "public: class llvm::SmallVector<unsigned int,8> & __cdecl llvm::SmallVector<unsigned int,8>::operator=(class llvm::SmallVector<unsigned int,8> const &)" (??4?$SmallVector@I$07@llvm@@QEAAAEAV01@AEBV01@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "protected: void __cdecl llvm::SmallVectorBase<unsigned __int64>::grow_pod(void *,unsigned __int64,unsigned __int64)" (?grow_pod@?$SmallVectorBase@_K@llvm@@IEAAXPEAX_K1@Z) referenced in function "public: class llvm::SmallVector<unsigned char,8> & __cdecl llvm::SmallVector<unsigned char,8>::operator=(class llvm::SmallVector<unsigned char,8> const &)" (??4?$SmallVector@E$07@llvm@@QEAAAEAV01@AEBV01@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: virtual __cdecl llvm::raw_ostream::~raw_ostream(void)" (??1raw_ostream@llvm@@UEAA@XZ) referenced in function "int `public: __cdecl llvm::raw_string_ostream::raw_string_ostream(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)'::`1'::dtor$0" (?dtor$0@?0???0raw_string_ostream@llvm@@QEAA@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z@4HA)
MyLibrary.lib(Run.cpp.obj) : error LNK2001: unresolved external symbol "public: virtual class llvm::raw_ostream & __cdecl llvm::raw_ostream::changeColor(enum llvm::raw_ostream::Colors,bool,bool)" (?changeColor@raw_ostream@llvm@@UEAAAEAV12@W4Colors@12@_N1@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2001: unresolved external symbol "public: virtual class llvm::raw_ostream & __cdecl llvm::raw_ostream::resetColor(void)" (?resetColor@raw_ostream@llvm@@UEAAAEAV12@XZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2001: unresolved external symbol "public: virtual class llvm::raw_ostream & __cdecl llvm::raw_ostream::reverseColor(void)" (?reverseColor@raw_ostream@llvm@@UEAAAEAV12@XZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2001: unresolved external symbol "protected: virtual unsigned __int64 __cdecl llvm::raw_ostream::preferred_buffer_size(void)const " (?preferred_buffer_size@raw_ostream@llvm@@MEBA_KXZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "private: void __cdecl llvm::raw_ostream::SetBufferAndMode(char *,unsigned __int64,enum llvm::raw_ostream::BufferKind)" (?SetBufferAndMode@raw_ostream@llvm@@AEAAXPEAD_KW4BufferKind@12@@Z) referenced in function "public: __cdecl llvm::raw_string_ostream::raw_string_ostream(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??0raw_string_ostream@llvm@@QEAA@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "private: void __cdecl llvm::raw_ostream::flush_nonempty(void)" (?flush_nonempty@raw_ostream@llvm@@AEAAXXZ) referenced in function "public: void __cdecl llvm::raw_ostream::SetUnbuffered(void)" (?SetUnbuffered@raw_ostream@llvm@@QEAAXXZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2001: unresolved external symbol "private: virtual void __cdecl llvm::raw_ostream::anchor(void)" (?anchor@raw_ostream@llvm@@EEAAXXZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "class llvm::raw_fd_ostream & __cdecl llvm::errs(void)" (?errs@llvm@@YAAEAVraw_fd_ostream@1@XZ) referenced in function "void __cdecl my_library::run(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?run@my_library@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2001: unresolved external symbol "private: virtual void __cdecl llvm::raw_string_ostream::write_impl(char const *,unsigned __int64)" (?write_impl@raw_string_ostream@llvm@@EEAAXPEBD_K@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::LLVMContext::~LLVMContext(void)" (??1LLVMContext@llvm@@QEAA@XZ) referenced in function "void __cdecl std::_Destroy_in_place<struct llvm::orc::ThreadSafeContext::State>(struct llvm::orc::ThreadSafeContext::State &)" (??$_Destroy_in_place@UState@ThreadSafeContext@orc@llvm@@@std@@YAXAEAUState@ThreadSafeContext@orc@llvm@@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "void __cdecl llvm::deallocate_buffer(void *,unsigned __int64,unsigned __int64)" (?deallocate_buffer@llvm@@YAXPEAX_K1@Z) referenced in function "protected: __cdecl llvm::detail::UniqueFunctionBase<class std::unique_ptr<class llvm::RuntimeDyld::MemoryManager,struct std::default_delete<class llvm::RuntimeDyld::MemoryManager> > >::~UniqueFunctionBase<class std::unique_ptr<class llvm::RuntimeDyld::MemoryManager,struct std::default_delete<class llvm::RuntimeDyld::MemoryManager> > >(void)" (??1?$UniqueFunctionBase@V?$unique_ptr@VMemoryManager@RuntimeDyld@llvm@@U?$default_delete@VMemoryManager@RuntimeDyld@llvm@@@std@@@std@@$$V@detail@llvm@@IEAA@XZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "private: void __cdecl llvm::DataLayout::clear(void)" (?clear@DataLayout@llvm@@AEAAXXZ) referenced in function "public: class llvm::DataLayout & __cdecl llvm::DataLayout::operator=(class llvm::DataLayout const &)" (??4DataLayout@llvm@@QEAAAEAV01@AEBV01@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::DataLayout::~DataLayout(void)" (??1DataLayout@llvm@@QEAA@XZ) referenced in function "class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > __cdecl llvm::cantFail<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >(class llvm::Expected<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >,char const *)" (??$cantFail@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@llvm@@YA?AV?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@V?$Expected@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@0@PEBD@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::Module::~Module(void)" (??1Module@llvm@@QEAA@XZ) referenced in function "public: __cdecl llvm::orc::ThreadSafeModule::ThreadSafeModule(class std::unique_ptr<class llvm::Module,struct std::default_delete<class llvm::Module> >,class std::unique_ptr<class llvm::LLVMContext,struct std::default_delete<class llvm::LLVMContext> >)" (??0ThreadSafeModule@orc@llvm@@QEAA@V?$unique_ptr@VModule@llvm@@U?$default_delete@VModule@llvm@@@std@@@std@@V?$unique_ptr@VLLVMContext@llvm@@U?$default_delete@VLLVMContext@llvm@@@std@@@4@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: void __cdecl llvm::Module::setDataLayout(class llvm::DataLayout const &)" (?setDataLayout@Module@llvm@@QEAAXAEBVDataLayout@2@@Z) referenced in function "void __cdecl my_library::run(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?run@my_library@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: void __cdecl llvm::Module::print(class llvm::raw_ostream &,class llvm::AssemblyAnnotationWriter *,bool,bool)const " (?print@Module@llvm@@QEBAXAEAVraw_ostream@2@PEAVAssemblyAnnotationWriter@2@_N2@Z) referenced in function "class llvm::raw_ostream & __cdecl llvm::operator<<(class llvm::raw_ostream &,class llvm::Module const &)" (??6llvm@@YAAEAVraw_ostream@0@AEAV10@AEBVModule@0@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "void __cdecl llvm::logAllUnhandledErrors(class llvm::Error,class llvm::raw_ostream &,class llvm::Twine)" (?logAllUnhandledErrors@llvm@@YAXVError@1@AEAVraw_ostream@1@VTwine@1@@Z) referenced in function "void __cdecl my_library::run(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?run@my_library@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: static class llvm::Expected<class std::unique_ptr<class llvm::orc::SelfExecutorProcessControl,struct std::default_delete<class llvm::orc::SelfExecutorProcessControl> > > __cdecl llvm::orc::SelfExecutorProcessControl::Create(class std::shared_ptr<class llvm::orc::SymbolStringPool>,class std::unique_ptr<class llvm::orc::TaskDispatcher,struct std::default_delete<class llvm::orc::TaskDispatcher> >,class std::unique_ptr<class llvm::jitlink::JITLinkMemoryManager,struct std::default_delete<class llvm::jitlink::JITLinkMemoryManager> >)" (?Create@SelfExecutorProcessControl@orc@llvm@@SA?AV?$Expected@V?$unique_ptr@VSelfExecutorProcessControl@orc@llvm@@U?$default_delete@VSelfExecutorProcessControl@orc@llvm@@@std@@@std@@@3@V?$shared_ptr@VSymbolStringPool@orc@llvm@@@std@@V?$unique_ptr@VTaskDispatcher@orc@llvm@@U?$default_delete@VTaskDispatcher@orc@llvm@@@std@@@6@V?$unique_ptr@VJITLinkMemoryManager@jitlink@llvm@@U?$default_delete@VJITLinkMemoryManager@jitlink@llvm@@@std@@@6@@Z) referenced in function "public: static class llvm::Expected<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > > __cdecl my_library::JIT::Create(void)" (?Create@JIT@my_library@@SA?AV?$Expected@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@llvm@@XZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::orc::ResourceTracker::~ResourceTracker(void)" (??1ResourceTracker@orc@llvm@@QEAA@XZ) referenced in function "public: __cdecl llvm::IntrusiveRefCntPtr<class llvm::orc::ResourceTracker>::~IntrusiveRefCntPtr<class llvm::orc::ResourceTracker>(void)" (??1?$IntrusiveRefCntPtr@VResourceTracker@orc@llvm@@@llvm@@QEAA@XZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: class llvm::Error __cdecl llvm::orc::ResourceTracker::remove(void)" (?remove@ResourceTracker@orc@llvm@@QEAA?AVError@3@XZ) referenced in function "void __cdecl my_library::run(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?run@my_library@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: class llvm::IntrusiveRefCntPtr<class llvm::orc::ResourceTracker> __cdecl llvm::orc::JITDylib::getDefaultResourceTracker(void)" (?getDefaultResourceTracker@JITDylib@orc@llvm@@QEAA?AV?$IntrusiveRefCntPtr@VResourceTracker@orc@llvm@@@3@XZ) referenced in function "public: class llvm::Error __cdecl my_library::JIT::addModule(class llvm::orc::ThreadSafeModule,class llvm::IntrusiveRefCntPtr<class llvm::orc::ResourceTracker>)" (?addModule@JIT@my_library@@QEAA?AVError@llvm@@VThreadSafeModule@orc@4@V?$IntrusiveRefCntPtr@VResourceTracker@orc@llvm@@@4@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: class llvm::IntrusiveRefCntPtr<class llvm::orc::ResourceTracker> __cdecl llvm::orc::JITDylib::createResourceTracker(void)" (?createResourceTracker@JITDylib@orc@llvm@@QEAA?AV?$IntrusiveRefCntPtr@VResourceTracker@orc@llvm@@@3@XZ) referenced in function "void __cdecl my_library::run(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?run@my_library@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::orc::ExecutionSession::ExecutionSession(class std::unique_ptr<class llvm::orc::ExecutorProcessControl,struct std::default_delete<class llvm::orc::ExecutorProcessControl> >)" (??0ExecutionSession@orc@llvm@@QEAA@V?$unique_ptr@VExecutorProcessControl@orc@llvm@@U?$default_delete@VExecutorProcessControl@orc@llvm@@@std@@@std@@@Z) referenced in function "class std::unique_ptr<class llvm::orc::ExecutionSession,struct std::default_delete<class llvm::orc::ExecutionSession> > __cdecl std::make_unique<class llvm::orc::ExecutionSession,class std::unique_ptr<class llvm::orc::SelfExecutorProcessControl,struct std::default_delete<class llvm::orc::SelfExecutorProcessControl> >,0>(class std::unique_ptr<class llvm::orc::SelfExecutorProcessControl,struct std::default_delete<class llvm::orc::SelfExecutorProcessControl> > &&)" (??$make_unique@VExecutionSession@orc@llvm@@V?$unique_ptr@VSelfExecutorProcessControl@orc@llvm@@U?$default_delete@VSelfExecutorProcessControl@orc@llvm@@@std@@@std@@$0A@@std@@YA?AV?$unique_ptr@VExecutionSession@orc@llvm@@U?$default_delete@VExecutionSession@orc@llvm@@@std@@@0@$$QEAV?$unique_ptr@VSelfExecutorProcessControl@orc@llvm@@U?$default_delete@VSelfExecutorProcessControl@orc@llvm@@@std@@@0@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::orc::ExecutionSession::~ExecutionSession(void)" (??1ExecutionSession@orc@llvm@@QEAA@XZ) referenced in function "class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > __cdecl llvm::cantFail<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >(class llvm::Expected<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >,char const *)" (??$cantFail@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@llvm@@YA?AV?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@V?$Expected@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@0@PEBD@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: class llvm::Error __cdecl llvm::orc::ExecutionSession::endSession(void)" (?endSession@ExecutionSession@orc@llvm@@QEAA?AVError@3@XZ) referenced in function "class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > __cdecl llvm::cantFail<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >(class llvm::Expected<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >,char const *)" (??$cantFail@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@llvm@@YA?AV?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@V?$Expected@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@0@PEBD@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: class llvm::orc::JITDylib & __cdecl llvm::orc::ExecutionSession::createBareJITDylib(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?createBareJITDylib@ExecutionSession@orc@llvm@@QEAAAEAVJITDylib@23@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __cdecl my_library::JIT::JIT(class std::unique_ptr<class llvm::orc::ExecutionSession,struct std::default_delete<class llvm::orc::ExecutionSession> >,class llvm::orc::JITTargetMachineBuilder,class llvm::DataLayout)" (??0JIT@my_library@@QEAA@V?$unique_ptr@VExecutionSession@orc@llvm@@U?$default_delete@VExecutionSession@orc@llvm@@@std@@@std@@VJITTargetMachineBuilder@orc@llvm@@VDataLayout@6@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: class llvm::Expected<class llvm::orc::ExecutorSymbolDef> __cdecl llvm::orc::ExecutionSession::lookup(class llvm::ArrayRef<class llvm::orc::JITDylib *>,class llvm::StringRef,enum llvm::orc::SymbolState)" (?lookup@ExecutionSession@orc@llvm@@QEAA?AV?$Expected@VExecutorSymbolDef@orc@llvm@@@3@V?$ArrayRef@PEAVJITDylib@orc@llvm@@@3@VStringRef@3@W4SymbolState@23@@Z) referenced in function "public: class llvm::Expected<class llvm::orc::ExecutorSymbolDef> __cdecl my_library::JIT::lookup(class llvm::StringRef)" (?lookup@JIT@my_library@@QEAA?AV?$Expected@VExecutorSymbolDef@orc@llvm@@@llvm@@VStringRef@4@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::orc::MangleAndInterner::MangleAndInterner(class llvm::orc::ExecutionSession &,class llvm::DataLayout const &)" (??0MangleAndInterner@orc@llvm@@QEAA@AEAVExecutionSession@12@AEBVDataLayout@2@@Z) referenced in function "public: __cdecl my_library::JIT::JIT(class std::unique_ptr<class llvm::orc::ExecutionSession,struct std::default_delete<class llvm::orc::ExecutionSession> >,class llvm::orc::JITTargetMachineBuilder,class llvm::DataLayout)" (??0JIT@my_library@@QEAA@V?$unique_ptr@VExecutionSession@orc@llvm@@U?$default_delete@VExecutionSession@orc@llvm@@@std@@@std@@VJITTargetMachineBuilder@orc@llvm@@VDataLayout@6@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: virtual __cdecl llvm::orc::IRLayer::~IRLayer(void)" (??1IRLayer@orc@llvm@@UEAA@XZ) referenced in function "class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > __cdecl llvm::cantFail<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >(class llvm::Expected<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >,char const *)" (??$cantFail@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@llvm@@YA?AV?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@V?$Expected@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@0@PEBD@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::orc::IRCompileLayer::IRCompileLayer(class llvm::orc::ExecutionSession &,class llvm::orc::ObjectLayer &,class std::unique_ptr<class llvm::orc::IRCompileLayer::IRCompiler,struct std::default_delete<class llvm::orc::IRCompileLayer::IRCompiler> >)" (??0IRCompileLayer@orc@llvm@@QEAA@AEAVExecutionSession@12@AEAVObjectLayer@12@V?$unique_ptr@VIRCompiler@IRCompileLayer@orc@llvm@@U?$default_delete@VIRCompiler@IRCompileLayer@orc@llvm@@@std@@@std@@@Z) referenced in function "public: __cdecl my_library::JIT::JIT(class std::unique_ptr<class llvm::orc::ExecutionSession,struct std::default_delete<class llvm::orc::ExecutionSession> >,class llvm::orc::JITTargetMachineBuilder,class llvm::DataLayout)" (??0JIT@my_library@@QEAA@V?$unique_ptr@VExecutionSession@orc@llvm@@U?$default_delete@VExecutionSession@orc@llvm@@@std@@@std@@VJITTargetMachineBuilder@orc@llvm@@VDataLayout@6@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::orc::JITTargetMachineBuilder::JITTargetMachineBuilder(class llvm::Triple)" (??0JITTargetMachineBuilder@orc@llvm@@QEAA@VTriple@2@@Z) referenced in function "public: static class llvm::Expected<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > > __cdecl my_library::JIT::Create(void)" (?Create@JIT@my_library@@SA?AV?$Expected@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@llvm@@XZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: class llvm::Expected<class std::unique_ptr<class llvm::TargetMachine,struct std::default_delete<class llvm::TargetMachine> > > __cdecl llvm::orc::JITTargetMachineBuilder::createTargetMachine(void)" (?createTargetMachine@JITTargetMachineBuilder@orc@llvm@@QEAA?AV?$Expected@V?$unique_ptr@VTargetMachine@llvm@@U?$default_delete@VTargetMachine@llvm@@@std@@@std@@@3@XZ) referenced in function "public: class llvm::Expected<class llvm::DataLayout> __cdecl llvm::orc::JITTargetMachineBuilder::getDefaultDataLayoutForTarget(void)" (?getDefaultDataLayoutForTarget@JITTargetMachineBuilder@orc@llvm@@QEAA?AV?$Expected@VDataLayout@llvm@@@3@XZ)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::orc::ConcurrentIRCompiler::ConcurrentIRCompiler(class llvm::orc::JITTargetMachineBuilder,class llvm::ObjectCache *)" (??0ConcurrentIRCompiler@orc@llvm@@QEAA@VJITTargetMachineBuilder@12@PEAVObjectCache@2@@Z) referenced in function "class std::unique_ptr<class llvm::orc::ConcurrentIRCompiler,struct std::default_delete<class llvm::orc::ConcurrentIRCompiler> > __cdecl std::make_unique<class llvm::orc::ConcurrentIRCompiler,class llvm::orc::JITTargetMachineBuilder,0>(class llvm::orc::JITTargetMachineBuilder &&)" (??$make_unique@VConcurrentIRCompiler@orc@llvm@@VJITTargetMachineBuilder@23@$0A@@std@@YA?AV?$unique_ptr@VConcurrentIRCompiler@orc@llvm@@U?$default_delete@VConcurrentIRCompiler@orc@llvm@@@std@@@0@$$QEAVJITTargetMachineBuilder@orc@llvm@@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: static class llvm::Expected<class std::unique_ptr<class llvm::orc::DynamicLibrarySearchGenerator,struct std::default_delete<class llvm::orc::DynamicLibrarySearchGenerator> > > __cdecl llvm::orc::DynamicLibrarySearchGenerator::Load(char const *,char,class std::function<bool __cdecl(class llvm::orc::SymbolStringPtr const &)>)" (?Load@DynamicLibrarySearchGenerator@orc@llvm@@SA?AV?$Expected@V?$unique_ptr@VDynamicLibrarySearchGenerator@orc@llvm@@U?$default_delete@VDynamicLibrarySearchGenerator@orc@llvm@@@std@@@std@@@3@PEBDDV?$function@$$A6A_NAEBVSymbolStringPtr@orc@llvm@@@Z@std@@@Z) referenced in function "public: __cdecl my_library::JIT::JIT(class std::unique_ptr<class llvm::orc::ExecutionSession,struct std::default_delete<class llvm::orc::ExecutionSession> >,class llvm::orc::JITTargetMachineBuilder,class llvm::DataLayout)" (??0JIT@my_library@@QEAA@V?$unique_ptr@VExecutionSession@orc@llvm@@U?$default_delete@VExecutionSession@orc@llvm@@@std@@@std@@VJITTargetMachineBuilder@orc@llvm@@VDataLayout@6@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::orc::RTDyldObjectLinkingLayer::RTDyldObjectLinkingLayer(class llvm::orc::ExecutionSession &,class llvm::unique_function<class std::unique_ptr<class llvm::RuntimeDyld::MemoryManager,struct std::default_delete<class llvm::RuntimeDyld::MemoryManager> > __cdecl(void)>)" (??0RTDyldObjectLinkingLayer@orc@llvm@@QEAA@AEAVExecutionSession@12@V?$unique_function@$$A6A?AV?$unique_ptr@VMemoryManager@RuntimeDyld@llvm@@U?$default_delete@VMemoryManager@RuntimeDyld@llvm@@@std@@@std@@XZ@2@@Z) referenced in function "public: __cdecl my_library::JIT::JIT(class std::unique_ptr<class llvm::orc::ExecutionSession,struct std::default_delete<class llvm::orc::ExecutionSession> >,class llvm::orc::JITTargetMachineBuilder,class llvm::DataLayout)" (??0JIT@my_library@@QEAA@V?$unique_ptr@VExecutionSession@orc@llvm@@U?$default_delete@VExecutionSession@orc@llvm@@@std@@@std@@VJITTargetMachineBuilder@orc@llvm@@VDataLayout@6@@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: virtual __cdecl llvm::orc::RTDyldObjectLinkingLayer::~RTDyldObjectLinkingLayer(void)" (??1RTDyldObjectLinkingLayer@orc@llvm@@UEAA@XZ) referenced in function "class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > __cdecl llvm::cantFail<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >(class llvm::Expected<class std::unique_ptr<class my_library::JIT,struct std::default_delete<class my_library::JIT> > >,char const *)" (??$cantFail@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@llvm@@YA?AV?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@V?$Expected@V?$unique_ptr@VJIT@my_library@@U?$default_delete@VJIT@my_library@@@std@@@std@@@0@PEBD@Z)
MyLibrary.lib(Run.cpp.obj) : error LNK2019: unresolved external symbol "public: __cdecl llvm::SectionMemoryManager::SectionMemoryManager(class llvm::SectionMemoryManager::MemoryMapper *)" (??0SectionMemoryManager@llvm@@QEAA@PEAVMemoryMapper@01@@Z) referenced in function "protected: static class std::unique_ptr<class llvm::RuntimeDyld::MemoryManager,struct std::default_delete<class llvm::RuntimeDyld::MemoryManager> > __cdecl llvm::detail::UniqueFunctionBase<class std::unique_ptr<class llvm::RuntimeDyld::MemoryManager,struct std::default_delete<class llvm::RuntimeDyld::MemoryManager> > >::CallImpl<class `public: __cdecl my_library::JIT::JIT(class std::unique_ptr<class llvm::orc::ExecutionSession,struct std::default_delete<class llvm::orc::ExecutionSession> >,class llvm::orc::JITTargetMachineBuilder,class llvm::DataLayout)'::`1'::<lambda_6_> >(void *)" (??$CallImpl@V<lambda_6_>@?0???0JIT@my_library@@QEAA@V?$unique_ptr@VExecutionSession@orc@llvm@@U?$default_delete@VExecutionSession@orc@llvm@@@std@@@std@@VJITTargetMachineBuilder@orc@llvm@@VDataLayout@8@@Z@@?$UniqueFunctionBase@V?$unique_ptr@VMemoryManager@RuntimeDyld@llvm@@U?$default_delete@VMemoryManager@RuntimeDyld@llvm@@@std@@@std@@$$V@detail@llvm@@KA?AV?$unique_ptr@VMemoryManager@RuntimeDyld@llvm@@U?$default_delete@VMemoryManager@RuntimeDyld@llvm@@@std@@@std@@PEAX@Z)

I get similar errors for some other files as well.

Maybe someone got some pointers, where to start and/or how to solve this issue?
As far as I understand, the .lib file contains some .obj files, which will reference this symbols? Also I would assume that the functions/objects I’m using internally use the symbols missing?
Why are the symbols even missing and how could I tell cmake to include them?