Latest FBC install on Debian

Linux specific questions.
dasyar
Posts: 336
Joined: Dec 04, 2008 15:31

Latest FBC install on Debian

Postby dasyar » Jul 26, 2018 22:25

I just installed FreeBasic on my Raspberry Pi Desktop setup and FBC is having a problem finding -lgcc. Yes, the desktop has the latest gcc installed. About three months ago I had FreeBasic installed on another Raspberry Pi Desktop, and on that computer fbc seems to be running just fine. I wonder if something changed with the latest version of Debian. Is anybody else having any problems with there latest Debian FreeBasic setup?


Thanks
dasyar
Posts: 336
Joined: Dec 04, 2008 15:31

Re: Latest FBC install on Debian

Postby dasyar » Jul 27, 2018 11:12

I am using Geany as the IDE to work with FreeBasic. But, I do get the same results when I use the command line for implimenting FBC. I have never seen this problem before.

One more note, I did install both the 32bit and the 64bit versions. I have done this before on another machine without any problems.

fbc -w all "test1.bas" (in directory: /home/pi/programs/freebasic)
ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/6/libgcc.a when searching for -lgcc
ld: cannot find -lgcc
ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/6/libgcc_eh.a when searching for -lgcc_eh
ld: cannot find -lgcc_eh
Compilation failed.
marcov
Posts: 2650
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: Latest FBC install on Debian

Postby marcov » Jul 27, 2018 12:26

For rpi you should enable -gen gcc so

Code: Select all

fbc -w all  -gen gcc "test1.bas" 


Now you use the AS backend that only supports x86/x86-64.

(One could argue though that non x86 builds of FB should default to cgen)
caseih
Posts: 1302
Joined: Feb 26, 2007 5:32

Re: Latest FBC install on Debian

Postby caseih » Jul 27, 2018 13:15

dasyar wrote:fbc -w all "test1.bas" (in directory: /home/pi/programs/freebasic)
ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/6/libgcc.a when searching for -lgcc

i686-linux is not compatible with the ARM processor the Pi uses. I'm not sure where this file is coming from, but it's not the right version. You are looking for "arm" versions. I believe the package you need to install install is libgcc-dev. Use your package manager to install this. Also make sure you have the gcc compiler installed, again via your package manager. If you install a package called "synaptic" you can get a graphical user interface for searching for and installing packages from the official distribution repo. This should always be your first place to look for software and dependencies in general.

The default FBC code generator on the pi is gcc, so you I I'm pretty sure you don't need to specify -gen gcc.

When you say you installed both 32-bit and 64-bit versions of fbc, are you sure these are ARM versions for the Pi?
dasyar
Posts: 336
Joined: Dec 04, 2008 15:31

Re: Latest FBC install on Debian

Postby dasyar » Jul 27, 2018 15:19

Before this gets to be very confusing, an explanation. Raspberry Pi has two OSs, one for the small board, which runs on an ARM, and the Raspberry Pi Desktop, which runs on a PC or a MAC computer.

I am having the problem with the PC Desktop version. The Raspberry Pi Desktop version was just upgraded, so I am not sure if the -lgcc got moved to a different location and now fbc cannot find it, or is it some other problem.
dkl
Site Admin
Posts: 3202
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Latest FBC install on Debian

Postby dkl » Jul 27, 2018 16:26

Try adding the -v option to the fbc compile command, then it should show the target system it's trying to compile for (maybe it's 64bit x86_64 instead of 32bit i686?).
dasyar
Posts: 336
Joined: Dec 04, 2008 15:31

Re: Latest FBC install on Debian

Postby dasyar » Jul 27, 2018 16:40

This is using the -v.

