PHP Call Executable with Libraries

Years ago I created a linux executable with Xojo (formerly RealBasic) that would compile to a single file, let us call it Test. From a PHP script I could launch that executable with a command like this:


Later Xojo started building executables with an external folder named Test Libs that holds needed libraries instead of embedding them in the executable itself. With this new architecture, I can no longer launch the linux executable from a PHP script.

I have tried creating a console app, but still stores library files in the external Libs folder so they cannot be found when launching the executable from a PHP script.

I tried sudo to launch the executable with the root password, but that also fails to find the libraries.

Any ideas on how to launch a Xojo generated linux executable from PHP?

What about shell_exec(“/fully/qualified/path/to/Test”); ?

I tried the fully qualified path to Test, but it still won’t launch.

I also tried including sudo export LD_LIBRARY_PATH=’/path/to/lib

in the command but it also fails. I tried once with the path to the folder holding the library files and also tried with a full path to each library file separated with ;

Do you need to set the current working directory?

The php file and Xojo executable are in the same folder.

This php command returns the path of the folder holding both files.

echo getcwd() . “\n”;

When php launches the Xojo executable XYZ, it cannot find its library files which are in the XYZ Libs folder in that same folder.

Rename “XYZ Libs” to just “Libs” and try again. I had something like that in the past with Windows and the work around was this. Maybe related. If that does not help, check if the entire path includes non-ascii codes, like international chars like ç ã ü …

As suggested, I tried Rename “XYZ Libs” to just “Libs”, but it doesn’t work.

I tried putting the .so files in the same folder as the executable, but that doesn’t work.

In the PHP file, I even tried to set the current directory to the XYZ Libs folder before launching the executable which is called XYZ in the test folder, but that doesn’t work either.

chdir(’/var/www/html/test/XYZ Libs’);

It appears as if a Xojo linux executable uses some mechanism to locate its libraries files and that mechanism isn’t available when launched from PHP. It would seem that the Xojo people could document some kind of environment variable or something to make this work.

Does it run manually in the terminal?

cd /var/www/html/test


Yes, it runs when manually launched in terminal.

It also runs fine if I compile the same executable with a 10-year old version of Xojo that doesn’t use external library files.

See what

shell_exec('/var/www/html/test/XYZ  2>&1');

returns. Now it will capture errors sent to stderr.

You should also look into the system logs. Like

sudo tail /var/log/messages

Any chances of XYZ having user execution/read permissions differently of those in the Libs? So the process running XYZ, can load it, but can’t load whats in the Libs folder?

I just created a fresh XYZ do nothing linux app with a XYZ Libs folder using Xojo 2020 and now I can launch it from a PHP script. Now I’m trying to isolate why the real executable works with old RealBasic but fails with new Xojo.

Ok. Seems isolated to something in the program, not libs folder (unless you touch its contents manually, setting wrong permissions for example). Good luck with the research.

I think I have sorted it out. Years ago when Xojo began storing the library files externally I think there may have been an issue with the executable not finding the libraries. That now works fine with the new Xojo. Due to a deprecated feature in my old App, I had to make a change to compile with the new Xojo that introduced an exception during launch.

Now everything works as expected.