C 编译文件时出错

C 编译文件时出错,c,gcc,C,Gcc,我试图从《黑客攻击剥削的艺术》一书中编译notesearch.c,但我得到了一个错误。我记得我能做得很好。我使用的是x86 3.16.7.4-1-MANJARO Linux计算机 您需要说gcc-o notesearch notesearch.c。否则,您将(-o)输出到.c文件,这是不好的。此外,您可能还需要考虑用其他标志编译: -Wall:警告所有人,非常有用。 -Werror:同样非常有用。 -g:这是我最喜欢的标志。它使用调试符号进行编译,这样您就可以在gdb(Gnu DeBugger)

我试图从《黑客攻击剥削的艺术》一书中编译notesearch.c,但我得到了一个错误。我记得我能做得很好。我使用的是x86 3.16.7.4-1-MANJARO Linux计算机

您需要说
gcc-o notesearch notesearch.c
。否则,您将(
-o
)输出到.c文件,这是不好的。此外,您可能还需要考虑用其他标志编译:

-Wall
:警告所有人,非常有用。
-Werror
:同样非常有用。
-g
:这是我最喜欢的标志。它使用调试符号进行编译,这样您就可以在
gdb
(Gnu DeBugger)中启动程序,然后检查发生了什么,在执行过程中更改变量的值,并进行一般调试
gdb
非常有用。

您需要说
gcc-o notesearch notesearch.c
。否则,您将(
-o
)输出到.c文件,这是不好的。此外,您可能还需要考虑用其他标志编译:

-Wall
:警告所有人,非常有用。
-Werror
:同样非常有用。
-g
:这是我最喜欢的标志。它使用调试符号进行编译,这样您就可以在
gdb
(Gnu DeBugger)中启动程序,然后检查发生了什么,在执行过程中更改变量的值,并进行一般调试
gdb
非常有用。

您应该改为尝试
gcc-o notesearch notesearch.c
!请不要打破惯例。您应该试试
gcc-o notesearch notesearch.c
!请不要打破惯例。
[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]$