fbc -v -w all "test1.bas" (in directory: /home/pi/programs/freebasic)
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for linux-x86_64 (64bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
target: linux-x86_64, x86-64, 64bit
compiling: test1.bas -o test1.c (main module)
compiling C: gcc -m64 -march=x86-64 -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -masm=intel "test1.c" -o "test1.asm"
assembling: as --64 --strip-local-absolute "test1.asm" -o "test1.o"
linking: ld -m elf_x86_64 -o "test1" -dynamic-linker /lib64/ld-linux-x86-64.so.2 "/usr/local/bin/../lib/freebasic/linux-x86_64/fbextra.x" -s -L "/usr/local/bin/../lib/freebasic/linux-x86_64" -L "." -L "/usr/lib/gcc/i686-linux-gnu/6" "/usr/lib/gcc/i686-linux-gnu/6/../../../x86_64-linux-gnu/crt1.o" "/usr/lib/gcc/i686-linux-gnu/6/../../../x86_64-linux-gnu/crti.o" "/usr/lib/gcc/i686-linux-gnu/6/crtbegin.o" "/usr/local/bin/../lib/freebasic/linux-x86_64/fbrt0.o" "test1.o" "-(" -lfb -ltinfo -lm -ldl -lpthread -lgcc -lgcc_eh -lc "-)" "/usr/lib/gcc/i686-linux-gnu/6/crtend.o" "/usr/lib/gcc/i686-linux-gnu/6/../../../x86_64-linux-gnu/crtn.o"
ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/6/libgcc.a when searching for -lgcc
ld: cannot find -lgcc
ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/6/libgcc_eh.a when searching for -lgcc_eh
ld: cannot find -lgcc_eh
linking failed: 'ld' terminated with exit code 1
Compilation failed.
dkl
Site Admin
Posts: 3202
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Latest FBC install on Debian

Postby dkl » Jul 27, 2018 17:00

It's strange that fbc is trying to use 32bit libgcc even though it compiles for 64bit. What do you get when running these commands:
gcc -m32 -print-file-name=libgcc.a
gcc -m64 -print-file-name=libgcc.a


It should give different output, but if it's the same, then maybe some packages are missing: gcc-multilib, g++-multilib (maybe especially something like lib64gcc-?-dev or libgcc-?-dev:amd64)
dasyar
Posts: 336
Joined: Dec 04, 2008 15:31

Re: Latest FBC install on Debian

Postby dasyar » Jul 27, 2018 19:28

So, I went ahead and did a 'sudo apt-get install gcc-multilib', and now it is compiling without any errors. Now the question is, since I have both 32bit and 64bit installed, which one is being compiled, 32 or 64. The gcc-multilib is for the 32bit version, I guess I am now getting 32bit compiles, I think?
caseih
Posts: 1302
Joined: Feb 26, 2007 5:32

Re: Latest FBC install on Debian

Postby caseih » Jul 27, 2018 19:47

You're probably getting whatever version corresponds to the fbc that you are using. If that was 64-bit then you're using the 64-bit toolchain all the way through (otherwise you'd get a linker error trying to link the FB runtime because the architecture wouldn't match).

You can identify what architecture binaries are for by using the "file" command.

For example on my computer:

Code: Select all

$ file /opt/FreeBASIC/bin/fbc               
/opt/FreeBASIC/bin/fbc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped

Also the ldd command can tell you what a binary links against, and from those paths you can often determine the architecture.
dasyar
Posts: 336
Joined: Dec 04, 2008 15:31

Re: Latest FBC install on Debian

Postby dasyar » Jul 27, 2018 19:49

After doing a few more test compiles, something is still wrong. Sometimes I get an error free compile, and at other times, it shows that I am missing some libs, which I know I installed. I guess it is time to re-install the OS, and start from scratch. Propbably get back to this tomorow.
caseih
Posts: 1302
Joined: Feb 26, 2007 5:32

Re: Latest FBC install on Debian

Postby caseih » Jul 27, 2018 23:16

Besides ldd and file, another good command is "which." Sometimes you might not be running the binary you think you are. which can tell you the path of a binary you are trying to run. which fbc will tell you where the fbc binary is located, and then file /path/to/fbc will tell you what kind of binary it is. And finally, using ldd on a generated executable will tell you if all the shared library dependencies are satisfied and where they come from.

Also I note that depending on what FB commands you are using, it may try to link in additional libraries for things like graphics and sound.

As always, cut and paste the error messages you get (linker, etc). Otherwise all anyone can do is guess at possible problems and causes.
dasyar
Posts: 336
Joined: Dec 04, 2008 15:31

Re: Latest FBC install on Debian

Postby dasyar » Jul 27, 2018 23:17

After doing some more Freebasic 32bit and 64bit, on a fresh install of the Raspberry Pi Desktop (PC), FreeBasic does not like the Raspberry Pi Desktop (PC) OS. I am not sure why FreeBasic is not installing correctly, some Freebasic install guru will have to figure that one out. Time to move on.

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 2 guests