On Sat, Feb 18, 2017 at 5:34 PM, Nhon Quach <
nhon....@gmail.com> wrote:
> I am trying to port a C++ program to RISCV. Compilation seemed to have gone
> well, but I got the following error messages when linking. Any help or
> pointers will be greatly appreciated.
> ../../bsp/../toolchain/bin/riscv32-unknown-elf-ar rcs libwrap.a
> ../../bsp/../toolchain/bin/riscv32-unknown-elf-g++ -O2 -fno-builtin-printf
> -Wl,--wrap=isatty -Wl,--wrap=times -Wl,--wrap=sbrk -Wl,--wrap=_exit -L.
> -Wl,--start-group -lwrap -lc -Wl,--end-group -T
> ../../bsp/env/freedom-e300-hifive1/link.lds -nostartfiles -lstdc++
> -L../../bsp/env
> /home/nquach/Desktop/freedom-e-sdk/toolchain/lib/gcc/riscv32-unknown-elf/6.1.0/../../../../riscv32-unknown-elf/lib/libstdc++.a(eh_alloc.o):
> In function `_GLOBAL__sub_I__ZN9__gnu_cxx9__freeresEv':
> /home/nquach/Desktop/freedom-e-sdk/work/riscv32-gnu-toolchain/src/newlib-gcc/libstdc++-v3/libsupc++/eh_alloc.cc:260:
> undefined reference to `__wrap_free'
So looking at this it appears to be using the wrappers from
https://github.com/sifive/freedom-e-sdk/blob/master/bsp/libwrap/libwrap.mk
; but because -lstdc++ is after -lwrap in your linker command line,
undefined symbols in libstdc++.a cannot be resolved to external
symbols in libwrap.a. Is it possible to tweak your Makefile so that
-lstdc++ comes before the stuff that
libwrap.mk adds and see if that
helps?
-s