LIbrary path for linker

Hardware, coding, music, graphic and various applications

Moderators: Mug UK, moondog/.tSCc., [ProToS], lp, Moderator Team

jury
Captain Atari
Captain Atari
Posts: 350
Joined: Tue Sep 21, 2004 11:11 am
Location: Poland

LIbrary path for linker

Postby jury » Tue Mar 12, 2019 8:54 am

I got bit confused. Up until now, I thought that when cross-compiling something for like 68020-60 architecture, I just provide the "base" library path and according to architecture for which the code is being build the linker takes proper libraries. I mean that I just provide like "/home/jury/sdl_stuff/lib" and linker will take the proper libraries according to the architecture of compilation/building.
But now I came across m0n0 site regarding coldfire Grafx2 and I see that the libraries are provided with the whole path like "/usr/m68k-atari-mint/lib/m5475/"
https://freeshell.de/~monokrom/geeklog/ ... uery=grafx

Does that mean that when I provided just the base path ( /home/jury/sdl_stuff/lib ) everything was compiled for the 68020-60 architecture, but those object files where linked with 68000 "outer" libraries?

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 568
Joined: Sun Aug 03, 2014 5:54 pm

Re: LIbrary path for linker

Postby ThorstenOtto » Tue Mar 12, 2019 10:22 am

No, when using certain options, the linker is told to look in certain sub-directories of the base path. You only have to take care of that yourself, when invoking ld directly, not when using gcc. And you should make sure that the library of your target is actually available, otherwise it will default to the base path.

You can use certain features of gcc to check the configuration:
  • m68k-atari-mint-gcc -print-multi-lib
    will print a list of mapping between options and sub-directories to look at
  • m68k-atari-mint-gcc -mcpu=5475 -print-file-name=libc.a
    will print the full pathname of the library actually used.

jury
Captain Atari
Captain Atari
Posts: 350
Joined: Tue Sep 21, 2004 11:11 am
Location: Poland

Re: LIbrary path for linker

Postby jury » Tue Mar 12, 2019 10:47 am

Got it. Thank you.

mikro
Hardware Guru
Hardware Guru
Posts: 1937
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: LIbrary path for linker

Postby mikro » Tue Mar 12, 2019 4:00 pm

I either did not understand Thorsten's answer or Jury's question ;) but I think gcc doesn't behave like that.

When we are talking about system paths (i.e. the ones which gcc was configured with, like /usr/lib) then yes, gcc -mcpu=your_cpu is the only thing you have to care about.

But if you have a separate directory with someone else's libs, you definitely have to manually enter -L/your/custom/path/including/m68020-60 because the directory selection algorithm based on -mcpu doesn't apply here. What you provide as a search path, that is searched, period.

When doing the final build, I recommend adding -Wl,-t to gcc command line, that way you will see *all* libraries and objects files linked into the executable.

jury
Captain Atari
Captain Atari
Posts: 350
Joined: Tue Sep 21, 2004 11:11 am
Location: Poland

Re: LIbrary path for linker

Postby jury » Tue Mar 12, 2019 4:42 pm

mikro wrote:When we are talking about system paths (i.e. the ones which gcc was configured with, like /usr/lib) then yes, gcc -mcpu=your_cpu is the only thing you have to care about.

But if you have a separate directory with someone else's libs, you definitely have to manually enter -L/your/custom/path/including/m68020-60 because the directory selection algorithm based on -mcpu doesn't apply here. What you provide as a search path, that is searched, period.


Yest, this is exactly the case I'm talking about. So now I understand that it means that even thou I was providing -m68020-60 and giving -L/home/jury/sdl_stuff/lib the linker did not go deeper and took the libraries exactly from the given path, so this means the 68000 ones.
As for -mcpu=, I have never used it, I always use -m68020-60. But long time ago I came across the description of -m, -mcpu= and -march= but I have not understood whats the difference between them. Must find that article and read it again.

mikro wrote:When doing the final build, I recommend adding -Wl,-t to gcc command line, that way you will see *all* libraries and objects files linked into the executable.

Thanks, will check this option.

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12669
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: LIbrary path for linker

Postby wongck » Tue Mar 12, 2019 10:59 pm

Not sure if this is a correct way (probably not as I am a noobe at anything deeply system related).
I have manually copied libs into the gcc respective default architecture folder (e.g /usr/lib/m5475 etc) depending on the lib architecture.
Of course I done this on native gcc and not the cross-compiler but may be the same for cross-compiler.

That -mcpu=5475 just says use the coldfire lib, which just looks to me like adding that "5475" to the end of default lib path to find coldfire lib.
Of course I see things simplified... it probably not just adding to the end of the path only but doing something more (maybe different optimisation).
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 568
Joined: Sun Aug 03, 2014 5:54 pm

Re: LIbrary path for linker

Postby ThorstenOtto » Wed Mar 13, 2019 2:23 am

Unfortunately, things for a native compiler are currently a bit different. If you are using the coldfire compiler from mikro (the one thats generates coldfire code by default), then the coldfire libs should got to /usr/lib, and the others to /usr/lib/m68000 resp. /usr/lib/m68020-60. So best thing is to trace the actually libraries used using one of the methods mentioned above.

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12669
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: LIbrary path for linker

Postby wongck » Wed Mar 13, 2019 5:54 am

Thanks Thorsten for reminding the compiler architecture & library mix-up.
Yes, i read about it being discussed on the mintlist.
I found that it was really very obvious that the standard lib location/folder should be the same architecture as for the compiler.
That's... if i am using a coldfile and compiling on a coldfire gcc I do not have to specify that I want a coldfire code, it's obvious. No need to specify anything else. But if I wanted 68000 code, then I have to specify.
But Coldfire is easy.... try CT63 using a 68000 gcc :roll:

ThorstenOtto wrote:So best thing is to trace the actually libraries used using one of the methods mentioned above.

Yes, or see which architecture your gcc is compiled for. :wink:

Again, I did not read any gcc source code, just anecdotal evidence.
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list


Social Media

     

Return to “Professionals”

Who is online

Users browsing this forum: No registered users and 2 guests