How to use existing C++ code with external library in MATLAB
12 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on C Shared Library Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!