<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55152>55152</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Build problem (linking failure)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rdwnsjjd
      </td>
    </tr>
</table>

<pre>
    This is my code:
```cpp
#include "clang/Driver/Options.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
#include "clang/Rewrite/Core/Rewriter.h"

using namespace std;
using namespace clang;
using namespace clang::driver;
using namespace clang::tooling;
using namespace llvm;

Rewriter rewriter;
int numFunctions = 0;

int main(int argc, const char **argv) {
    llvm::Expected<CommonOptionsParser> op = CommonOptionsParser::create(argc, argv, llvm::cl::getGeneralCategory()); 
}
```

this is my clang version (built from source):
```shell
~/Projects/compiler/llvm-project-llvmorg-14.0.1/build/bin/clang -v
clang version 14.0.1
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: ~/Projects/compiler/llvm-project-llvmorg-14.0.1/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
```

and this is my compile command:
```shell
~/Projects/compiler/llvm-project-llvmorg-14.0.1/build/bin/clang -L/usr/lib  -lclangAST -lclangBasic -lclangFrontend -lclangSerialization -lclangTooling -lclangFrontend -lclangSerialization -lclangDriver -lclangTooling -lclangParse -lclangSema -lclangAnalysis -lclangRewriteFrontend -lclangRewrite -lclangEdit -lclangLex -lclangBasic test.cpp -o test 
```

All libraries are located in `/usr/lib`

this is my compile result:
```
/usr/bin/ld: /tmp/test-f7efbc.o: in function `main':
test.cpp:(.text+0x18): undefined reference to `llvm::cl::getGeneralCategory()'
/usr/bin/ld: test.cpp:(.text+0x37): undefined reference to `clang::tooling::CommonOptionsParser::create(int&, char const**, llvm::cl::OptionCategory&, llvm::cl::NumOccurrencesFlag, char const*)'
/usr/bin/ld: /tmp/test-f7efbc.o: in function `clang::ConstructionContextItem::getKindAsString(clang::ConstructionContextItem::ItemKind)':
test.cpp:(.text._ZN5clang23ConstructionContextItem15getKindAsStringENS0_8ItemKindE[_ZN5clang23ConstructionContextItem15getKindAsStringENS0_8ItemKindE]+0x11c): undefined reference to `llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)'
/usr/bin/ld: /tmp/test-f7efbc.o: in function `__clang_call_terminate':
test.cpp:(.text.__clang_call_terminate[__clang_call_terminate]+0x2): undefined reference to `__cxa_begin_catch'
/usr/bin/ld: test.cpp:(.text.__clang_call_terminate[__clang_call_terminate]+0x7): undefined reference to `std::terminate()'
/usr/bin/ld: /tmp/test-f7efbc.o: in function `clang::RewriteBuffer::~RewriteBuffer()':
test.cpp:(.text._ZN5clang13RewriteBufferD2Ev[_ZN5clang13RewriteBufferD2Ev]+0x22): undefined reference to `clang::DeltaTree::~DeltaTree()'
/usr/bin/ld: /tmp/test-f7efbc.o: in function `clang::RewriteRope::~RewriteRope()':
test.cpp:(.text._ZN5clang11RewriteRopeD2Ev[_ZN5clang11RewriteRopeD2Ev]+0x22): undefined reference to `clang::RopePieceBTree::~RopePieceBTree()'
/usr/bin/ld: /tmp/test-f7efbc.o: in function `clang::RopeRefCountString::Release()':
test.cpp:(.text._ZN5clang18RopeRefCountString7ReleaseEv[_ZN5clang18RopeRefCountString7ReleaseEv]+0x94): undefined reference to `operator delete[](void*)'
/usr/bin/ld: /tmp/test-f7efbc.o: in function `__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<clang::FileID const, clang::RewriteBuffer> > >::deallocate(std::_Rb_tree_node<std::pair<clang::FileID const, clang::RewriteBuffer> >*, unsigned long)':
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKN5clang6FileIDENS3_13RewriteBufferEEEE10deallocateEPS8_m[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKN5clang6FileIDENS3_13RewriteBufferEEEE10deallocateEPS8_m]+0x19): undefined reference to `operator delete(void*)'
/usr/bin/ld: /tmp/test-f7efbc.o: in function `void std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
test.cpp:(.text._ZSt8_DestroyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEvPT_[_ZSt8_DestroyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEvPT_]+0x11): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/bin/ld: /tmp/test-f7efbc.o: in function `__gnu_cxx::new_allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::deallocate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, unsigned long)':
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE10deallocateEPS6_m[_ZN9__gnu_cxx13new_allocatorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE10deallocateEPS6_m]+0x19): undefined reference to `operator delete(void*)'
/usr/bin/ld: /tmp/test-f7efbc.o:(.data+0x0): undefined reference to `llvm::DisableABIBreakingChecks'
/usr/bin/ld: /tmp/test-f7efbc.o:(.eh_frame+0xa6b): undefined reference to `__gxx_personality_v0'
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
```

why? what's wrong? I'm so confused and I hope you can help!
thank you!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFWUtz4jgQ_jXmooLCNs8Dh_CaomYqkwqpPezFJdsCNLEtSpIJ2V-_3bIMhpAAWZKliCOp1Q993eqWRSji18HTiisC3_SVRCJmjn_nNMdO887pNItvtF7bEc_nWZTkMSOO50UJzZaONx1LvmESGr_XmotMNVZA_Ijhbv5UPC-fORKZZlt9FYPKUyYv5HhkUS4VrAO6f3HFtTjPOZVoVBYfKjy__Apf2byLLkOuwjoS6ZonTM4ypWkWsbO8T0Ik3LSANRWZ9dYDleoCmPbctnWW45G9SK6Z0SfZfuBAl3nmCuSRjKZMrWnEiNKx4w9P0wrpZ6h38I2LqLxgprZLe29qkmzSHbF4lksh0jZ2dJ5pkuXpNM8KlxLHH5PmETtOSinPHK-HTSqXkeONYPeBL0m0ohJwBFTvgLBxvD5xupadwKcwBw2fbNcs0gzAGp1wqeNPiFgb_SepKCGSjKKLeqUJhcZRRUmUFP-XTP9gGZM0GQHLUshXYAPj8OsPiV1ed3yUO6rL1pVEg_ATcJACk2C1vTDniSYLKVKiRC4jZuQeZyK1YklSqppATD1I8QcwUNCM7IaAJlpfXxekOnaEXNbdVqPZcIGKqnAHheiAaWFJfVNIPbTLshjKE0DDNJhEtr1O0GnV8-w5Ey9ZHWIn39aXWW7nrQDTmKSQSRE5shaKbwuS2apJwuIxR_zJbZZgRE9FnsUkolnMY3AP-TEaEV6oo-h1o86b5srI5iE8lxF4fGoXs1-EN3WbXyDTojhniQnZmwgb7UxL80Rz5AIpDdxsrWbaaR2p_GjSyXgF8aQas4V38H8KpO-Mzl9VaAipJ2Ycqk7ZHFLFo7JTVomyP2eS04T_Y4AuB20av4qnqPTvSDB5Zc-e0p2ZGU1eFWBo-zZ5Hmu0w2V3EnNdtn-x7eFCNVO6AccSUhemTT7w4l2SEEBNUsmZggQHCV1EFAOCQ-aBudWoez9hWedLpiCM3vq-r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