How to use existing C++ code with external library in MATLAB
조회 수: 12 (최근 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!