필터 지우기
필터 지우기

How do I resolve Invalid MEX-file 'C:\Users\​s0001581\D​ownloads\m​ex_example​1.mexw64': The specified module could not be found.

조회 수: 20 (최근 30일)
/*
After building a Mex file I get the following "error Invalid MEX-file 'C:\Users\s0001581\Downloads\mex_example1.mexw64': The specified %module could not be found. " when calling the created Mex function. The Mex file works if I don't include the line "Alpha_shape_2 %A(points.begin(), points.end(), FT(10000), Alpha_shape_2::REGULARIZED);" which is a function from the CGAL library. %Other functions from the same library don't give this error.
The command line used to create the mexfile is the following:
"mex -v mex_example1.cpp -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um" -LC:\Users\s0001581\C++\Optimus\vcpkg\installed\x64-windows\lib -lboost_chrono-vc140-mt -lboost_date_time-vc140-mt -lboost_filesystem-vc140-mt -lboost_iostreams-vc140-mt -lboost_system-vc140-mt -lboost_thread-vc140-mt -lbrotlicommon -lbrotlidec -lbrotlienc -lbz2 -ldouble-conversion -lfreetype -lgmp -lgmpxx -lharfbuzz-subset -lharfbuzz -licudt -licuin -licuio -licutu -licuuc -ljpeg -llibcrypto -llibpng16 -llibssl -llzma -lmpfr -lpcre2-16 -lpcre2-32 -lpcre2-8 -lpcre2-posix -lpkgconf -lturbojpeg -lyasm -lzlib -lzstd"
Below is the code used
*/
#include "mex.hpp"
#include "mexAdapter.hpp"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Alpha_shape_2.h>
#include <CGAL/Alpha_shape_vertex_base_2.h>
#include <CGAL/Alpha_shape_face_base_2.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/algorithm.h>
#include <CGAL/assertions.h>
#include <fstream>
#include <iostream>
#include <list>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
typedef K::Point_2 Point;
typedef K::Segment_2 Segment;
typedef CGAL::Alpha_shape_vertex_base_2<K> Vb;
typedef CGAL::Alpha_shape_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
typedef CGAL::Delaunay_triangulation_2<K, Tds> Triangulation_2;
typedef CGAL::Alpha_shape_2<Triangulation_2> Alpha_shape_2;
typedef Alpha_shape_2::Alpha_shape_edges_iterator Alpha_shape_edges_iterator;
typedef K::Point_2 Point_2;
typedef std::vector<Point_2> Points;
using namespace matlab::data;
using matlab::mex::ArgumentList;
class MexFunction : public matlab::mex::Function {
public:
void operator()(ArgumentList outputs, ArgumentList inputs) {
ArrayFactory factory;
TypedArray<double> x = std::move(inputs[0]);
TypedArray<double> y = std::move(inputs[1]);
TypedArray<double> shrink_factor = std::move(inputs[2]);
std::list<Point> points;
std::vector<double> x_pos{ 0.814723686393179,0.905791937075619,0.126986816293506,0.913375856139019,0.632359246225410,0.0975404049994095,0.278498218867048,0.546881519204984,0.957506835434298,0.964888535199277,0.157613081677548,0.970592781760616,0.957166948242946,0.485375648722841,0.800280468888800,0.141886338627215,0.421761282626275,0.915735525189067,0.792207329559554,0.959492426392903,0.655740699156587,0.0357116785741896,0.849129305868777,0.933993247757551,0.678735154857774,0.757740130578333,0.743132468124916,0.392227019534168,0.655477890177557,0.171186687811562,0.706046088019609,0.0318328463774207,0.276922984960890,0.0461713906311539,0.0971317812358475,0.823457828327293,0.694828622975817,0.317099480060861,0.950222048838355,0.0344460805029088,0.438744359656398,0.381558457093008,0.765516788149002,0.795199901137063,0.186872604554379,0.489764395788231,0.445586200710900,0.646313010111265,0.709364830858073,0.754686681982361,0.276025076998578,0.679702676853675,0.655098003973841,0.162611735194631,0.118997681558377,0.498364051982143,0.959743958516081,0.340385726666133,0.585267750979777,0.223811939491137 };
std::vector<double> y_pos{ 0.751267059305653,0.255095115459269,0.505957051665142,0.699076722656686,0.890903252535799,0.959291425205444,0.547215529963803,0.138624442828679,0.149294005559057,0.257508254123736,0.840717255983663,0.254282178971531,0.814284826068816,0.243524968724989,0.929263623187228,0.349983765984809,0.196595250431208,0.251083857976031,0.616044676146639,0.473288848902729,0.351659507062997,0.830828627896291,0.585264091152724,0.549723608291140,0.917193663829810,0.285839018820374,0.757200229110721,0.753729094278495,0.380445846975357,0.567821640725221,0.0758542895630636,0.0539501186666072,0.530797553008973,0.779167230102011,0.934010684229183,0.129906208473730,0.568823660872193,0.469390641058206,0.0119020695012414,0.337122644398882,0.162182308193243,0.794284540683907,0.311215042044805,0.528533135506213,0.165648729499781,0.601981941401637,0.262971284540144,0.654079098476782,0.689214503140008,0.748151592823710,0.450541598502498,0.0838213779969326,0.228976968716819,0.913337361501670,0.152378018969223,0.825816977489547,0.538342435260057,0.996134716626886,0.0781755287531837,0.442678269775446 };
for (int i = 0; i < x_pos.size(); ++i) {
points.push_back(Point(x_pos[i], y_pos[i]));
}
Alpha_shape_2 A(points.begin(), points.end(), FT(10000), Alpha_shape_2::REGULARIZED);
outputs[0] = x;
outputs[1] = y;
}
};

답변 (1개)

Jinal
Jinal 2023년 11월 15일
편집: Jinal 2023년 11월 15일
Hello Anton,
As per my understanding, you are encountering ‘Invalid MEX File’ error when executing a C++ MEX file.
This error typically occurs when MATLAB cannot load the MEX file specified in the error message, because MATLAB cannot find all DLL files referenced by the MEX file.
In this case, MATLAB is unable to find the dependent libraries for the 'mex_example1' module.
A possible workaround for resolving the issue you are facing is as follows:
  • Find the names of the dependent libraries for the MEX file.
  • To find library dependencies on Windows, you can download the third-party utility ‘Dependency Walker’ from the following link: https://www.dependencywalker.com/
  • Once you have identified the dependent libraries, determine if the dependent libraries are present on your system and on the system path.
Please refer the following documentation page for more information on how to resolve ‘Invalid MEX File’ error: https://in.mathworks.com/help/releases/R2022a/matlab/matlab_external/invalid-mex-file-error.html
I hope that this helps resolve the issue you are facing.

카테고리

Help CenterFile Exchange에서 Write C++ Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by