GDX init failed: Could not load shared library

12 views (last 30 days)
I am using Matlab 2022a and GAMS 42.0 and the following error is displayed when running the trnsport problem:
Error using gt_cmex_gdx_write
GDX init failed: Could not load shared library libgdxdclib64.dylib:
]dlopen(libgdxdclib64.dylib, 2): image not found
Error in GAMSTransfer.Container/write (line 551)
GAMSTransfer.gt_cmex_gdx_write(obj.gams_dir, filename, obj.data, ...
Error in setpath (line 49) m.write('trnsport.gdx');
Here is the code of the trnsport problem:
addpath("/Library/Frameworks/GAMS.framework/Versions/42/Resources/apifiles/Matlab/api")
import GAMSTransfer.*
% create an empty container
m = Container();
% add sets
i = Set(m, 'i', 'records', {'seattle', 'san-diego'}, 'description', 'canning plants');
j = Set(m, 'j', 'records', {'new-york', 'chicago', 'topeka'}, 'description', 'markets');
% add parameters
a = Parameter(m, 'a', i, 'description', 'capacity of plant i in cases');
b = Parameter(m, 'b', j, 'description', 'demand at market j in cases');
d = Parameter(m, 'd', {i,j}, 'description', 'distance in thousands of miles');
f = Parameter(m, 'f', 'description', 'freight in dollars per case per thousand miles');
c = Parameter(m, 'c', {i,j}, 'description', 'transport cost in thousands of dollars per case');
% set parameter records
a.setRecords([350, 600]);
b.setRecords([325, 300, 275]);
d.setRecords([2.5, 1.7, 1.8; 2.5, 1.8, 1.4]);
f.setRecords(90);
c.setRecords([0.225, 0.153, 0.162; 0.225, 0.162, 0.126]);
% add variables
x = Variable(m, 'x', 'positive', {i,j}, 'description', 'shipment quantities in cases');
z = Variable(m, 'z', 'description', 'total transportation costs in thousands of dollars');
% set variable records
% Note: Argument order is: level, marginal, lower, upper, scale.
x.setRecords([50, 300, 0; 275, 0, 275], [0, 0, 0.036; 0, 0.009, 0]);
z.setRecords(153.675);
% (optional) transform records into different format
x.transformRecords('table');
% add equations
cost = Equation(m, 'cost', 'e', 'description', 'define objective function');
supply = Equation(m, 'supply', 'l', i, 'description', 'observe supply limit at plant i');
demand = Equation(m, 'demand', 'g', j, 'description', 'satisfy demand at market j');
% set equation records
cost.setRecords(0, 1, 0, 0);
supply.setRecords(struct('level', [350, 550], 'marginal', [SpecialValues.EPS, 0], 'upper', [350, 600]));
demand.setRecords([325, 300, 275], [0.225, 0.153, 0.126], [325, 300, 275]);
% write data to a GDX file
m.write('trnsport.gdx');

Answers (1)

Sugandhi
Sugandhi on 25 Aug 2023
Hi,
I understand that you are getting error when using MATLAB 2022a and GAMS 42.0.
The error message you're encountering indicates that the GDX library in GAMS is unable to load the shared library libgdxdclib64.dylib. This library is required for GDX file operations in MATLAB.
To resolve this issue, try the following steps:
  1. Ensure that GAMS is properly installed and configured on your system. Make sure you have the correct version of GAMS that is compatible with MATLAB 2022a.
  2. Check if the libgdxdclib64.dylib library is present in the expected location. In this case, it should be in the /Library/Frameworks/GAMS.framework/Versions/42/Resources/apifiles/Matlab/api directory. Verify that the file exists in that location.
  3. If the library is missing, you may need to reinstall GAMS or repair the installation to ensure that all necessary files are present.
  4. If the library is present but still cannot be loaded, you might need to check your system's library search paths. Ensure that the directory containing the libgdxdclib64.dylib library is included in the appropriate search path for your operating system.
  5. If you're using macOS, you can try setting the DYLD_LIBRARY_PATH environment variable to include the directory containing the library.
  1 Comment
Yanda Jiang
Yanda Jiang on 2 Dec 2023
I tried what you suggested, but it still doesn't work. confused....

Sign in to comment.

Categories

Find more on Software Development Tools in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!