Issue with ruby compilation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Issue with ruby compilation

Luis C
Hi All,

I have some problems with a compilation of a basic program. This program is just an example that compiles by generating the code in python and ruby.

// FILE pepe.h
#include <iostream>
#include "json.hpp"

using namespace std;

class Pepe {

    Pepe() {}
    const char *get_foo();
};

// FILE pepe.cc
#include "pepe.h"

const char *Pepe::get_foo() {

    nlohmann::json j;

    j["hola"] = "adios";
    j["value"] = 12;

    std::stringstream o;
    o << j;

    return o.str().c_str();
}

// FILE make_pepe.sh
#!/bin/bash

# compilation for ruby
#swig -c++ -ruby pepe_wrapper.i
#g++ -fPIC -I/usr/include/ -I.. -I. --std=c++14 -c pepe.cc pepe_wrapper_wrap.cxx


# Compilation for python
swig -c++ -python pepe_wrapper.i
g++ -fPIC -I/usr/include/python2.7 -I.. -I. --std=c++14 -c pepe.cc pepe_wrapper_wrap.cxx


The compilation for python works and the file is correctly compiled but when I use the compilation for ruby I got an error on the std

[root@738934b3d807 src]# ./make_pepe.sh
In file included from pepe.h:2:0,
                 from pepe_wrapper_wrap.cxx:1860:
json.hpp: In static member function 'static void nlohmann::detail::external_constructor<(nlohmann::detail::value_t)7u>::construct(BasicJsonType&, typename BasicJsonType::number_float_t)':
json.hpp:275:17: error: 'finite' is not a member of 'std'
         if (not std::isfinite(val))
                 ^~~
json.hpp:275:17: note: suggested alternative:
In file included from /usr/include/features.h:368:0,
                 from /usr/include/string.h:25,
                 from pepe_wrapper_wrap.cxx:464:
/usr/include/bits/mathcalls.h:208:1: note:   'finite'

