'gsl/gsl' file not found, emscripten. HOw to include the ms-gsl library to be compiled when creating WASM from C++

369 Views Asked by At

I'm compiling some C++ with emscripten and I'm having a problem to use some features from gsl such as "Expects". The emcc can't find "gsl/gsl". How can I compile it with gsl?

Here is the header file:

#ifndef ROBOT_CPP_PWMTEST_H
#define ROBOT_CPP_PWMTEST_H

#include <iostream>
#include <gsl/gsl>

class PwmTest {

public:
    int duty_cycle_pwm_a;
    int duty_cycle_pwm_b;
    explicit PwmTest();
    ~PwmTest();
    int setPwmA(int duty_cycle);
    int getPwmA();
};


#endif //ROBOT_CPP_PWMTEST_H

Here is the source file:

#include "PwmTest.h"

PwmTest::PwmTest()
{
    duty_cycle_pwm_a = 0;
    duty_cycle_pwm_b = 0;
    std::cout << "PWM instance Created" << std::endl;
}

PwmTest::~PwmTest()
{
    std::cout << "PWM instance Destroyed" << std::endl;
}


int PwmTest::setPwmA(int duty_cycle)
{
    Expects(-1 < duty_cycle && duty_cycle <= 100);
    duty_cycle_pwm_a = duty_cycle;
    std::cout << "PWM A is set to " << duty_cycle_pwm_a << std::endl;
    return 0;
}

int PwmTest::getPwmA()
{
    std::cout << "PWM A value is: " << duty_cycle_pwm_a << std::endl;
    return duty_cycle_pwm_a;
}


#ifdef __EMSCRIPTEN__

#include <emscripten.h>
#include <emscripten/bind.h>

EMSCRIPTEN_BINDINGS(pwm_class_emscripten) {
    emscripten::class_<PwmTest>("PwmTest")
    .constructor<>()
    .function("setPwmA", &PwmTest::setPwmA)
    .function("getPwmA", &PwmTest::getPwmA)
    .property("duty_cycle_pwm_a", &PwmTest::duty_cycle_pwm_a)
    ;
}
#endif

It works if I take the gsl off of it.

0

There are 0 best solutions below