uzh-rpg/high_mpc

CommonExternal: Cannot open "./mpc/saved/mpc_v1.so". Error code (WIN32): 126

Closed this issue · 5 comments

On Windows 10 and Pycharm, when running run_mpc.py, there was an error as indicated by the title.
File "D:\Anaconda\envs\python36\lib\site-packages\casadi\casadi.py", line 16673, in nlpsol return _casadi.nlpsol(*args)
RuntimeError: .../casadi/core/importer_internal.cpp:229: Assertion "handle_!=0" failed:
CommonExternal: Cannot open "./mpc/saved". Error code (WIN32): 126
The reason for it should be that mpc_v1.so was generated on Linux and could not be recognized by Windows?
Then how to get a mpc_v1.dll by compilation given that there is only a mpc_v1.c without any more files, for example a mpc_v1.h?

hi,

in https://github.com/uzh-rpg/high_mpc/blob/master/high_mpc/mpc/mpc.py,

you can comment out the line that tries to load the precompiled mpc, but use jit compilation.
as following

         self.solver = ca.nlpsol("solver", "ipopt", nlp_dict, ipopt_options)
         # jit (just-in-time compilation)
        print("Generating shared library........")
        cname = self.solver.generate_dependencies("mpc_v1.c")  
        system('gcc -fPIC -shared -O3 ' + cname + ' -o ' + self.so_path) # -O3
        
        # # reload compiled mpc
        # print(self.so_path)
        # self.solver = ca.nlpsol("solver", "ipopt", self.so_path, ipopt_options)

Thanks. I have done what you said. Although I have not installed gcc or MinGW on my Windows, the above error disappeared and no errors were reported. The terminal got the following content:

`Generating shared library........
'gcc' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.


This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt


0.07002854347229004
0.05401182174682617
0.06301426887512207
more numbers here...`

So does it work normally?

it is fine. I am not familiar with Windows.

But basically, you can also comment this line out

       # print("Generating shared library........")
       # cname = self.solver.generate_dependencies("mpc_v1.c")  
       # system('gcc -fPIC -shared -O3 ' + cname + ' -o ' + self.so_path) # -O3

In this case, the only difference is that your code will be slower. But, the result will be the same

Thanks. It indeed works. But it's a pity that the .so file or .dll file (compiled on my Windows) cannot be used even if I tried the external funciton of casadi according to the official documentation.

Finally, it worked. Just to compile these .c files into 64-bit .dll files. Because my python is a 64-bit one.