The json library is from (https://github.com/nlohmann/json)

Any ideas why that code is not compiling for ruby? Did I miss something on the interface file?

Regards,
Luis

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with ruby compilation

William S Fulton


On 10 March 2017 at 12:04, Luis C <[hidden email]> wrote:
Hi All,

I have some problems with a compilation of a basic program. This program is just an example that compiles by generating the code in python and ruby.

// FILE pepe.h
#include <iostream>
#include "json.hpp"

using namespace std;

class Pepe {

    Pepe() {}
    const char *get_foo();
};

// FILE pepe.cc
#include "pepe.h"

const char *Pepe::get_foo() {

    nlohmann::json j;

    j["hola"] = "adios";
    j["value"] = 12;

    std::stringstream o;
    o << j;

    return o.str().c_str();
}

// FILE make_pepe.sh
#!/bin/bash

# compilation for ruby
#swig -c++ -ruby pepe_wrapper.i
#g++ -fPIC -I/usr/include/ -I.. -I. --std=c++14 -c pepe.cc pepe_wrapper_wrap.cxx


# Compilation for python
swig -c++ -python pepe_wrapper.i
g++ -fPIC -I/usr/include/python2.7 -I.. -I. --std=c++14 -c pepe.cc pepe_wrapper_wrap.cxx


The compilation for python works and the file is correctly compiled but when I use the compilation for ruby I got an error on the std

[root@738934b3d807 src]# ./make_pepe.sh
In file included from pepe.h:2:0,
                 from pepe_wrapper_wrap.cxx:1860:
json.hpp: In static member function 'static void nlohmann::detail::external_constructor<(nlohmann::detail::value_t)7u>::construct(BasicJsonType&, typename BasicJsonType::number_float_t)':
json.hpp:275:17: error: 'finite' is not a member of 'std'
         if (not std::isfinite(val))
                 ^~~
json.hpp:275:17: note: suggested alternative:
In file included from /usr/include/features.h:368:0,
                 from /usr/include/string.h:25,
                 from pepe_wrapper_wrap.cxx:464:
/usr/include/bits/mathcalls.h:208:1: note:   'finite'

The json library is from (https://github.com/nlohmann/json)

Any ideas why that code is not compiling for ruby? Did I miss something on the interface file?

The owner of json.hpp is not including the appropriate header file or is expecting users to add in missing headers. I'm afraid that you need to know basic C++ like this in order to use C++ in SWIG.

William
 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with ruby compilation

Luis C
HI William,

Thanks for your response, However the json.hpp file compiles with the python interface with no issues. May be I didn't explain my self correctly, but on the example the python interface compiles with no problem and the ruby side is the one that have issues. That's why I post the problem here, on python and swig works perfect, but when I compiles in ruby I got that error. I make a test by generating a Lua interface and also compiles that's why I think is more on the ruby generation of the interface the issue.

Thanks and regards,
Luis

2017-03-17 19:12 GMT+00:00 William S Fulton <[hidden email]>:


On 10 March 2017 at 12:04, Luis C <[hidden email]> wrote:
Hi All,

I have some problems with a compilation of a basic program. This program is just an example that compiles by generating the code in python and ruby.

// FILE pepe.h
#include <iostream>
#include "json.hpp"

using namespace std;

class Pepe {

    Pepe() {}
    const char *get_foo();
};

// FILE pepe.cc
#include "pepe.h"

const char *Pepe::get_foo() {

    nlohmann::json j;

    j["hola"] = "adios";
    j["value"] = 12;

    std::stringstream o;
    o << j;

    return o.str().c_str();
}

// FILE make_pepe.sh
#!/bin/bash

# compilation for ruby
#swig -c++ -ruby pepe_wrapper.i
#g++ -fPIC -I/usr/include/ -I.. -I. --std=c++14 -c pepe.cc pepe_wrapper_wrap.cxx


# Compilation for python
swig -c++ -python pepe_wrapper.i
g++ -fPIC -I/usr/include/python2.7 -I.. -I. --std=c++14 -c pepe.cc pepe_wrapper_wrap.cxx


The compilation for python works and the file is correctly compiled but when I use the compilation for ruby I got an error on the std

[root@738934b3d807 src]# ./make_pepe.sh
In file included from pepe.h:2:0,
                 from pepe_wrapper_wrap.cxx:1860:
json.hpp: In static member function 'static void nlohmann::detail::external_constructor<(nlohmann::detail::value_t)7u>::construct(BasicJsonType&, typename BasicJsonType::number_float_t)':
json.hpp:275:17: error: 'finite' is not a member of 'std'
         if (not std::isfinite(val))
                 ^~~
json.hpp:275:17: note: suggested alternative:
In file included from /usr/include/features.h:368:0,
                 from /usr/include/string.h:25,
                 from pepe_wrapper_wrap.cxx:464:
/usr/include/bits/mathcalls.h:208:1: note:   'finite'

The json library is from (https://github.com/nlohmann/json)

Any ideas why that code is not compiling for ruby? Did I miss something on the interface file?

The owner of json.hpp is not including the appropriate header file or is expecting users to add in missing headers. I'm afraid that you need to know basic C++ like this in order to use C++ in SWIG.

William
 



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with ruby compilation

Luis C
Hi William and John,

The inclusion of the header file "math.h" solves the problem.

Thanks for your time and support!

Regards,
Luis

2017-03-18 20:57 GMT+00:00 Luis C <[hidden email]>:
HI William,

Thanks for your response, However the json.hpp file compiles with the python interface with no issues. May be I didn't explain my self correctly, but on the example the python interface compiles with no problem and the ruby side is the one that have issues. That's why I post the problem here, on python and swig works perfect, but when I compiles in ruby I got that error. I make a test by generating a Lua interface and also compiles that's why I think is more on the ruby generation of the interface the issue.

Thanks and regards,
Luis

2017-03-17 19:12 GMT+00:00 William S Fulton <[hidden email]>:


On 10 March 2017 at 12:04, Luis C <[hidden email]> wrote:
Hi All,

I have some problems with a compilation of a basic program. This program is just an example that compiles by generating the code in python and ruby.

// FILE pepe.h
#include <iostream>
#include "json.hpp"

using namespace std;

class Pepe {

    Pepe() {}
    const char *get_foo();
};

// FILE pepe.cc
#include "pepe.h"

const char *Pepe::get_foo() {

    nlohmann::json j;

    j["hola"] = "adios";
    j["value"] = 12;

    std::stringstream o;
    o << j;

    return o.str().c_str();
}

// FILE make_pepe.sh
#!/bin/bash

# compilation for ruby
#swig -c++ -ruby pepe_wrapper.i
#g++ -fPIC -I/usr/include/ -I.. -I. --std=c++14 -c pepe.cc pepe_wrapper_wrap.cxx


# Compilation for python
swig -c++ -python pepe_wrapper.i
g++ -fPIC -I/usr/include/python2.7 -I.. -I. --std=c++14 -c pepe.cc pepe_wrapper_wrap.cxx


The compilation for python works and the file is correctly compiled but when I use the compilation for ruby I got an error on the std

[root@738934b3d807 src]# ./make_pepe.sh
In file included from pepe.h:2:0,
                 from pepe_wrapper_wrap.cxx:1860:
json.hpp: In static member function 'static void nlohmann::detail::external_constructor<(nlohmann::detail::value_t)7u>::construct(BasicJsonType&, typename BasicJsonType::number_float_t)':
json.hpp:275:17: error: 'finite' is not a member of 'std'
         if (not std::isfinite(val))
                 ^~~
json.hpp:275:17: note: suggested alternative:
In file included from /usr/include/features.h:368:0,
                 from /usr/include/string.h:25,
                 from pepe_wrapper_wrap.cxx:464:
/usr/include/bits/mathcalls.h:208:1: note:   'finite'

The json library is from (https://github.com/nlohmann/json)

Any ideas why that code is not compiling for ruby? Did I miss something on the interface file?

The owner of json.hpp is not including the appropriate header file or is expecting users to add in missing headers. I'm afraid that you need to know basic C++ like this in order to use C++ in SWIG.

William
 




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...