Linking error while separating parser into _def and .cpp files

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Linking error while separating parser into _def and .cpp files

Exagon
I am currently trying to separate my parser inteo different files using BOOST_SPIRIT_DEFIND/DECLAR/INSTATIATE, but I keep getting a linker error.
I dont know what I am doing wrong, or if I am doing something wrong.
Could anybody help me?
HERE is a smal example, where I get the linker error.
Greetings Exagon
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

cppljevans
On 11/08/2016 01:13 PM, Exagon wrote:
> I am currently trying to separate my parser inteo different files using
> BOOST_SPIRIT_DEFIND/DECLAR/INSTATIATE, but I keep getting a linker error.
> I dont know what I am doing wrong, or if I am doing something wrong.
> Could anybody help me?
> HERE <http://melpon.org/wandbox/permlink/iSEDrjYf14SvKKWe>   is a smal
> example, where I get the linker error.
> Greetings Exagon
>
Exagon, FWIW, I'm getting a similar error about parse_rule being
undefined; however, mine is with the code which Peter Gerell
uploaded here:


https://github.com/pgerell/boost_1_61_problem

I'm trying to figure out why.  However, Peter indicates he
had to problem with 1.60.0 but only with 1.61.1.

The mystery deepens ;(

Anyway, my link error includes:

--[--cut here--
/tmp/build/clangxx3_8_pkg/clang/dwnlds_work/dwnlds/Gerell.Boost_1_61_Spirit.LinkError.clone/boost_1_61_problem/common.o:
In function `bool boost::spirit::x3::rule<count_class, ast::Count,
false>::parse<std::__1::__wrap_iter<char const*>,
boost::spirit::x3::unused_type, ast::Start>(std::__1::__wrap_iter<char
const*>&, std::__1::__wrap_iter<char const*> const&,
boost::spirit::x3::unused_type const&, boost::spirit::x3::unused_type,
ast::Start&) const':
common.cpp:(.text._ZNK5boost6spirit2x34ruleI11count_classN3ast5CountELb0EE5parseINSt3__111__wrap_iterIPKcEENS1_11unused_typeENS4_5StartEEEbRT_RKSF_RKT0_SD_RT1_[_ZNK5boost6spirit2x34ruleI11count_classN3ast5CountELb0EE5parseINSt3__111__wrap_iterIPKcEENS1_11unused_typeENS4_5StartEEEbRT_RKSF_RKT0_SD_RT1_]+0x3c):
undefined reference to `bool parse_rule<std::__1::__wrap_iter<char
const*>, boost::spirit::x3::unused_type,
ast::Start>(boost::spirit::x3::rule<count_class, ast::Count, false>,
std::__1::__wrap_iter<char const*>&, std::__1::__wrap_iter<char const*>
const&, boost::spirit::x3::unused_type const&, ast::Start&)'
clang-3.8: error: linker command failed with exit code 1 (use -v to see
invocation)

--}--cut here--


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Exagon
I also thought maybe its the same problem Peter Gerell has, but I have the problem, no matter which boost version I use to compile.

I am getting this error in my project:

In function `bool boost::spirit::x3::rule<kyle::parser::impl::identifier_class, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, false>::parse<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, boost::spirit::x3::char_class<boost::spirit::char_encoding::standard, boost::spirit::x3::space_tag> const, boost::spirit::x3::unused_type>, boost::spirit::x3::unused_type const>(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&, __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, boost::spirit::x3::char_class<boost::spirit::char_encoding::standard, boost::spirit::x3::space_tag> const, boost::spirit::x3::unused_type> const&, boost::spirit::x3::unused_type, boost::spirit::x3::unused_type const&) const':
/usr/include/boost/spirit/home/x3/nonterminal/rule.hpp:116: undefined reference to `bool kyle::parser::impl::parse_rule<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, boost::spirit::x3::char_class<boost::spirit::char_encoding::standard, boost::spirit::x3::space_tag> const, boost::spirit::x3::unused_type>, boost::spirit::x3::unused_type const>(boost::spirit::x3::rule<kyle::parser::impl::identifier_class, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, false>, __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&, __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, boost::spirit::x3::char_class<boost::spirit::char_encoding::standard, boost::spirit::x3::space_tag> const, boost::spirit::x3::unused_type> const&, boost::spirit::x3::unused_type const&)'
collect2: Fehler: ld gab 1 als Ende-Status zurück

Hope its related to https://github.com/pgerell/boost_1_61_problem, because then it will get fixed.
I just had to ask this, because I wasnt sure if I am doing something wrong.
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

cppljevans
In reply to this post by cppljevans
On 11/08/2016 03:22 PM, Larry Evans wrote:
> On 11/08/2016 01:13 PM, Exagon wrote:
>> I am currently trying to separate my parser inteo different files using
>> BOOST_SPIRIT_DEFIND/DECLAR/INSTATIATE, but I keep getting a linker error.
[snip]
> Exagon, FWIW, I'm getting a similar error about parse_rule being
> undefined; however, mine is with the code which Peter Gerell
> uploaded here:
>
>
> https://github.com/pgerell/boost_1_61_problem
>
> I'm trying to figure out why.  However, Peter indicates he
> had to problem with 1.60.0 but only with 1.61.1.
       ^^^^^^^^^^ should be "no problem".

In contrast, your link problem occurs with 1.60.0, if I'm
reading your wandbox/permlink correctly.
>
[snip]



------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Exagon
Yes I think so, could be the case I did something stupid in the example in Wandbox,
but I get this error with every boost version I tried in Wandbox

Greetings Exagon
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Joel de Guzman
On 09/11/2016 5:33 AM, Exagon wrote:
> Yes I think so, could be the case I did something stupid in the example in
> Wandbox,
> but I get this error with every boost version I tried in Wandbox

Can someone please tell me how to easily get the files off Wandbox?

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Exagon
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Exagon
This post was updated on .
In reply to this post by Joel de Guzman
I think Wandbox doesnt support downloading all the files(if so correct me pls)
https://github.com/bitwalda/Spirit_X3_liker_error
here is a githup repo with all the files in the wandbox

greetings Exagon
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Joel de Guzman
On 09/11/2016 6:30 AM, Exagon wrote:
> https://github.com/bitwalda/Spirit_X3_liker_error
> <https://github.com/bitwalda/Spirit_X3_liker_error>
> here is a githup repo with all the files in the wandbox

Here's the corrected code:

template<typename Parser>
bool test(std::string str, Parser&& p, bool full_match = true)
{
     using iterator_type = std::string::const_iterator;
     iterator_type in = str.begin();
     iterator_type end = str.end();
     std::string ast;
     bool ret = boost::spirit::x3::phrase_parse(in, end, p,
boost::spirit::x3::ascii::space, ast);
     ret &= (!full_match || (in == end));
     return ret;
}

1) You declared std::string::const_iterator as your iterator. You need to
    make sure you give it the exact type. str.begin() does not give you that.
