How to use existing C++ code with external library in MATLAB
11 次查看(过去 30 天)
显示 更早的评论
I got a C++ code (writen in Unix and compiled by gcc, works fine). The code uses the head files in the boost library, which I have installed in my Windows system. The main function of the code requires inputs of two file names, and write the solution a default text file.
Now, I want to use it in MATLAB under Windows OS. I have searched around and found maybe Mex could achieve this. But I have two difficulties:
- The return of the main function is void type. How to deal with this?
- It always complains that the head files from the boost library can't be found.
Thank you.
Part of the codes:
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <iostream>
#include <iomanip>
int main(int argc, char**argv) {
mallopt(M_MMAP_MAX, 0);
mallopt(M_TRIM_THRESHOLD, -1);
.......
......
print_summary(std::cout, attained_measures_precision_time);
if (out_base_name.compare("") != 0) {
std::string nome(out_base_name + "_paths.txt");
std::ofstream res_file(nome.c_str());
save_path_flows_solution(g, centroids, res_file, paths_matrix, D, all_centroids, p_star, edge_matrix);
res_file.close();
}
return 0;
}
2 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 C Shared Library Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!