Recent

Author Topic: SOLVED: Warning: "crtbegin.o" not found, this will probably ca  (Read 3085 times)

PJW

  • New Member
  • *
  • Posts: 23
SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« on: September 02, 2021, 11:42:30 pm »
I've been using Lazarus and FPC on and off for a number of years on Windows, but I'm finally venturing into the Linux world.   I need to develop an small console app that will run on a Raspberry Pi.

I've got Lazarus 2.0.0 and FPC 3.0.4 installed (32 bit).  For some reason the newer versions do not seem to be available, but this version should be new enough for what I'm doing.

I'm getting the following Warning messages when compiling my app:

Warning: "crtbegin.o" not found, this will probably cause a linking failure
Warning: "crtend.o" not found, this will probably cause a linking failure

The program compiles and appears to be running properly, but I can't help but want to resolve these compiler warnings.   I searched for and found the two files, and added the following to my fpc.cfg file:

-Fl/usr/lib/gcc/arm-linux-gnueabihf/8

However this seems to break Lazarus/FPC.  When I start Lazarus, it complains it can't find the the compiler (FPC), so I assume I broke it by adding that line.   If I remove the line it works fine.

So I guess there are two questions:

1.  What did I do wrong and what do I need to do to fix it?
2.  What do these files do and what are the consequences of not linking them?


« Last Edit: September 04, 2021, 12:00:32 am by PJW »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #1 on: September 03, 2021, 12:09:26 am »
You probably miss some core package needed for development. Depending on distro it is called "build-essentials" or "glibc-dev"  or "glibc-devel".

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #2 on: September 03, 2021, 01:14:03 am »
This is a GCC version problem.

First you need to find the version of GCC. You can do this by typing in the console/terminal:

gcc --version

On my Manjaro Linux this is currently 11.1.0.

Now check the version in /etc/fpc.cfg (you have to open the file as root/sudo). Scroll down until you see '# path to gcclib'. There you will find the GCC version that the compiler tries to find on your system:

Code: [Select]
# path to the gcclib
#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/32
#endif
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0
#endif

As you can see, my FPC installation says 10.2.0 and as a result I get the same compiler warning. Adjust it to your GCC version (both lines):

Code: [Select]
# path to the gcclib
#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/32
#endif
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0
#endif

In my case I changed it to 11.1.0 but it may be different on your system. Save the file and the problem is solved. If your GCC or FPC gets an update you may need to set the new version again in fpc.cfg.
« Last Edit: September 03, 2021, 11:43:44 pm by munair »
keep it simple

PJW

  • New Member
  • *
  • Posts: 23
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #3 on: September 03, 2021, 01:25:15 am »
Got it fixed!

I had the right object files all along, but was updating the wrong fpc.cfg.   I updated the correct one and now things worked.   I have no idea why updating the wrong one broke things though!
« Last Edit: September 03, 2021, 01:57:55 am by PJW »

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #4 on: September 03, 2021, 08:06:42 am »
Got it fixed!

I had the right object files all along, but was updating the wrong fpc.cfg.   I updated the correct one and now things worked.   I have no idea why updating the wrong one broke things though!

I only have one fpc.cfg file on my system, not sure which one you edited (unless you have more than one FPC version installed, if that is possible).

Anyway, if your problem is solved you might want to put that in the title.  ;)
keep it simple

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1120
  • Professional amateur ;-P
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #5 on: September 03, 2021, 09:45:25 pm »
Hey Munair,

... (unless you have more than one FPC version installed, if that is possible).

It's very possible to have many installs of Lazarus/FPC.
I, myself, have 4 installs of different combinations of Lazarus and FPC installed under their own, self-contained folders all installed via fpcudeluxe.

When you install via the proper channels, either your OS repository(Linux) or via the packages on SourceForge, then you have a single install, system wide and it's a bit tricky to do parallel installs.

So in conclusion, it is possible to have multiple installs with different combinations of Lazarus/FPC, but you can't use the methods of the proper channels, you either do it by hand or use a tool like fpcupdeluxe.

Cheers,
Gus
« Last Edit: September 03, 2021, 09:56:37 pm by Gustavo 'Gus' Carreno »
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #6 on: September 03, 2021, 10:40:25 pm »
Hi!

I had the same error.

I am not quit shure  but I think it happened  when I did an update to fpc 3,2 via the Suse repository.

Grrr! And every Linux  distro has it's own path.

For Suse it is:

Code: Bash  [Select][+][-]
  1. /usr/lib64/gcc/x86_64-suse-linux/11

Winni
« Last Edit: September 03, 2021, 10:42:17 pm by winni »

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #7 on: September 03, 2021, 11:05:09 pm »
When you install via the proper channels, either your OS repository(Linux) or via the packages on SourceForge, then you have a single install, system wide and it's a bit tricky to do parallel installs.

Yes, I was referring to Linux, as the OP did. With parallel installs it is a matter of finding the right fpc.cfg files, but I have not much experience with that.
« Last Edit: September 03, 2021, 11:40:47 pm by munair »
keep it simple

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #8 on: September 03, 2021, 11:15:46 pm »
I am not quit shure  but I think it happened  when I did an update to fpc 3,2 via the Suse repository.

Yeah, it's a bit annoying. Ideally, Lazarus should automatically detect the GCC version and adjust/warn if it has changed or expects a different version. Particularly for new comers who are familiarizing themselves with FPC/Lazarus, this is intimidating because they get the false sense that they've done something wrong whereas in truth they didn't. As far as I remember this has been a problem and while not fatal, it deserves a fix IMHO.
« Last Edit: September 03, 2021, 11:40:55 pm by munair »
keep it simple

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Warning: "crtbegin.o" not found, this will probably ca
« Reply #9 on: September 03, 2021, 11:28:23 pm »
Hi!

Yes - everything compiled fine.
But I always had the anoying message with crtbegin.o and crtend.o

As this was new to me I wanted to know the reason.

Winni

 

TinyPortal © 2005-2018