How to use existing C++ code with external library in MATLAB
9 ビュー (過去 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!