Recent

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

Thaddy

  • Hero Member
  • *****
  • Posts: 18305
  • Here stood a man who saw the Elbe and jumped it.
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #30 on: September 02, 2025, 10:53:52 am »
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}
  2. uses
  3.   sysutils, classes, process;
  4. var
  5.   gnupath:TProcess;
  6.   cfg:TStringlist;
  7. begin
  8.   gnupath := TProcess.Create(nil);
  9.   gnupath.Options := [poUsePipes,poWaitOnExit];
  10.   gnupath.executable := 'gcc';
  11.   gnupath.parameters.add('--print-libgcc-file-name');
  12.   gnupath.execute;
  13.   cfg := TStringlist.Create;
  14.   cfg.LoadFromStream(gnupath.Output);
  15.   writeln('-Fl'+extractfilepath(cfg.text));// add to fpc.cfg if it is not already there.
  16.   cfg.free;
  17.   gnupath.free;
  18. end.
         
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #31 on: September 02, 2025, 10:57:57 am »
I have this in my automatic build script for trunk:

Code: Bash  [Select][+][-]
  1. # sudo find / -name crtbegin.o
  2. # This library needs to be added to the fpc.cfg file.
  3.  
  4. cat << EOF >> $HOME/.fpc.cfg
  5. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget
  6. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget/*
  7. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget/rtl
  8. -Fl$(dirname $(gcc --print-file-name=crtbegin.o))
  9. -FD$BASE/fpc/bin
  10. EOF

So with gcc --print-file-name=crtbegin.o you get the correct directory.

(The parameter --print-libgcc-file-name Thaddy gave will probably be pointing to the same directory in 99,9999% of the cases.)

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #32 on: September 02, 2025, 11:18:00 am »
Cool stuff. 

I'm trying to get away from maintaining my own out of tree build of FPC .
Can these mods be included in the official tree?


Thaddy

  • Hero Member
  • *****
  • Posts: 18305
  • Here stood a man who saw the Elbe and jumped it.
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #33 on: September 02, 2025, 12:24:30 pm »
@rvk
Don't forget to add crtend as well
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #34 on: September 02, 2025, 12:33:00 pm »
@rvk
Don't forget to add crtend as well
Haha, I assumed crtend.o is in the same directory as crtbegin.o — but I guess that’s also 'only' true 99.9999% of the time   :D

PeterBB

  • Jr. Member
  • **
  • Posts: 84
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #35 on: September 03, 2025, 10:02:49 pm »
On Linux systems with fpc installed there is usually a tool fpcmkcfg

It writes out a default config file to stdout. It will have the current gcc versions in it.

Try
Code: [Select]
man fpcmkcfg

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #36 on: September 03, 2025, 10:25:05 pm »
If I run that command here is part of the output:

Code: Pascal  [Select][+][-]
  1. # searchpath for tools
  2. -FD/bin/$FPCTARGET
  3.  
  4. # path to the gcclib
  5. #ifdef cpui386
  6. -Fl/usr/lib/gcc/x86_64-redhat-linux/15/32
  7. #endif
  8. #ifdef cpux86_64
  9. -Fl/usr/lib/gcc/x86_64-redhat-linux/15
  10. #endif
  11.  
  12. # searchpath for libraries
  13. #-Fl/lib
  14. #-Fl/lib;/usr/lib
  15. -Fl/lib/$FPCTARGET
  16.  

cf
Code: Pascal  [Select][+][-]
  1. gcc --print-libgcc-file-name
  2. /usr/lib/gcc/x86_64-redhat-linux/15/libgcc.a
  3.  

However something seems to filter this out of my /etc/fpc.cfg.
Code: Pascal  [Select][+][-]
  1. # searchpath for fppkg user-specific packages
  2. -Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/*
  3.  
  4. # path to the gcclib
  5.  
  6.  
  7. # searchpath for libraries
  8. #IFDEF CPU64
  9. #-Fl/usr/lib64/fpc/$fpcversion/lib
  10. #-Fl/lib64;/usr/lib64
  11. -Fl/usr/lib64/fpc/$fpcversion/lib/$FPCTARGET
  12. #ELSE
  13. #-Fl/usr/lib/fpc/$fpcversion/lib
  14. #-Fl/lib;/usr/lib
  15. -Fl/usr/lib/fpc/$fpcversion/lib/$FPCTARGET
  16. #ENDIF
  17.  
« Last Edit: September 03, 2025, 10:32:41 pm by lazer »

PeterBB

  • Jr. Member
  • **
  • Posts: 84
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #37 on: September 03, 2025, 10:59:48 pm »
How about someone puts in the fpc.cfg

The first few lines of my /etc/fpc.cfg are;

Code: [Select]
#
# Config file generated by fpcmkcfg on 3-9-25 - 10:37:08
# Example fpc.cfg for Free Pascal Compiler
#

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #38 on: September 03, 2025, 11:12:29 pm »
Code: Pascal  [Select][+][-]
  1. head /etc/fpc.cfg
  2. #
  3. # Config file generated by fpcmkcfg on 10-5-25 - 15:52:40
  4. # Example fpc.cfg for Free Pascal Compiler
  5. #
  6.  
  7.  

This is old. I reinstalled fpc today. Maybe its been changed.

PeterBB

  • Jr. Member
  • **
  • Posts: 84
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #39 on: September 03, 2025, 11:13:44 pm »
However something seems to filter this out of my /etc/fpc.cfg.
Code: Pascal  [Select][+][-]
  1. # searchpath for fppkg user-specific packages
  2. -Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/*
  3.  
  4. # path to the gcclib
  5.  
  6.  
  7. # searchpath for libraries
  8. #IFDEF CPU64
  9. #-Fl/usr/lib64/fpc/$fpcversion/lib
  10. #-Fl/lib64;/usr/lib64
  11. -Fl/usr/lib64/fpc/$fpcversion/lib/$FPCTARGET
  12. #ELSE
  13. #-Fl/usr/lib/fpc/$fpcversion/lib
  14. #-Fl/lib;/usr/lib
  15. -Fl/usr/lib/fpc/$fpcversion/lib/$FPCTARGET
  16. #ENDIF
  17.  

I wonder if that would happen if fpc was installed before gcc?
Or if some gcc libraries were missing at the time?


lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #40 on: September 04, 2025, 07:15:30 am »
No gcc is one of the first things I install on a new system. Long before thinking about fpc.

Also , I just removed distro fpc, renamed the old /etc/fpc.cfg and reinstalled fpc

Old and new configs are identical. I also notice that the bin and lib paths it sets do not exist , only units is populated.

Code: Pascal  [Select][+][-]
  1. ls /usr/lib64/fpc/*
  2. fpmkinst  msg  ppcx64  samplecfg  units
  3.  
« Last Edit: September 04, 2025, 07:20:18 am by lazer »

Thaddy

  • Hero Member
  • *****
  • Posts: 18305
  • Here stood a man who saw the Elbe and jumped it.
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #41 on: September 04, 2025, 09:36:34 am »
rvk wrote explicitly that his code needs to be added to /etc/fpc.cfg

But note that if you installed through fpcupdeluxe a different fpc.cfg may be used.
« Last Edit: September 04, 2025, 09:51:57 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #42 on: September 04, 2025, 09:56:01 am »
rvk wrote explicitly that his code needs to be added to /etc/fpc.cfg
In my script it was needed (way back in 2018).

But looking back... it seems that now I have duplicate lines of the gcc lib.
Code: Bash  [Select][+][-]
  1. # cat ./.fpc.cfg | grep 12
  2. -Fl/usr/lib/gcc/aarch64-linux-gnu/12
  3. -Fl/usr/lib/gcc/aarch64-linux-gnu/12

I'm not sure if that's always been the case. Could it be that the addition of "# path to the gcclib" by fpcmkcfg???

My script is from before 2018 and maybe fpcmkcfg wasn't adding then yet.
I can remember adding this to my script because of the errors of missing crtbegin.o and crtend.o.

Or could it be the ifdefs don't always trigger that line?
Code: Text  [Select][+][-]
  1. # path to the gcclib
  2. #ifdef Linux
  3. #ifdef cpuaarch64
  4. -Fl/usr/lib/gcc/aarch64-linux-gnu/12
  5. #endif
  6. #endif


rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #43 on: September 04, 2025, 10:05:48 am »
Ha, my script was even from before 2016. I see in very old instructions I used to use samplecfg.
Maybe the samplecfg didn't add that line and it was then when I added those lines myself.

So I can probably remove that last line I add to the fpc.cfg from my script.

Thausand

  • Sr. Member
  • ****
  • Posts: 389
Re: SOLVED: Warning: "crtbegin.o" not found, this will probably ca
« Reply #44 on: September 04, 2025, 10:06:25 am »
I'm not sure if that's always been the case. Could it be that the addition of "# path to the gcclib" by fpcmkcfg???
No always be case but (recent) fpcmkcfg now make gcc path (depend on what use template, default template make gcc path).


 

TinyPortal © 2005-2018