• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Ubuntu and ld.so.conf vs LD_LIBRARY_PATH and java.library.path

 
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the title made sense to you, you probably already understand but here's the problem.

I use NetBeans for development but any Java application that is started by the launcher has this problem.

Java searches for external dynamic libraries based on java.library.path which is set when the JVM starts from LD_LIBRARY_PATH. But Ubuntu doesn't let us set LD_LIBRARY_PATH anywhere except in the user's .profile (or .cshrc..) so it's not available to anything run from the application launcher.

Java doesn't use ld.so.conf and bash doesn't allow dots (.) in environment variable names.

There must be a way to affect LD_LIBRARY_PATH or java.library.path for programs started by the launcher but I can't find it.

Has anyone solved this? I have come up with a few work-arounds that work for development but none I'd like to include in a release.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have my Ubuntu machine here, but I think it works like this on Ubuntu:

In /etc/ld.conf.d (the name of a directory; I'm not 100% sure this is right) there are little text files that contain library paths. The linker, ld, has a cache somewhere that is built up from those files. You can add a text file yourself in that directory (ofcourse you have to be root to put it there) with the path to your native library. After you did that, run sudo ldconfig to rebuild the cache for the linker.

See man ldconfig for more details.
 
Joe Areeda
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct for most programs BUT as far as I can tell Java does not use ld.so.conf. Let's see if I can prove or disprove that.

here's a test program:

We can verify ld.so.conf is configured correctlty with the command ldconfig -v

It outputs all the library directories and libraries configured. Edited output:


if LD_LIBRARY_PATH is not set the program produces:


If I set LD_LIBRARY_PATH, though I get:


So as far as I can tell System.loadLibrary does not use the path set by ld.so.conf

Joe
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic