Running partcl on parrot [Was: Re: GCC failed with configure.pl]

Jonathan "Duke" Leto jonathan at leto.net
Thu Jul 25 22:46:04 UTC 2013


Howdy Ashraya,

I can help with this. You must create a Parrot_String from your char*.
This is because C and Parrot have very different ideas about strings.

I am not sure of the exact names of the functions that create
Parrot_Strings, but if you look at the example code in embed_new.pod,
you should see it creating them.

Please let me know if that helps!

Duke

PS: Not many people have used the new embed API, so please let us know
if/when you hit any bugs and if we could improve the docs. Thanks!

>
> Parrot_api_load_bytecode_file(interp, "foo.pbc", &pf)

> factorial.c:65:5: warning: passing argument 2 of
> ‘Parrot_api_load_bytecode_file’ from incompatible pointer type [enabled by
> default]
> In file included from factorial.c:2:0:
> ../parrot/include/parrot/api.h:324:12: note: expected ‘Parrot_String’ but
> argument is of type ‘char *’
> ashiva at ubuntu:~/Parrot/rakudo/Test$
>
> Can anyone please suggest what I can possibly do to avoid these errors and
> run the pbc ?
>
> Thanks & Regards,
> Ashraya S Shiva
>
>
> On Wed, Jul 24, 2013 at 5:38 PM, Ashraya <theemeraldsoul at gmail.com> wrote:
>>
>> Hi All,
>>
>> I am trying to run a simple factorial program using parrot inside my C
>> code.
>>
>> This is from the embed_new.pod tutorial.
>>
>> This line in the main function seems to be giving me some errors :
>>
>> Parrot_api_load_bytecode_file(interp, "foo.pbc", &pf)
>>
>>
>> ashiva at ubuntu:~/Parrot/rakudo/Test$ gcc factorial.c `parrot_config
>> embed-cflags` `parrot_config embed-ldflags`
>> factorial.c: In function ‘main’:
>> factorial.c:65:5: warning: passing argument 2 of
>> ‘Parrot_api_load_bytecode_file’ from incompatible pointer type [enabled by
>> default]
>> In file included from factorial.c:2:0:
>> ../parrot/include/parrot/api.h:324:12: note: expected ‘Parrot_String’ but
>> argument is of type ‘char *’
>> ashiva at ubuntu:~/Parrot/rakudo/Test$
>>
>> Can anyone please suggest what I can possibly do to avoid these errors and
>> run the pbc ?
>>
>> Thanks & Regards,
>> Ashraya
>>
>>
>> Thanks & Regards,
>> Ashraya S Shiva
>>
>>
>> On Wed, Jul 24, 2013 at 12:23 AM, Ashraya <theemeraldsoul at gmail.com>
>> wrote:
>>>
>>> Oh ok.. Thanks for the clarification, Will.
>>>
>>> Thank you all, for your patience. :)
>>>
>>> Thanks & Regards,
>>> Ashraya S Shiva
>>>
>>>
>>> On Wed, Jul 24, 2013 at 12:12 AM, Will Coleda <will at coleda.com> wrote:
>>>>
>>>> FYI, I'm the partcl developer.
>>>>
>>>> Some notes about the status of partcl on parrot:
>>>>
>>>> https://github.com/partcl/partcl is the old, PIR based version - this
>>>> version was more complete, written in PIR & C, but it is not even being
>>>> tested regularly to insure that changes in parrot don't break it, as
>>>> previous breaking changes are still unresolved.
>>>>
>>>> https://github.com/partcl/partcl-nqp is newer, and is targeting the
>>>> nqp-rx that ships with parrot, which is, so far as I know, no longer
>>>> maintained - a snapshot is bundled in with parrot.
>>>>
>>>> partcl-nqp  has a branch, nqp2, which is in the middle of trying to
>>>> target the standalone nqp, which is being maintained. However, this is a
>>>> work in progress, and I'm not sure the branch even compiles at this point.
>>>> The goal is to 1) make this work with the new standalone NQP, and then to
>>>> get this version as functional as the PIR version once was. But it's not an
>>>> actively developed project.
>>>>
>>>> So, it looks like you're using the first version... and yes, I can
>>>> reproduce your problem with my installed parrot (5.5.0-devel)
>>>>
>>>> I haven't done a bisect, but it looks like this file (Tcl::Glob) was
>>>> installed as part of parrot's 5.0.0-devel branch, but isn't as of 5.5.0
>>>>
>>>> So, partcl on PIR is extra broken until that's fixed, or you could try
>>>> with an older parrot version.
>>>>
>>>> Apologies.
>>>>
>>>> On Tue, Jul 23, 2013 at 2:18 PM, Ashraya <theemeraldsoul at gmail.com>
>>>> wrote:
>>>>>
>>>>> One more thing.. I am trying to compile TCL code here too..
>>>>>
>>>>> But it doesn't seem to work :
>>>>>
>>>>> ashiva at ubuntu:~/Parrot/rakudo/partcl$ ../parrot/parrot tcl.pbc -e "puts
>>>>> {hello world}"
>>>>> "load_bytecode" couldn't find file 'Tcl/Glob.pir'
>>>>> current instr.: 'prepare_lib' pc 27748 (runtime/builtin/dict.pir:102)
>>>>> called from Sub '_main' pc 0 (src/tclsh.pir:39)
>>>>> called from Sub '_main' pc 3 (src/tclsh.pir:42)
>>>>> ashiva at ubuntu:~/Parrot/rakudo/partcl$
>>>>>
>>>>>
>>>>> I read in a conversation thread that this is working.. But I am not
>>>>> able to understand where I am going wrong.
>>>>>
>>>>> Please help.
>>>>>
>>>>> Thanks a lot,
>>>>> Ashraya
>>>>>
>>>>> Thanks & Regards,
>>>>> Ashraya S Shiva
>>>>>
>>>>>
>>>>> On Tue, Jul 23, 2013 at 9:54 PM, Will Coleda <will at coleda.com> wrote:
>>>>>>
>>>>>> It sounds like you're trying to compile C code with parrot - Parrot is
>>>>>> a compiler for the languages PIR and PASM, and provides an interpreter to
>>>>>> run PBC (parrot bytecode).
>>>>>>
>>>>>> You can compile C code that interoperates with parrot (using the
>>>>>> embed/extend interface), but you cannot use parrot to compile and run C code
>>>>>> by itself. For that, you'd use a tool like GCC.
>>>>>>
>>>>>>
>>>>>> On Tue, Jul 23, 2013 at 11:58 AM, Ashraya <theemeraldsoul at gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>> Hello Duke,
>>>>>>>
>>>>>>> Let me rephrase my question.
>>>>>>>
>>>>>>> For example, I write a simple perl file, hello.pl :
>>>>>>> #!/usr/bin/perl
>>>>>>> print "Hello World"
>>>>>>>
>>>>>>> To compile this, I use :  parrot perl6.pbc hello.pl
>>>>>>>
>>>>>>> The output is : Hello World
>>>>>>>
>>>>>>> Similarly, if I have a C file, hello.c :
>>>>>>>
>>>>>>> #include<stdio.h>
>>>>>>>
>>>>>>> int main()
>>>>>>> {
>>>>>>>     printf("Hello World\n");
>>>>>>>     return 0;
>>>>>>> }
>>>>>>>
>>>>>>> How would I compile this to get the output?
>>>>>>>
>>>>>>> Note : I downloaded the c99 package for parrot from github but I
>>>>>>> could not get this installed.
>>>>>>>
>>>>>>> Thanks & Regards,
>>>>>>> Ashraya S Shiva
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jul 23, 2013 at 7:23 PM, Jonathan "Duke" Leto
>>>>>>> <jonathan at leto.net> wrote:
>>>>>>>>
>>>>>>>> Howdy Ashraya,
>>>>>>>>
>>>>>>>> I believe nobody is answering you because they don't quite
>>>>>>>> understand
>>>>>>>> what you mean.
>>>>>>>>
>>>>>>>> Could you ask your question another way, and give some more
>>>>>>>> background
>>>>>>>> about what you are trying to do?
>>>>>>>>
>>>>>>>> Duke
>>>>>>>>
>>>>>>>> On Sun, Jul 21, 2013 at 10:51 PM, Ashraya <theemeraldsoul at gmail.com>
>>>>>>>> wrote:
>>>>>>>> > A gentle reminder.. Please reply. How to convert a C code into PIR
>>>>>>>> > code ?
>>>>>>>> >
>>>>>>>> > Thanks & Regards,
>>>>>>>> > Ashraya S Shiva
>>>>>>>> >
>>>>>>>> >
>>>>>>>> > On Wed, Jul 17, 2013 at 4:30 PM, Ashraya
>>>>>>>> > <theemeraldsoul at gmail.com> wrote:
>>>>>>>> >>
>>>>>>>> >> Hello Duke,
>>>>>>>> >>
>>>>>>>> >> I am trying one of the examples in the .pod you have given :
>>>>>>>> >>
>>>>>>>> >>   /* foo.c */
>>>>>>>> >>
>>>>>>>> >>   /* specify the function prototype */
>>>>>>>> >>   #ifdef __WIN32
>>>>>>>> >>   __declspec(dllexport) void foo(void);
>>>>>>>> >>   #else
>>>>>>>> >>   void foo(void);
>>>>>>>> >>   #endif
>>>>>>>> >>
>>>>>>>> >>   void foo(void) {
>>>>>>>> >>     printf("Hello Parrot!\n");
>>>>>>>> >>   }
>>>>>>>> >>
>>>>>>>> >> Then, after having compiled the file as a shared library, the PIR
>>>>>>>> >> code
>>>>>>>> >> looks like this:
>>>>>>>> >>
>>>>>>>> >>
>>>>>>>> >> Here, how do I compile the .c file to produce a .pir file ??
>>>>>>>> >>
>>>>>>>> >> Thanks,
>>>>>>>> >> Ashiva
>>>>>>>> >>
>>>>>>>> >> Thanks & Regards,
>>>>>>>> >> Ashraya S Shiva
>>>>>>>> >>
>>>>>>>> >>
>>>>>>>> >> On Wed, Jul 17, 2013 at 2:08 AM, Jonathan "Duke" Leto
>>>>>>>> >> <jonathan at leto.net>
>>>>>>>> >> wrote:
>>>>>>>> >>>
>>>>>>>> >>> Howdy,
>>>>>>>> >>>
>>>>>>>> >>> You can embed Parrot inside of a C or C++ application. It can be
>>>>>>>> >>> any
>>>>>>>> >>> language, actually (it works with FORTRAN), but we have the best
>>>>>>>> >>> docs
>>>>>>>> >>> for C and C++. I have embedded Parrot inside of PostgreSQL
>>>>>>>> >>> (PL/Parrot
>>>>>>>> >>> [0]), but that uses the old interface [1]. The new interface [2]
>>>>>>>> >>> is
>>>>>>>> >>> infinitely better, but has not been heavily used. But it was
>>>>>>>> >>> designed
>>>>>>>> >>> very well by Whiteknight, so it is high quality.
>>>>>>>> >>>
>>>>>>>> >>> You can also call out to C/C++ libraries from parrot via
>>>>>>>> >>> "dlopen" and
>>>>>>>> >>> cousins via the Native Call Interface (NCI) substem of Parrot
>>>>>>>> >>> [3].
>>>>>>>> >>>
>>>>>>>> >>> Which of those things do you want to do, or possibly both?
>>>>>>>> >>>
>>>>>>>> >>> Duke
>>>>>>>> >>>
>>>>>>>> >>> [0] http://pl.parrot.org
>>>>>>>> >>> [1] https://github.com/parrot/parrot/blob/master/docs/embed.pod
>>>>>>>> >>> [2]
>>>>>>>> >>> https://github.com/parrot/parrot/blob/master/docs/embed_new.pod
>>>>>>>> >>> [3]
>>>>>>>> >>>
>>>>>>>> >>> https://github.com/parrot/parrot/blob/master/docs/pdds/draft/pdd16_native_call.pod
>>>>>>>> >>>
>>>>>>>> >>>
>>>>>>>> >>> On Tue, Jul 16, 2013 at 4:58 AM, Ashraya S
>>>>>>>> >>> <theemeraldsoul at gmail.com>
>>>>>>>> >>> wrote:
>>>>>>>> >>> > Hello All,
>>>>>>>> >>> >
>>>>>>>> >>> > I switched to my favorite Ubuntu and parrot got installed like
>>>>>>>> >>> > a charm.
>>>>>>>> >>> >
>>>>>>>> >>> > However, I would like to know how parrot supports C program
>>>>>>>> >>> > compilation.
>>>>>>>> >>> > Is there any tutorial I can find ? I did not get much support
>>>>>>>> >>> > for C in
>>>>>>>> >>> > google. Got loads for perl and pasm.
>>>>>>>> >>> >
>>>>>>>> >>> > Please advise.
>>>>>>>> >>> >
>>>>>>>> >>> > Thanks,
>>>>>>>> >>> > Ashiva
>>>>>>>> >>> >
>>>>>>>> >>> >
>>>>>>>> >>> > On Wednesday, July 10, 2013 7:30:29 PM UTC+5:30, Coke wrote:
>>>>>>>> >>> >>
>>>>>>>> >>> >> Do you have a C compiler installed?
>>>>>>>> >>> >>
>>>>>>>> >>> >>
>>>>>>>> >>> >> On Wed, Jul 10, 2013 at 6:39 AM, Ashraya S
>>>>>>>> >>> >> <theemer... at gmail.com>
>>>>>>>> >>> >> wrote:
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> Hi All,
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> I am new to parrot and i am trying to install this in
>>>>>>>> >>> >>> windows 7.
>>>>>>>> >>> >>> I have installed perl and minGW and have added these to my
>>>>>>>> >>> >>> PATH as
>>>>>>>> >>> >>> well.
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> But i get the following error :
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> C:\Users\ashiva\Documents\GitHub\parrot>perl Configure.pl
>>>>>>>> >>> >>> Parrot Version 5.5.0 Configure 2.0
>>>>>>>> >>> >>> Copyright (C) 2001-2013, Parrot Foundation.
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> Hello, I'm Configure. My job is to poke and prod your system
>>>>>>>> >>> >>> to
>>>>>>>> >>> >>> figure
>>>>>>>> >>> >>> out
>>>>>>>> >>> >>> how to build Parrot. The process is completely automated,
>>>>>>>> >>> >>> unless you
>>>>>>>> >>> >>> passed in
>>>>>>>> >>> >>> the `--ask' flag on the command line, in which case I'll
>>>>>>>> >>> >>> prompt you
>>>>>>>> >>> >>> for a
>>>>>>>> >>> >>> few
>>>>>>>> >>> >>> pieces of info.
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> Since you're running this program, you obviously have Perl
>>>>>>>> >>> >>> 5--I'll be
>>>>>>>> >>> >>> pulling
>>>>>>>> >>> >>> some defaults from its configuration.
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> init::manifest -      Check
>>>>>>>> >>> >>> MANIFEST.....................................done.
>>>>>>>> >>> >>> init::defaults -      Set Configure's default
>>>>>>>> >>> >>> values.....................done.
>>>>>>>> >>> >>> init::install -       Set up installation
>>>>>>>> >>> >>> paths..........................done.
>>>>>>>> >>> >>> init::hints -         Load platform and local hints
>>>>>>>> >>> >>> files................done.
>>>>>>>> >>> >>> inter::progs -        Determine what C compiler and linker
>>>>>>>> >>> >>> to
>>>>>>>> >>> >>> use...Compilation
>>>>>>>> >>> >>> failed with 'gcc'
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> C:\Users\ashiva\Documents\GitHub\parrot>
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> Please help me resolve this problem.
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> Thanks a lot, in advance.
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> --
>>>>>>>> >>> >>> Ashiva
>>>>>>>> >>> >>>
>>>>>>>> >>> >>> _______________________________________________
>>>>>>>> >>> >>> http://lists.parrot.org/mailman/listinfo/parrot-dev
>>>>>>>> >>> >>>
>>>>>>>> >>> >>
>>>>>>>> >>> >>
>>>>>>>> >>> >>
>>>>>>>> >>> >> --
>>>>>>>> >>> >> Will "Coke" Coleda
>>>>>>>> >>> >
>>>>>>>> >>> >
>>>>>>>> >>> > _______________________________________________
>>>>>>>> >>> > http://lists.parrot.org/mailman/listinfo/parrot-dev
>>>>>>>> >>> >
>>>>>>>> >>>
>>>>>>>> >>>
>>>>>>>> >>>
>>>>>>>> >>> --
>>>>>>>> >>> Jonathan "Duke" Leto <jonathan at leto.net>
>>>>>>>> >>> Leto Labs LLC http://letolabs.com
>>>>>>>> >>> 209.691.DUKE http://duke.leto.net
>>>>>>>> >>> @dukeleto
>>>>>>>> >>
>>>>>>>> >>
>>>>>>>> >
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Jonathan "Duke" Leto <jonathan at leto.net>
>>>>>>>> Leto Labs LLC http://letolabs.com
>>>>>>>> 209.691.DUKE http://duke.leto.net
>>>>>>>> @dukeleto
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> http://lists.parrot.org/mailman/listinfo/parrot-dev
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Will "Coke" Coleda
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Will "Coke" Coleda
>>>
>>>
>>
>



-- 
Jonathan "Duke" Leto <jonathan at leto.net>
Leto Labs LLC http://letolabs.com
209.691.DUKE http://duke.leto.net
@dukeleto


More information about the parrot-dev mailing list