The main Function Is Defined Twice in a Fortran and C Interoperation Scenario
In BiSheng Compiler, the install_path/lib/ directory contains the libflangmain.a library. This static library provides a main function to be called by the operating system. Therefore, a Fortran program only needs its own program function.
In a Fortran and C interoperation scenario, the user may provide a main function in the C program. As a result, the main function may be defined twice during linking. An example is as follows:
/bin/ld: c_call_fortran.o: in function `main': c_call_fortran.c:(.text+0x0): multiple definition of `main'; /install/bin/../lib/libflangmain.a(flangmain.c.o):flangmain.c:(.text.main+0x0): first defined here
In this case, you only need to add -fno-fortran-main to compiler options.
Parent topic: Flang Compatibility