c - 使用 gcc -v 手动编译

标签 c gcc

是否可以编译一个简单的 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

任何人都可以修改它以使其工作吗?

最佳答案

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

要使用所有自定义库运行,请使用 -nostdlib

关于c - 使用 gcc -v 手动编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5765259/

相关文章:

c - 为什么我的二维数组会导致 C 中的总线错误?

c - 想知道此声明与代码中的注释相比有什么问题吗? - 初学者在这里

php - 最佳实践 : Displaying image generated by C program in PHP website

gcc - 为什么 gcc 在 main 的开头推送 %rbx?

c++ - 为什么 gcc 不能去虚拟化这个函数调用?

c++ - 在 sparc solaris 上使用 gcc 为长整数赋值

c - 错误: incompatible types when initializing type 'struct taus88_t *' using type 'taus88_t' |?

c - 确定目录中最旧的文件

c++ - 构建 wxWidgets 应用程序失败 - 未定义对 `wxCRT_StrdupA(char const*)' 的引用

c - 为什么一种 malloc 段错误,而另一种却没有?