BookmarkSubscribeRSS Feed
harmonic
Obsidian | Level 7

Hello,

 

I installed Sas Analytics pro in a Linux virtual machine and I am trying to run a C++ code using call system function.

 

I updated the file C++ from docker desktop because I don't know how to mount the local C disk to the container docker.

 

Running this code 

 

data _null_;
call system("pwd");
run;

I find my directory:

Current working directory is '/tmp/SAS_work188200000688_sas-analytics-pro/SAS_work26F300000688_sas-analytics-pro'.

 

And to run my C++ code I am using this command that works in the linux shell but not from the docker shell and in Sas Studio.

filename oscmd pipe "/tmp/C/bld/Gross_test_01";
data _null_;
infile oscmd;
input;
put _infile_;
run;

 

Pipe command="/tmp/C/bld/Gross_test_01 "
/tmp/C/bld/Gross_test_01: error while loading shared libraries: libgross.so: cannot open shared object file: No such file or directory
 
It seems that can't be possible navigate in the directories because the file libgross.so is present. My directory is

 

fabiopuddu_0-1700211246645.png

 

1. Anyone knows how to mount a C: local drive or what is the kind of problem that I can't run that file from the directory?

 

19 REPLIES 19
Kurt_Bremser
Super User

Issue the command set in the Linux shell to get the current settings of all environment variables, then run set from SAS with the PIPE method and look at the differences.

harmonic
Obsidian | Level 7

I run the set command, which environment variables should I check?

harmonic
Obsidian | Level 7

Hello, here I put some variable but I don't know which differences are part of my issue.

 

fabiopuddu_2-1700645086755.png

 

 

Kurt_Bremser
Super User

What catches my attention is your massive PATH in the Linux commandline. I suspect the problem is there.

Also check if the current working directory (PWD) has an effect; issue a cd command before you run your C++ program.

Sajid01
Meteorite | Level 14

Hello @harmonic 
Your error message indicates that the library libgross.so is not accessible. Either it is missing OR is not reachable.
Make sure you are able to run the C++ code from the command line in the same folder that the code is running using X Commands.
Make sure the user id is the same as that runs the SAS code.
If you are not able to run from the command line please post the output.

 

harmonic
Obsidian | Level 7

 

/*test1*/
filename oscmd pipe "pwd &&  ./Gross_test_01 0.95419 0.00674 0.00367 0.02649 0.00645 0.00097 0.00096 0.00019 0.00015 0.00018 0 0 0 0 0 0.00001 0 0 0 0.00002 0 288.15 5701.325";

data _null_;
infile oscmd;
input;
put _infile_;
run;

/*
NOTE: The infile OSCMD is:
Pipe command="pwd & ./Gross_test_01 0.95419 0.00674 0.00367 0.02649 0.00645 0.00097 0.00096 0.00019 0.00015 0.00018 0 0 0 0
0 0.00001 0 0 0 0.00002 0 288.15 5701.325"
/tmp/C/bld
./Gross_test_01: error while loading shared libraries: libgross.so: cannot open shared object file: No such file or directory
NOTE: 2 records were read from the infile OSCMD.
*/

/* test2*/ data _null_; call system('./Gross_test_01 0.95419 0.00674 0.00367 0.02649 0.00645 0.00097 0.00096 0.00019 0.00015 0.00018 0 0 0 0 0 0.00001 0 0 0 0.00002 0 288.15 5701.325'); call system("pwd"); call system("cd .."); call system("cd .."); call system("pwd"); call system("cd C/bld/"); call system("pwd"); call system('./Gross_test_01 0.95419 0.00674 0.00367 0.02649 0.00645 0.00097 0.00096 0.00019 0.00015 0.00018 0 0 0 0 0 0.00001 0 0 0 0.00002 0 288.15 5701.325'); run;

/*NOTE: Current working directory is '/tmp/SAS_work2E8D0000128D_sas-analytics-pro/SAS_work1CCF0000128D_sas-analytics-pro'.
NOTE: Current working directory is '/tmp'.
NOTE: Current working directory is '/tmp/C/bld'.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
*/

