There are files like: ph
#ifndef P_H #define P_H #include <stdio.h> void p(); #endif pc
#include "ph" void p() { printf("Hello world\n"); } hello.c
#include "ph" int main() { p(); return 0; } When compiling with the -o optimization option, everything is fine:
gcc -c hello.c pc gcc hello.o po -o result Problems occur when compiling with -o1 -o2 -o3 options
gcc -c hello.c pc gcc hello.o po -o1 result result: In function `p': (.text+0x10b): multiple definition of `p' po:pc:(.text+0x0): first defined here result: In function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o:/build/buildd/glibc-2.21/csu/../sysdeps/x86_64/crti.S:80: first defined here result: In function `data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here result: In function `data_start': (.data+0x8): multiple definition of `__dso_handle' /usr/lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o:(.data+0x0): first defined here result:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here result: In function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here result: In function `main': (.text+0xf6): multiple definition of `main' hello.o:hello.c:(.text+0x0): first defined here result: In function `_init': (.init+0x0): multiple definition of `_init' /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o:/build/buildd/glibc-2.21/csu/../sysdeps/x86_64/crti.S:64: first defined here /usr/lib/gcc/x86_64-linux-gnu/4.9/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__' result:(.data+0x10): first defined here /usr/bin/ld: ошибка в result(.eh_frame); таблиц .eh_frame_hdr создана не будет. collect2: error: ld returned 1 exit status With Linux and gcc is not very familiar, what the problem is I do not understand.