Recent

Author Topic: SOLVED: Warning: "crtbegin.o" not found, this will probably ca  (Read 4872 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: 12181
  • 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: 828
  • 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 »
It's only logical.

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: 828
  • 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.  ;)
It's only logical.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1189
  • 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: 828
  • 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 »
It's only logical.

munair

  • Hero Member
  • *****
  • Posts: 828
  • 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 »
It's only logical.

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

Awesome Programmer

  • Sr. Member
  • ****
  • Posts: 472
  • Programming is FUN only when it works :)
    • Cool Technology
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #10 on: April 29, 2025, 06:01:24 pm »
Even though this is an old post, the answers provided still works today.

My hardrive recently crashed on my linux system. So, I had to reinstall and rebuild my linux system not mention all the upgrades. That broke a lot of my setup and one of them was this annoying error about crtbeginS.o not found.

This fixed it.
Thank you.

Thaddy

  • Hero Member
  • *****
  • Posts: 16928
  • Ceterum censeo Trump esse delendam
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #11 on: April 29, 2025, 06:43:37 pm »
Yes, it simply needs a correct install of the GNU C suite and the correct path to its libs.
You can also fix it manually.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

daniel_sap

  • Jr. Member
  • **
  • Posts: 93
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #12 on: May 05, 2025, 09:37:55 pm »
I have the same warning messages when compiling under ubuntu.
Can I just leave them like that and do not provide any paths, cause the compilation is successfull and the compiled binary works fine.
Or may be there will be some negative effect which I don't notice at the moment

Thaddy

  • Hero Member
  • *****
  • Posts: 16928
  • Ceterum censeo Trump esse delendam
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #13 on: May 06, 2025, 10:32:54 am »
They are only needed when you do a lot of interfacing with C libraries:
crt means c runtime libraries.
But it is still a good idea to resolve it and include the current C libraries in your path.
it merely initializes and finalizes the c runtime stuff.
The "problem" is just windows related if there are no clibs in the path.
On linux it won't occur afaik.
« Last Edit: May 06, 2025, 10:37:56 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #14 on: May 06, 2025, 11:49:20 am »
Hi
@Thaddy: Nah, got a new quote, have we?!?  ;D
I'd have thought, The Toy Boys were censured listening, but you're right nifty little song THIS.
Thanks mate, for the blast from the past...  :D
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

 

TinyPortal © 2005-2018