I tried different ways, in the first test I tried to go to the path and run the script but I got the error.

In the second test I don't get any error but it doesn't make any sense because in the first command I am not in the path where the c++ is located when I run the program but I don't see any error.

 

@Sajid01 user id is sasdemo by default but I tried from root as well:

fabiopuddu_0-1700741335174.png

 

 

Kurt_Bremser
Super User

Expand the PATH with the entries in the commandline PATH.

Add this to your command:

export PATH=$PATH:<insert the additional entries here>;cd /tmp/C/bld;./Gross_test_01 0.95419 0.00674 0.00367 0.02649 <and so on>
harmonic
Obsidian | Level 7
Should I use this command from the docker shell, in the container where sas pro is installed?
Sajid01
Meteorite | Level 14

Hello @harmonic

To give a feasible solution one needs an understanding of the environment you are in.
As I understand it,you have SAS Analytics proc on installed on Linux operating system in a virtual machine.
C++ is expected to be installed here.
I would recommend the following steps to start with.
Login to the VM (either directly or using SSH) as sasdemo (the account you are using to run the sas code).
From the commandline run the following commands to see if the library is available.

Check if libgross.so is available.
ldconfig -p | grep libgross.so
If there is no output then you have missing libgross.so

Check if you have gcc is installed
ls /usr/bin | grep c++
if there is no output c++ is not installed.

Install C++. Follow you distributions instructions.

In case you have everything available (libgross.so , c++) go to the folder wherever Gross_test_01 exists and try running it.
Needless to say C++ works as smoothly as SAS if everything is correct.

harmonic
Obsidian | Level 7

In the linux shell I can run the code.  This is my output:

 

fabiopuddu_0-1700755790629.png

My problem is that in the shell in the Docker and in sas studio I can't run this program. I have to say that I uploaded all the directories c++ from docker desktop in the virtual path because I can't find it in my local machine.

From the docker shell (white one) I can see sasdemo user, but from my linux shell (black one) not.

fabiopuddu_1-1700756254412.png

fabiopuddu_2-1700756283267.png

 

fabiopuddu_4-1700756527975.png

 

 

fabiopuddu_3-1700756502624.png

 

 

Sajid01
Meteorite | Level 14

Hello @harmonic 
Thanks for the quick response.
In addition to the binaries and libraries, the configuration  and environment variables would also be needed. That gets done when one installs the c++ natively in the docker. I don't know if that is feasible in the docker container at your end.

If this is SAS provided docker find out from them if c++/ development  can be installed in the docker container.

For the present I have the following suggestions.
Please run the command ldconfig in docker container. It creates the necessary links.
Then please try running your code.

If that does not work, create the executable for  Gross_test_01 with static linking of all the libraries. That includes the libraries in the executable and it should be execute in the container.

Necessary requirement for static linking is that the version of the OS should be identical in the container .and where the executable is  generated.

harmonic
Obsidian | Level 7

Did you mean that the main problem is the c++ doesn't work in the container? 

Linux shell

fabiopuddu_0-1700818542322.png


Container shell

fabiopuddu_0-1700818652289.png

 

Sajid01
Meteorite | Level 14

Hello @harmonic 
"Did you mean that the main problem is the c++ doesn't work in the container? " No. I don't mean that.

In fact the executable Gross_test_01 is executing.

Your executable program Gross_test_01 needs to find the library libgross.so for dynamic linking at run time, but cannot find it.

This is happening because apparently  c++ has not been installed in the container.Even though you have copied c++ folders, the links and relevant path/env variable information has not been updated.

(This is what you said " I updated the file C++ from docker desktop because I don't know how to mount the local C disk to the container docker".

"I uploaded all the directories c++ from docker desktop in the virtual path because I can't find it in my local machine".)

Did you get a chance to read my past two posts?

One last things try everything only on a dev system.

 

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 3278 views
  • 0 likes
  • 3 in conversation