0

I am trying to use the complex matrix operations of the armadillo library but my whole code base is in C. How can I make a wrapper for the existing cpp library.

I have gone through examples online and I am able to make the wrapper for my own cpp library but I am a bit confused regarding an existing library such as armadillo. I have gone through the link Using Eigen in a C Project

Here I am confused with the Library implementation part

/* foo.cpp */
#include "foo.h"
#include <iostream>
extern "C" {
void foo(int arg) {
  std::cout << arg << std::endl;
}
} /* extern "C" */

How am I supposed to change the library implementation of armadillo and include the wrapper headers to it?

Thanks

  • Come up with a set of functions that can be called from C that wrap the armadillo functions. Then apply the steps given in the question you linked. – dbush Oct 03 '18 at 17:19
  • Your code cannot be compiled by a C compiler, it is C++. Everything else in your question is about C. You tagged both. Please explain the special language-duality of your question, i.e. how this is both about C AND C++. – Yunnosch Oct 03 '18 at 17:26
  • @Yunnosch my code is written in c but I want to use some of the functions from armadillo which I want to call in my c program. – Sushant S Samuel Oct 03 '18 at 17:33
  • That should be called "Library Wrapper implementation". not "Library implementation". That code calls the library, it isn't the library. – stark Oct 03 '18 at 17:42
  • Can you post an example call to armadillo library function made in C++? – KamilCuk Oct 03 '18 at 19:43
  • The simplest solution would be to treat your C project as a C++ project. Bar a few minor differences, C++ can be essentially considered as a superset of C. – hbrerkere Oct 04 '18 at 00:46

0 Answers0