julianLiuRsch
Programmer
- Oct 4, 2008
- 11
I complied and linked a very simple .c file, a.c :
---
#include <stdio.h>
int main() {
char* eee[][100] = {
"aaa",
"bbb"
};
}
===
and I used these two steps to compile and link it
---
gcc -c -o b.o b.c
ld -o z b.o
===
the error was
---
ld -o z b.o
ld: warning: cannot find entry symbol _start; defaulting to 00000000004000b0
b.o: In function `main':
b.c.text+0x1d): undefined reference to `memset'
===
Obviously I wrote a wrong ld command. If I insist on using ld to get the final exe-elf file (``z''), how to write this ld command?
(I am using Fedora 10 x86_64, gcc's condition is as below
---
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
===
)
thanks in adv!
---
#include <stdio.h>
int main() {
char* eee[][100] = {
"aaa",
"bbb"
};
}
===
and I used these two steps to compile and link it
---
gcc -c -o b.o b.c
ld -o z b.o
===
the error was
---
ld -o z b.o
ld: warning: cannot find entry symbol _start; defaulting to 00000000004000b0
b.o: In function `main':
b.c.text+0x1d): undefined reference to `memset'
===
Obviously I wrote a wrong ld command. If I insist on using ld to get the final exe-elf file (``z''), how to write this ld command?
(I am using Fedora 10 x86_64, gcc's condition is as below
---
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
===
)
thanks in adv!