irixxxx / picodrive

Fast MegaDrive/MegaCD/32X emulator
Other
55 stars 25 forks source link

Error compiling #12

Closed dipievil closed 3 years ago

dipievil commented 3 years ago

Hi!

When I try to compile I got some errors in config.log:

mipsel-linux-gcc -I~/git/RG350_buildroot/output/host/usr/include -I~/git/RG350_buildroot/output/target/usr/include/SDL -D__RG350__ /tmp/picodrive-conf--1392-.c -o /tmp/picodrive-conf--1392- --sysroot ~/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot -L~/git/RG350_buildroot/output/host/usr/lib /root/git/RG350_buildroot/output/host/usr/lib/gcc/mipsel-gcw0-linux-uclibc/5.4.0/../../../../mipsel-gcw0-linux-uclibc/bin/ld: cannot find crt1.o: No such file or directory /root/git/RG350_buildroot/output/host/usr/lib/gcc/mipsel-gcw0-linux-uclibc/5.4.0/../../../../mipsel-gcw0-linux-uclibc/bin/ld: cannot find crti.o: No such file or directory collect2: error: ld returned 1 exit status

Here is the command: CROSS_COMPILE=mipsel-linux- CFLAGS="-I~/git/RG350_buildroot/output/host/usr/include -I~/git/RG350_buildroot/output/target/usr/include/SDL" LDFLAGS="--sysroot ~/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot -L~/git/RG350_buildroot/output/host/usr/lib" ./configure --platform=rg350

Can you give some help?

Thanks!

irixxxx commented 3 years ago

It's a problem with your compiler setup. It can't find files it needs for linking the runtime environment to the executable.

Have you searched for crti.o in your toolchain?

dipievil commented 3 years ago

Hello again! First of all, thanks for your reply.

I have searched the file in my toolchain this way: dipi@dipi-linux:~/git/RG350_buildroot/output$ find . -name "crt1.o" ./build/uclibc-0.9.33.2/lib/crt1.o ./host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/crt1.o

After that I did this command to export the path as this suggestion in StackOverflow: export LIBRARY_PATH=/root/git//RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/crt1.o

Iḿ using this buildroot 2020-05-25 RG350 Docker Buildroot

irixxxx commented 3 years ago

LIBRARY_PATH is a path variable. You mustn't add a single file here, but the directory it is contained in. So. export LIBRARY_PATH=/root/git//RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib is more likely corrrect.

Anyway, I don't know if this LIBRARY_PATH stuff works with every gcc. Try adding something like -B <path_to_crti_directory> -L <path_to_crti_directory> to your link command.

dipievil commented 3 years ago

The LIBRARY_PATH was my mistake. I have

Now I have tried this: CROSS_COMPILE=mipsel-linux- CFLAGS="-I ~/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/include/ -I ~/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL -B ~/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/ -L ~/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/" LDFLAGS="--sysroot ~/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot -L ~/git/RG350_buildroot/output/host/lib -B ~/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/ -L ~/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/ " ./configure --platform=rg350

The same error happens.

Considering that I have two directories with the file crt1.o how can I assure wich one is correct? Maybe any other specific file that should be in that directory too...

Another question that maybe is related to this problem, the folder _/root/git/RG350buildroot/output/host/usr/lib/gcc/mipsel-gcw0-linux-uclibc/5.4.0/../../../../mipsel-gcw0-linux-uclibc/bin/ld: wich appeats in the log should exist?

irixxxx commented 3 years ago

That ld path collapses to root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/bin/ld after the .. stuff has been resolved...I'm sure it exists, the linker executable is loaded from it.

Considering the location of crti.o, in my toolchain there's only one in .../usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/crti.o. If you have one in a similar location I reckon it should be the right one. I have this for my linux qemu crossbuilds: LDFLAGS="-L $HOME/opt/linux-cross/mipsel-linux-gnu/lib -Wl,-rpath,$HOME/opt/linux-cross/mipsel-linux-gnu/lib -B$HOME/opt/linux-cross/mipsel-linux-gnu/lib". This is however somewhat platform dependent. For my open2x builds I need this: LDFLAGS="-B$TC/lib/gcc/arm-open2x-linux/4.1.1 -B$TC/arm-open2x-linux/lib -L$TC/arm-open2x-linux/lib, with $TC pointing at the base directory of the toolchain. On other platforms, --sysroot <dir> is sufficient, or may additionally need some of the above. Basically, you need to experiment a bit with those to find the right combination. Adding -Wl,--verboseto the linking shows you where files are searched for.

irixxxx commented 3 years ago

Have you solved your compile problems?

dipievil commented 3 years ago

I have changed the command to absolute path /root/git and the log changed a bit.

CROSS_COMPILE=mipsel-linux- CFLAGS="-I/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/ -I/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL -B/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib -L/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/" LDFLAGS="--sysroot /root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot -L/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/ -B/root/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/ -L/root/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/ -Wl, --verbose" ./configure --platform=rg350

Log here.

But the ld is there dipi@dipi-linux:~/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/bin$ ls ar as ld ld.bfd nm objcopy objdump ranlib readelf strip

dipievil commented 3 years ago

I have changed the command to absolute path /root/git and the log changed a lot.

CROSS_COMPILE=mipsel-linux- CFLAGS="-I/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/ -I/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL -B/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib -L/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/" LDFLAGS="--sysroot /root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot -L/root/git/RG350_buildroot/output/host/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/ -B/root/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/ -L/root/git/RG350_buildroot/output/build/uclibc-0.9.33.2/lib/ -Wl, --verbose" ./configure --platform=rg350

Log here.

irixxxx commented 3 years ago

Don't know if this is still of relevance. I have had success with this for a newly built toolchain: NTC=/opt/mips-toolchain OTC=/opt/rg350-toolchain PATH=$PATH:$NTC/usr/bin CROSS_COMPILE=mipsel-linux- CFLAGS="-I$OTC/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include -I$OTC/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL -march=mips32r2" LDFLAGS="--sysroot $OTC/usr/mipsel-gcw0-linux-uclibc/sysroot -Wl,--dynamic-linker=/lib/ld-uClibc.so.0 -L$OTC/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib" ./configure --platform=rg350 Depending on your toolchain you might need to add -mabicallsto CFLAGS. I'm sorry I can't give you any more help. As I think this isn't exactly a picodrive problem I'm going to close this here.