首页 文章

使用gcc -v手动编译

提问于
浏览
2

是否可以编译一个简单的Hello World程序,该程序仅使用提供的gcc / glibc文件而不是使用操作系统提供的默认文件? (因此,执行时,程序将只使用提供的文件而不是操作系统提供的文件 . )我在网上到处查看但无法使用任何文件:

我试图手动做这个 gcc -v simple.c 但我不能自己重现它 .

这是我试过的:(所有提供的文件都在桌面上)

/home/myuser/Desktop/cc1 -quiet -v simple.c -quiet -dumpbase simple.c -mtune=generic -auxbase simple -version -o /tmp/temp1.s

如何将以下路径更改为自定义路径而不是默认路径?

ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include  search starts here:
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.4.5/include
 /usr/lib/gcc/x86_64-linux-gnu/4.4.5/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C (Debian 4.4.5-8) version 4.4.5 (x86_64-linux-gnu)
    compiled by GNU C version 4.4.5, GMP version 4.3.2, MPFR version 3.0.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: dac4d891d068d1bed01868869b00bd17
as -V -Qy -o /tmp/temp2.o /tmp/temp1.s
GNU assembler version 2.20.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.20.1-system.20100303
/home/myuser/Desktop/collect2 --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker ld-2.11.2.so crt1.o crti.o crtbegin.o /tmp/temp2.o libgcc.a --as-needed libgcc_s.so.1 --no-as-needed libc.a libgcc_s.so.1 --as-needed libgcc.a --no-as-needed crtend.o crtn.o

为什么使用下面的/ usr / bin / ld代替提供的ld-2.11.2.so?

/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie
collect2: ld returned 1 exit status

任何人都可以修改它吗?

2 回答

  • 0

    -v 显示编译器驱动程序执行的操作 . 它不会影响您获得的标准库 .

    要与所有自定义库一起运行,请使用 -nostdlib .

  • 0

    如何将以下路径更改为自定义路径而不是默认路径?

    只需将 -I path 添加到编译器调用中即可 . 此路径将在内部路径之前添加 .

    为什么使用下面的/ usr / bin / ld代替提供的ld-2.11.2.so?

    第一个是可执行二进制文件,第二个是共享对象 . 您不能在二进制位置使用共享对象 .

相关问题