|
||||||
| Forums FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| ARCHIVES - Programming & Scripting A place to discuss website design, programming, shell scripts, etc |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
When I compile a hello.c in bash shell, I encounter a strange problem.
The hello.c's code is: ============= #include <stdio.h> int main() { printf("hello world\n"); return 1; } ============= the command line input is: bash#gcc -o hello hello.c ->this action is successful but when the input is: bash#gcc -Wl, --verbose -o hello hello.c ->this command can not work well the output of err is: Using built-in specs. Target: x86_64-suse-linux Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.2.1 --enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --program-suffix=-4.2 --enable-version-specific-runtime-libs --without-system-libunwind --with-cpu=generic --host=x86_64-suse-linux Thread model: posix gcc version 4.2.1 (SUSE Linux) /usr/lib64/gcc/x86_64-suse-linux/4.2.1/cc1 -quiet -v hello.c -quiet -dumpbase hello.c -mtune=generic -auxbase hello -version -o /tmp/cchckHCi.s #include "..." search starts here: #include <...> search starts here: /usr/local/include /usr/lib64/gcc/x86_64-suse-linux/4.2.1/include /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/include /usr/include End of search list. GNU C version 4.2.1 (SUSE Linux) (x86_64-suse-linux) compiled by GNU C version 4.2.1 (SUSE Linux). GGC heuristics: --param ggc-min-expand=97 --param ggc-min-heapsize=126731 Compiler executable checksum: 15875aa798ad559dcc04a8709924cdb9 /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/as -V -Qy -o /tmp/ccBQYGbj.o /tmp/cchckHCi.s GNU assembler version 2.17.50 (x86_64-suse-linux) using BFD version (GNU Binutils) 2.17.50.20070726-14 (SUSE Linux) /usr/lib64/gcc/x86_64-suse-linux/4.2.1/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o hello /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.2.1/crtbegin.o -L/usr/lib64/gcc/x86_64-suse-linux/4.2.1 -L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../.. /tmp/ccBQYGbj.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-suse-linux/4.2.1/crtend.o /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crtn.o /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: : No such file: No such file or directory collect2: ld returned 1 exit status ======== The most strange thing is when i divide the compile process into three steps below: 1) bash#/usr/lib64/gcc/x86_64-suse-linux/4.2.1/cc1 -quiet -v hello.c -quiet -dumpbase hello.c -mtune=generic -auxbase hello -version -o /tmp/cchckHCi.s ->success 2) bash#/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/as -V -Qy -o /tmp/ccBQYGbj.o /tmp/cchckHCi.s ->success 3) bash#/usr/lib64/gcc/x86_64-suse-linux/4.2.1/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o hello /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.2.1/crtbegin.o -L/usr/lib64/gcc/x86_64-suse-linux/4.2.1 -L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../.. /tmp/ccBQYGbj.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-suse-linux/4.2.1/crtend.o /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/crtn.o ->success I can work very well by using the above steps and get the correct binary file---hello. but why it fails as i directly execute the command "gcc -Wl, --verbose -o hello hello.c"? thanks for any advices! ![]() |
|
|||
|
You're meant to put some linker option after -Wl, See the man page for gcc.
If you don't have any option to give the linker, then don't use it. |
|
|||
|
Quote:
I use the option -Wl, --verbose complied with gcc rule, and this question came from section 2 chapter 5 of "linux from scratch". the intention of this operation is to display all the library files linked by "ld". I want to know why but not bypass it Thank your reply at mid-night |
|
|||
|
Then the LFS documentation is wrong. You probably only need the --verbose.
It's not midnight everywhere in the world. |
|
|||
|
Quote:
Ld also has the same option, it display link script and all the linked library files. The option -Wl,<option> is used to pass <option> to linker. so the command "gcc -Wl,--verbose " means passing the "--verbose" option to ld. I have resolved this problem. The root cause is an unwanted space between "-Wl," and "--verbose". |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|