ldconfig

Index: makepanda/makepandacore.py                                                      
===================================================================                    
RCS file: /cvsroot/panda3d/makepanda/makepandacore.py,v                                
retrieving revision 1.119                                                              
diff -r1.119 makepandacore.py                                                          
1033c1033,1036                                                                         
<             handle = os.popen(LocateBinary("ldconfig") + " -NXp")                    
---                                                                                    
>             if (sys.platform.startswith("freebsd")):                                 
>                 handle = os.popen(LocateBinary("ldconfig"))                          
>             else:                                                                    
>                 handle = os.popen(LocateBinary("ldconfig") + " -NXp")

FreeBSDs ldconfig dont have NXp options.

Ah, right, I forgot that the BSD version of ldconfig does not have these options. I ran into that issue too when compiling on FreeBSD, but apparently I didn’t check in a fix.

I’ve just checked this fix - thanks!

Wait, I see you’re running ldconfig without any arguments. Is that right? I need to print out the cache, shouldn’t it be at least with -r ?

Yes. Also need minor changes to reading of output after that.

Index: makepanda/makepandacore.py                                                      
===================================================================                    
RCS file: /cvsroot/panda3d/makepanda/makepandacore.py,v                                
retrieving revision 1.119                                                              
diff -r1.119 makepandacore.py                                                          
1033c1033,1036                                                                         
<             handle = os.popen(LocateBinary("ldconfig") + " -NXp")                    
---                                                                                    
>             if (sys.platform.startswith("freebsd")):                                 
>                 handle = os.popen(LocateBinary("ldconfig") + " -r")                  
>             else:                                                                    
>                 handle = os.popen(LocateBinary("ldconfig") + " -NXp")                
1035,1039c1038,1050                                                                    
<             for line in result:                                                      
<                 lib = line.strip().split(" ", 1)[0]                                  
<                 if (".so " in lib):                                                  
<                     lib = lib.split(".so", 1)[0][3:]                                 
<                     LD_CACHE.append(lib)                                             
---                                                                                    
>             if (sys.platform.startswith("freebsd")):                                 
>                 for line in result:                                                  
>                     if (".so" in line):                                              
>                         lib = line.strip().split(" ", 1)[0]                          
>                         lib = lib.split(':', 1)[1][2:]                               
>                         lib = lib.split('.', 1)[0]                                   
>                         LD_CACHE.append(lib)                                         
>             else:                                                                    
>                 for line in result:                                                  
>                     lib = line.strip().split(" ", 1)[0]                              
>                     if (".so" in lib):                                               
>                         lib = lib.split(".so", 1)[0][3:]                             
>                         LD_CACHE.append(lib)

Are you sure that checks is correct ?

if (".so " in lib):                                               

I paste outputs from my linux machine:

        libzvbi.so.0 (libc6) => /usr/lib/libzvbi.so.0
        libzvbi-chains.so.0 (libc6) => /usr/lib/libzvbi-chains.so.0
        libzip.so.1 (libc6) => /usr/lib/libzip.so.1
        libz.so.1 (libc6) => /lib/libz.so.1
        libx264.so.67 (libc6) => /usr/lib/libx264.so.67
        ............

I think that space after .so is bad.

This is output and from BSD. I paste it if my code isn`t looks good for you :slight_smile:

/var/run/ld-elf.so.hints:
        search directories: /lib:/usr/lib:/usr/lib/compat:/usr/local/lib:/usr/local/lib/gcc44:/usr/local/lib/pth:/usr/local/lib/graphviz:/usr/local/lib/qt4
        0:-lc.7 => /lib/libc.so.7                                                                                                                          
        1:-lcrypt.5 => /lib/libcrypt.so.5                                                                                                                  
        2:-lkvm.5 => /lib/libkvm.so.5                                                                                                                      
        3:-lm.5 => /lib/libm.so.5                                                                                                                          
        4:-lmd.5 => /lib/libmd.so.5                                                                                                                        
        5:-lncurses.8 => /lib/libncurses.so.8
        ...

Great, thanks!

Yeah, the space after .so is necessary. We only want to pick up *.so, because those are the ones that can be linked, not .so.

Ahm, BSD don`t follow this rule … Something new for me … :slight_smile:

No, I mean that if I specify -lfoo at the linker command-line, it will only search for a libfoo.so, but not libfoo.so.1.2.3.
This is useful because you could have multiple versions of the same library around, without ambiguity which one should be linked (libfoo.so will be a symlink pointing to one of the versions).
Usually the development distribution of a library installs the libfoo.so symlink.

I don’t know how BSD does this actually. It looks like the entire concept of ldconfig is different - it appears to be a system for linker hints rather than a caching system.
Is there anything in the output of “ldconfig -r” that defines what happens if you simply link without a version number, or so? Or are there no entries in there for .so’s without version number?

You dont need to specify version number. Output of "ldconfig -r" just shows a lastest version of lib. ldconfig generates this "hints" file used by dynamic linker for quicker lookup of library(with lastest version). LD_LIBRARY_PATH isnt used(in particular). Can be used to override or to add other directories where linker to search for library. Also ldconfig is used to specify only safe directories from where shared libraries can be loaded.
So ldconfig scans around “specified” directories and looks for libraries with pattern lib*.so.[0-9], add them to hints file, and these libraries are ready to be used :slight_smile: There is and some security checks, but I don`t remember them.

Hm, I see. So the behavior when specifying “-lfoo” on the linker command-line could be ambiguous?

I’ll reboot into FreeBSD one of these days and experiment a bit to understand how it works there.
For now, makepanda will just scan the /lib, /usr/lib, /usr/local/lib, etc. dirs to find libraries on FreeBSD.

No. It`s just a bit smarter than linux one.(this is my opinion). And makes things quicker. :slight_smile: