I have C++ code spread across multiple C++ and header files and wanted to know how to link them in ECL. Should I install them as libraries (.cpp and header files) into the local cluster I am running in order to import them into the main C++ embed code and use it OR is there any other way of linking embedded C++ code across ECL files?
To be more clear, suppose there's a helper.cpp with helper functions and helper.h with appropriate headers and we want to use them in our embedded C++ code. So how do we import these helper functions and their declarations into the main C++ embed program that we write? Is there a way to install them into the cluster we are using?
helpers.h
int sum(int , int);
helpers.cpp
#include "helpers.h"
int sum(int a, int b) {
return a+b;
}
main.cpp
#include "helpers.h"
#include<iostream>
using namespace std;
int main() {
cout<<sum(10,5);
return 0;
}
We are able to compile both helpers.cpp and main.cpp as g++ helpers.cpp main.cpp -o main
and run the executable using ./main
to get 15 as output. How do we move these 3 files to embedded C++ and include many more such files in the background?