error while loading shared libraries: ?: cannot open shared object file: No such file or directory

大城市里の小女人 提交于 2019-12-23 17:06:37

问题


I'm trying to diagnose (and fix) a problem that sits on the boundary of several components; any insights into how to either gain more information or outright resolve the issue is very much appreciated.

I have an application which starts as a C program that may launch a Java program and may then launch the same C program in a recursive fashion. It has been working on both Linux and Cygwin. Some bugs were found in the program launching paradigm within Java, and it was updated from the simpler Runtime strategy to the (new in 1.5) ProcessBuilder strategy. For various unsundry reasons, it launches bash with the -c option followed by whatever it is that needs to be called. It works on Linux, but when ported to Cygwin, it fails as described below. Unfortunately, I accidentally deleted the working Cygwin instance, so I can't readily discern if the issue is merely a configuration issue or something deeper.

For the record, I don't think there's anything wrong with Cygwin, but I'm not sure because I had foolishly updated Cygwin at the same time. (What was I thinking?!)

The error comes when Java is trying to launch the C program. It's always exactly the same error:

error while loading shared libraries: ?: cannot open shared object file: No such file or directory

Research on this error within cygwin yields nearly nothing, only this:
http://cygwin.com/ml/cygwin/2012-03/msg00396.html

Notably, tests running images that are a part of the standard Cygwin distribution run and work fine. In contrast, the program bs.exe is compiled and linked in the Cygwin environment.

Some things I was considering was if perhaps there are environment variables I've not included in the environment, but it's supposed to inherit the caller's environ, and I don't see that I've ever used any kind of LD_LIBRARY_PATH in cygwin environments in the past and didn't notice any similar references in the literature. Then, there's the Java policies, but that hasn't changed any from before, and when I added cygwin to the file, it didnt' help.

...I've run out of ideas... Anybody?

UPDATE: Here's a code excerpt of the ProcessBuilder code in Java:

public results ExecuteProgram(String program, String log)
{
   results r = new results();
   boolean returnString = false;
   if (Empty(log)) { log = getTempFile(); }
   File lf = null;
   ProcessBuilder pb;
   r.OK = true;
   r.err = "Unable to Run program: ";
   int status = 0; //Note that 0 = success!
   // Before we get here, we know the first space delimited substring
   // of the program string already has the full path to the program. The
   // rest (if any) are arguments.

   try
   { 
      // Shell contains something like /bin/bash, depending on the system
      //
      pb = new ProcessBuilder(Shell, "-c", program);

      // Map<String, String> env = pb.environment();
      // env.remove("PATH");
      // env.put("PATH", Path);
      // env.remove("CLASSPATH");
      // env.put("CLASSPATH", CLASSPATH);
      // env.remove("LD_LIBRARY_PATH");
      // env.put("LD_LIBRARY_PATH", LD_LIBRARY_PATH);
      // ALSO DO:
      // LD_LIBRARY_PATH

      pb.directory(new File(wd));
      pb.redirectErrorStream(true);
      lf = new File(log); 
      pb.redirectOutput(Redirect.appendTo(lf)); 
      Process p = pb.start();
      assert p.getInputStream().read() == -1;
      if (!returnString)
      {
         assert pb.redirectInput() == Redirect.PIPE;
         assert pb.redirectOutput().file() == lf;
      }
      r.err = "OS Process started."; 
      r.OK = true; 
      try 
      {   
         r.Status = p.exitValue(); 
         r.err = "OS Process completed."; 
      }   
      catch (IllegalThreadStateException e)   
      {   
      }   
   }
   catch (IOException e)
   {
      r.err += "\nIOException while accessing IO stream: "+
       e.toString();
      r.OK = false;
   }
   if ((r.Status == 0) && (r.OK))
   {
      r.err = "Success";
   } else {
      if (r.Status != 0)
      {
         r.err += "Process exit status: "+r.Status;
      }
      System.out.print(r.err);
   }
   return r;
}

Oh yes, and as per the usual, cygcheck -s information follows, snipped a little. More on request as the whole dataset is huge and probably uninteresting.

Cygwin Configuration Diagnostics Current System Time: Thu Dec 05 04:08:40 2013 Windows 7 Professional N Ver 6.1 Build 7600
Running under WOW64 on AMD64 Path: C:\Program Files\Java\jdk1.7.0\bin C:\opt\bin C:\cygwin\usr\local\bin C:\cygwin\bin C:\Program Files (x86)\Android\android-sdk\platform-tools C:\Program Files\PostgreSQL\9.3\bin C:\Program Files\Java\jdk1.7.0\bin C:\Program Files (x87)\PC Connectivity Solution C:\windows\system32 C:\windows C:\windows\System32\Wbem C:\windows\System32\WindowsPowerShell\v1.0 C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn C:\Program Files (x86)\Toshiba\Bluetooth Toshiba Stack\sys C:\Program Files (x86)\Toshiba\Bluetooth Toshiba Stack\sys\x64 C:\Program Files\Intel\WiFi\bin C:\Program Files\Common Files\Intel\WirelessCommon C:\cygwin\bin C:\Program Files\PostgreSQL\9.3\bin C:\cygwin\lib\lapack

Cygwin DLL version info: 
    DLL version: 1.8.4 
    DLL epoch: 19 
    DLL old termios: 5 
    DLL malloc env: 28
    Cygwin conv: 181 
    API major: 0 
    API minor: 262 
    Shared data: 5 
    DLL identifier: cygwin1 
    Mount registry: 3 
    Cygwin registry name: Cygwin 
    Program options name: Program Options
    Installations name: Installations  
    Cygdrive default prefix:
    Build date:
    Shared id: cygwin1S5
      <snip>

来源:https://stackoverflow.com/questions/20392789/error-while-loading-shared-libraries-cannot-open-shared-object-file-no-such

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!