[user@user Book]$ gcc -o notesearch.c notesearch
notesearch: In function `__x86.get_pc_thunk.bx':
(.text+0x30): multiple definition of `__x86.get_pc_thunk.bx'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../crti.o:(.gnu.linkonce.t.__x86.get_pc_thunk.bx+0x0): first defined here
notesearch: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../crti.o:(.fini+0x0): first defined here
notesearch: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../crt1.o:(.data+0x0): first defined here
notesearch: In function `data_start':
(.data+0x4): multiple definition of `__dso_handle'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/crtbegin.o:(.data+0x0): first defined here
notesearch:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../crt1.o:(.rodata.cst4+0x0): first defined here
notesearch: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../crt1.o:(.text+0x0): first defined here
notesearch:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../crt1.o:(.rodata+0x0): first defined here
notesearch: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../crti.o:(.init+0x0): first defined here
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
notesearch:(.data+0x8): first defined here
/usr/bin/ld: warning: Cannot create .eh_frame_hdr section, --eh-frame-hdr ignored.
/usr/bin/ld: error in notesearch(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status
[user@user Book]$
我正在尝试从书中编译notesearch.c"攻击剥削艺术"我收到一个错误。我记得能够做得很好。我在x86 3.16.7.4-1-MANJARO Linux计算机上。
答案 0 :(得分:4)
你需要说gcc -o notesearch notesearch.c
。否则,您正在输出(-o
).c文件,这是不好的。此外,您可能需要考虑使用这些其他标志进行编译:
-Wall
:警告全部,非常有用。
-Werror
:再次,非常有用。
-g
:这是我最喜欢的旗帜。它使用调试符号进行编译,以便您可以在gdb
(Gnu DeBugger)中开始编程,然后检查发生了什么,在执行期间更改变量值,并进行调试。 gdb
非常有帮助。