2) You declared an attribute of std::string. You did not pass any.
3) You passed boost::spirit::x3::space as your skipper, but you declared
    it as boost::spirit::x3::ascii::space. Those are different types.

You'll need to be very exact with what you declare and with what you
actually use. X3 allows any sort of possible types, but the linker does
not.

Here's a tip: When having linker errors, after BOOST_SPIRIT_INSTANTIATE,
declare something like:

   int x = context_type{};

It will be an error, yes, because context_type cannot be converted to
an int. But that error will also give you the exact type of your context.
Compare it against the linker error and you will see your mistake.

Once you get past this initial hurdle, it will be smooth sailing (apart
from the probable bug reported by Mikael, and we'll fix that ASAP).

Hope that helps.

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Exagon
Thank you very much this helps me a lot and works for me.
But since I have to pass an attribute to the phrase_parse function, how can I write a test method for testing all parsers in unit test etc?
It would be a pain to write a new function for every parser I have to test, and for every parser which returns another attribute.

Greetings Exagon
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Joel de Guzman
On 09/11/2016 9:05 AM, Exagon wrote:
> Thank you very much this helps me a lot and works for me.
> But since I have to pass an attribute to the phrase_parse function, how can
> I write a test method for testing all parsers in unit test etc?
> It would be a pain to write a new function for every parser I have to test,
> and for every parser which returns another attribute.

I'd say that unit tests should reflect what actually you do, so I do not
understand why you shouldn't test the attributes too. But I suppose this
is outside the scope of this conversation, no?

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Exagon
Joel de Guzman wrote
I'd say that unit tests should reflect what actually you do, so I do not
understand why you shouldn't test the attributes too. But I suppose this
is outside the scope of this conversation, no?
of course you are right, I am realy thankfull for your solution and for helping me so fast.
Thank you very much.
\Exagon
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

sehe
On 09-11-16 02:44, Exagon wrote:

> Joel de Guzman wrote
>> I'd say that unit tests should reflect what actually you do, so I do not
>> understand why you shouldn't test the attributes too. But I suppose this
>> is outside the scope of this conversation, no?
> of course you are right, I am realy thankfull for your solution and for
> helping me so fast.
> Thank you very much.
> \Exagon
>
>
UGH. So I was early with my admonishment about cross posting without
links or updating. Turns out I already was that person who wasted their
time on a solved problem.

And yeah, I too had the trouble of getting the files out of wandbox.

I personally believe that stackoverflow is the superior platform for
questions like these (because the concurrent activity is much more
visible there), and you can just crosspost with a link to the Spirit
mailing list to attract the attention of the spirit crowd.

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Exagon
sehe wrote
UGH. So I was early with my admonishment about cross posting without
links or updating. Turns out I already was that person who wasted their
time on a solved problem.

And yeah, I too had the trouble of getting the files out of wandbox.
 I am realy realy sorry for this. In the future I will ask questions like this on SO.
Thank you all ver y much foir helping me so much with boost spirit and answering my questions

\Exagon
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Joel de Guzman
In reply to this post by sehe
On 09/11/2016 8:23 PM, Seth wrote:

> On 09-11-16 02:44, Exagon wrote:
>> Joel de Guzman wrote
>>> I'd say that unit tests should reflect what actually you do, so I do not
>>> understand why you shouldn't test the attributes too. But I suppose this
>>> is outside the scope of this conversation, no?
>> of course you are right, I am realy thankfull for your solution and for
>> helping me so fast.
>> Thank you very much.
>> \Exagon
>>
>>
> UGH. So I was early with my admonishment about cross posting without
> links or updating. Turns out I already was that person who wasted their
> time on a solved problem.
>
> And yeah, I too had the trouble of getting the files out of wandbox.
>
> I personally believe that stackoverflow is the superior platform for
> questions like these (because the concurrent activity is much more
> visible there), and you can just crosspost with a link to the Spirit
> mailing list to attract the attention of the spirit crowd.

I have such high respect for you, Seth! Thank you very much for your
SO activity. I'll try my best to be more active. I posted a follow up
to your answer.

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/




------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

Joel de Guzman
In reply to this post by Exagon
On 10/11/2016 2:34 AM, Exagon wrote:

> sehe wrote
>> UGH. So I was early with my admonishment about cross posting without
>> links or updating. Turns out I already was that person who wasted their
>> time on a solved problem.
>>
>> And yeah, I too had the trouble of getting the files out of wandbox.
>
>  I am realy realy sorry for this. In the future I will ask questions like
> this on SO.
> Thank you all ver y much foir helping me so much with boost spirit and
> answering my questions

Cross posting here would be welcome. I'm not active with SO, although I
probably should be.

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while separating parser into _def and .cpp files

sehe
In reply to this post by Joel de Guzman
On 10-11-16 00:54, Joel de Guzman wrote:
> I have such high respect for you, Seth! Thank you very much for your
> SO activity. I'll try my best to be more active. I posted a follow up
> to your answer.
>
> Regards,

That's mutual then! No need to maintain a presence in both places. I'd
much rather have you "available" here for the hard questions than
dividing time between platforms. If I find anything of note I try to
cross-post on this list.

Cheers,

Seth


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general