hi,
my gcc 5.2.0 hi can link to .o but not .a, why?
i586-peter-elf-gcc a.c workspace/PeterI/library/libpeter/libpeter.o <--- this is ok
But this i586-peter-elf-gcc a.c workspace/PeterI/library/libpeter/libpeter.a gives me these
^
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `_read':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:12: undefined reference to `vfs_fread'
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:22: undefined reference to `getChar'
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `_write':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:39: undefined reference to `k_outStringToDisplay_len'
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `_open':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:52: undefined reference to `vfs_fopen'
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `_lseek':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:34: undefined reference to `vfs_fseek'
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `_close':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:59: undefined reference to `vfs_fclose'
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `malloc':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:163: undefined reference to `kmalloc'
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `_malloc_r':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:167: undefined reference to `kmalloc'
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `free':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:171: undefined reference to `kfree'
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/lib/libc.a(lib_a-peter_stub.o): In function `_free_r':
/Users/peter/workspace/PeterI/toolchain/build-newlib/i586-peter-elf/newlib/libc/sys/peter/../../../../../../newlib-2.1.0/newlib/libc/sys/peter/peter_stub.c:175: undefined reference to `kfree'
thanks
from Peter ([email protected])
gcc can't link
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: gcc can't link
Start with using -l and -L for library archives
Re: gcc can't link
Hi, i have -L and -l. Otherwise it prompt me
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/bin/ld: cannot find -lpeter
Any other hints?
thanks
/toolchain/lib/gcc/i586-peter-elf/5.2.0/../../../../i586-peter-elf/bin/ld: cannot find -lpeter
Any other hints?
thanks
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: gcc can't link
Your second post contradicts your first, so I can't trust anything you said at all. Until the problem between keyboard and chair is fixed I can't help.Any other hints?
Re: gcc can't link
good bye
Re: gcc can't link
The problem is that you are are placing the .o and .a files on the command line before any reference to the functions in the .o or .a file is made. It's OK in the case of the .o file, because the linker will link it to your other files no matter what. An archive file (.a) is treated differently: Only object files containiing referenced symbols are pulled in. Since it appears that newlib is referencing your functions, you need to put your .a file after the reference to newlib.
-Rich
-Rich
Re: gcc can't link
Hi Mr Rdp, your idea is correct, but changing the order of .a and .o doesnt help. i added --start-group in ld, so ld resolves the nested dependency, thanks