How to compile multiple .ll files into a single executable

My source code is composed of multiple .cpp .c and .h files. I also have a file that consists of my application’s int main(…) function.
I applied transformations on these files using llvm passes, and now I have .ll files corresponding to all the .cpp and .c files.
I want to compile this transformed code into a single executable. I tried using llvm-link but I get the following error:

error: Linking globals named 'main': symbol multiply defined!

I also tried using the –only-needed option with llvm-link. I succeeded in creating a single .bc file. I then used llc to generate an object file. When I try to convert that object file to an executable using clang, I get following errors:

/usr/bin/ld: /lib/aarch64-linux-gnu/crt1.o: in function `__wrap_main':
(.text+0x40): undefined reference to `main'

Please help if you know the solution to my problem.

The easiest way to do this is to pass all the .ll files directly to clang as if they were input source files.

clang a.ll b.ll c.ll

It can handle bitcode/LLVM IR directly.