Re: 【Deployment】

2020-08-15 Thread Kon Lovett
appears using CHICKEN 5 but extras.c & data-structures.c are CHICKEN 4 modules

> On Aug 15, 2020, at 2:42 AM, Kristian Lein-Mathisen  
> wrote:
> 
> 
> Hi, 
> 
> I'm glad that helped. But I suppose I should have explained my process, 
> instead of just giving you the end result - which clearly doesn't work once 
> you start adding imports like you have.
> 
> The error messages you're seeing (undefined reference to `C_extras_toplevel') 
> are coming from your C compilier. They mean that your program is using a 
> function which isn't defined anywhere, so we need to find where 
> C_extras_toplevel is defined.
> 
> There are probably a hundred different ways of finding the .c file which 
> defines a function. Here's and one. Install ctags and then run this:
> 
>  ~/o/chicken-5.2.0rc1  ➤ ctags *.c
> # creates a "grepable" file called tags
> 
> ~/o/chicken-5.2.0rc1  ➤ grep C_extras_toplevel tags
> C_extras_toplevel   extras.c/^void C_ccall 
> C_extras_toplevel(C_word c,C_word *av){$/;"f   typeref:typename:void 
> C_ccall
> # so it seems we need extras.c too
> 
>  ~/o/chicken-5.2.0rc1  ➤ grep C_data_2dstructures_toplevel tags
> C_data_2dstructures_topleveldata-structures.c   /^void C_ccall 
> C_data_2dstructures_toplevel(C_word c,C_word *av){$/;"   f   
> typeref:typename:void C_ccall
> # and data-structures.c
> 
>  ~/o/chicken-5.2.0rc1  ➤ gcc -DHAVE_CHICKEN_CONFIG_H hello.c -I . runtime.c 
> library.c eval.c expand.c modules.c internal.c chicken-syntax.c 
> build-version.c extras.c data-structures.c -lm -llog -o hello
> 
> Adding those two files to the gcc command should get your program to compile 
> properly. If not, you can find the missing .c files by grepping `tags`. 
> 
> Hope that helps.
> K.
> 
> On Sat, Aug 15, 2020, 02:57 亀田馬志  > wrote:
> Hello.
> 
> >  gcc -DHAVE_CHICKEN_CONFIG_H hello.c -I . runtime.c library.c eval.c 
> > expand.c modules.c internal.c chicken-syntax.c build-version.c -lm -o hello
> 
> Oh, yes. It works! Great! Thank you!
> 
> But..
> 
> I wrote a script like this.
> 
> (import format (chicken io) (chicken string) (chicken process-context))
> 
> (require-extension srfi-13)
> 
> (let ((file-name (car (command-line-arguments
>   (with-input-from-file file-name
> (lambda ()
>   (let loop ((ls0 '()) (c (read-line)))
> (if (eof-object? c)
> (for-each (lambda (x)
> (format #t
> "時刻:~A秒,北緯:~A度~A分,東経:~A度~A分~%"
> (+ (* (cadar x) 60) (caddar x))
> (string-take (cadr x) 2)
> (string-drop (cadr x) 2)
> (string-take (caddr x) 3)
> (string-drop (caddr x) 3)))
>   (reverse ls0))
> (let ((ls1 (string-split c ",")))
>   (if (string=? (car ls1) "$GPGGA")
>   (loop (cons `(,(map string->number
>   (string-chop (list-ref ls1 1) 2))
> ,(list-ref ls1 2)
> ,(list-ref ls1 4)) ls0) (read-line))
>   (loop ls0 (read-line)
> 
> Sorry, some Japanese are mixed. But. Anyway.
> I try compiling with your way, and gcc gives me an error like this.
> 
> /usr/bin/ld: /tmp/ccxVWfZy.o: in function `f_223':
> poichan-01-1.c:(.text+0x765): undefined reference to `C_extras_toplevel'
> /usr/bin/ld: /tmp/ccxVWfZy.o: in function `f_226':
> poichan-01-1.c:(.text+0x92d): undefined reference to 
> `C_data_2dstructures_toplevel'
> collect2: error: ld returned 1 exit status
> 
> H Is there something wrong on the code?
> What are the C_extras_toplevel and C_data_wdstructures_toplevel?
> 
> If I used some libraries from chicken-install, should I use the compiled 
> "scheme to c" file too?
> 
> There must be something more to learn around the Chicken Scheme more.
> 
> Anyway, you have helped me a lot! Thank you.
> 
> 
> 2020年8月13日(木) 14:56 Kristian Lein-Mathisen  >:
> 
> Hi,
> 
> I managed to get something working on my termux, maybe that can help you:
> 
> ~/o/chicken-5.2.0rc1  ➤
> echo '(print "hello")' > hello.scm   ~/o/chicken-5.2.0rc1  ➤
> ./csc -t hello.scm
>  ~/o/chicken-5.2.0rc1  ➤
> gcc -DHAVE_CHICKEN_CONFIG_H hello.c -I . runtime.c library.c eval.c expand.c 
> modules.c internal.c chicken-syntax.c build-version.c -lm -llog -o hello
>  ~/o/chicken-5.2.0rc1  ➤ ldd hello 
> libm.so   
> liblog.so
> libdl.so
> libc.so
>  ~/o/chicken-5.2.0rc1  ➤ ./hello
> hello
> 
> You can ignore -llog unless you're on Android.
> 
> So you don't need buildtag.h. Is there a reason you can't "csc -static 
> hello.scm" or "csc -static -C -static hello.scm" which is a more common 
> use-case?
> 
> Cheers,
> K.
> 
> On Thu, Aug 13, 2020, 03:27 亀田馬志  

Re: 【Deployment】

2020-08-15 Thread Kristian Lein-Mathisen
Hi,

I'm glad that helped. But I suppose I should have explained my process,
instead of just giving you the end result - which clearly doesn't work once
you start adding imports like you have.

The error messages you're seeing (undefined reference to
`C_extras_toplevel') are coming from your C compilier. They mean that your
program is using a function which isn't defined anywhere, so we need to
find where C_extras_toplevel is defined.

There are probably a hundred different ways of finding the .c file which
defines a function. Here's and one. Install ctags and then run this:

 ~/o/chicken-5.2.0rc1  ➤ ctags *.c
# creates a "grepable" file called tags

~/o/chicken-5.2.0rc1  ➤ grep C_extras_toplevel tags
C_extras_toplevel   extras.c/^void C_ccall
C_extras_toplevel(C_word c,C_word *av){$/;"f   typeref:typename:void
C_ccall
# so it seems we need extras.c too

 ~/o/chicken-5.2.0rc1  ➤ grep C_data_2dstructures_toplevel tags
C_data_2dstructures_topleveldata-structures.c   /^void C_ccall
C_data_2dstructures_toplevel(C_word c,C_word *av){$/;"   f
 typeref:typename:void C_ccall
# and data-structures.c

 ~/o/chicken-5.2.0rc1  ➤ gcc -DHAVE_CHICKEN_CONFIG_H hello.c -I . runtime.c
library.c eval.c expand.c modules.c internal.c chicken-syntax.c
build-version.c extras.c data-structures.c -lm -llog -o hello

Adding those two files to the gcc command should get your program to
compile properly. If not, you can find the missing .c files by grepping
`tags`.

Hope that helps.
K.

On Sat, Aug 15, 2020, 02:57 亀田馬志  wrote:

> Hello.
>
> >  gcc -DHAVE_CHICKEN_CONFIG_H hello.c -I . runtime.c library.c eval.c
> expand.c modules.c internal.c chicken-syntax.c build-version.c -lm -o hello
>
> Oh, yes. It works! Great! Thank you!
>
> But..
>
> I wrote a script like this.
>
> (import format (chicken io) (chicken string) (chicken process-context))
>
> (require-extension srfi-13)
>
> (let ((file-name (car (command-line-arguments
>   (with-input-from-file file-name
> (lambda ()
>   (let loop ((ls0 '()) (c (read-line)))
> (if (eof-object? c)
> (for-each (lambda (x)
> (format #t
> "時刻:~A秒,北緯:~A度~A分,東経:~A度~A分~%"
> (+ (* (cadar x) 60) (caddar x))
> (string-take (cadr x) 2)
> (string-drop (cadr x) 2)
> (string-take (caddr x) 3)
> (string-drop (caddr x) 3)))
>   (reverse ls0))
> (let ((ls1 (string-split c ",")))
>   (if (string=? (car ls1) "$GPGGA")
>   (loop (cons `(,(map string->number
>   (string-chop (list-ref ls1 1) 2))
> ,(list-ref ls1 2)
> ,(list-ref ls1 4)) ls0) (read-line))
>   (loop ls0 (read-line)
>
> Sorry, some Japanese are mixed. But. Anyway.
> I try compiling with your way, and gcc gives me an error like this.
>
> /usr/bin/ld: /tmp/ccxVWfZy.o: in function `f_223':
> poichan-01-1.c:(.text+0x765): undefined reference to `C_extras_toplevel'
> /usr/bin/ld: /tmp/ccxVWfZy.o: in function `f_226':
> poichan-01-1.c:(.text+0x92d): undefined reference to
> `C_data_2dstructures_toplevel'
> collect2: error: ld returned 1 exit status
>
> H Is there something wrong on the code?
> What are the C_extras_toplevel and C_data_wdstructures_toplevel?
>
> If I used some libraries from chicken-install, should I use the compiled
> "scheme to c" file too?
>
> There must be something more to learn around the Chicken Scheme more.
>
> Anyway, you have helped me a lot! Thank you.
>
>
> 2020年8月13日(木) 14:56 Kristian Lein-Mathisen :
>
>>
>> Hi,
>>
>> I managed to get something working on my termux, maybe that can help you:
>>
>> ~/o/chicken-5.2.0rc1  ➤
>> echo '(print "hello")' > hello.scm   ~/o/chicken-5.2.0rc1  ➤
>> ./csc -t hello.scm
>>  ~/o/chicken-5.2.0rc1  ➤
>> gcc -DHAVE_CHICKEN_CONFIG_H hello.c -I . runtime.c library.c eval.c
>> expand.c modules.c internal.c chicken-syntax.c build-version.c -lm -llog -o
>> hello
>>  ~/o/chicken-5.2.0rc1  ➤ ldd hello
>> libm.so
>> liblog.so
>> libdl.so
>> libc.so
>>  ~/o/chicken-5.2.0rc1  ➤ ./hello
>> hello
>>
>> You can ignore -llog unless you're on Android.
>>
>> So you don't need buildtag.h. Is there a reason you can't "csc -static
>> hello.scm" or "csc -static -C -static hello.scm" which is a more common
>> use-case?
>>
>> Cheers,
>> K.
>>
>> On Thu, Aug 13, 2020, 03:27 亀田馬志  wrote:
>>
>>> Thanks for your reply.
>>>
>>> > It seems there is a chicken-bin for U20.04LTS
>>>
>>> Yes, there is BINARY. I mean I could not find a SOURCE CODE package.
>>> (Usually, you can take source code from the Ubuntu repository if you
>>> wished to.)
>>>
>>
>>
>>> > did you try compiling hello.scm to hello.c with that?
>>>
>>> Yes, I did.
>>> To write a single file 

Re: 【Deployment】

2020-08-15 Thread 亀田馬志
Hello.

>  gcc -DHAVE_CHICKEN_CONFIG_H hello.c -I . runtime.c library.c eval.c
expand.c modules.c internal.c chicken-syntax.c build-version.c -lm -o hello

Oh, yes. It works! Great! Thank you!

But..

I wrote a script like this.

(import format (chicken io) (chicken string) (chicken process-context))

(require-extension srfi-13)

(let ((file-name (car (command-line-arguments
  (with-input-from-file file-name
(lambda ()
  (let loop ((ls0 '()) (c (read-line)))
(if (eof-object? c)
(for-each (lambda (x)
(format #t
"時刻:~A秒,北緯:~A度~A分,東経:~A度~A分~%"
(+ (* (cadar x) 60) (caddar x))
(string-take (cadr x) 2)
(string-drop (cadr x) 2)
(string-take (caddr x) 3)
(string-drop (caddr x) 3)))
  (reverse ls0))
(let ((ls1 (string-split c ",")))
  (if (string=? (car ls1) "$GPGGA")
  (loop (cons `(,(map string->number
  (string-chop (list-ref ls1 1) 2))
,(list-ref ls1 2)
,(list-ref ls1 4)) ls0) (read-line))
  (loop ls0 (read-line)

Sorry, some Japanese are mixed. But. Anyway.
I try compiling with your way, and gcc gives me an error like this.

/usr/bin/ld: /tmp/ccxVWfZy.o: in function `f_223':
poichan-01-1.c:(.text+0x765): undefined reference to `C_extras_toplevel'
/usr/bin/ld: /tmp/ccxVWfZy.o: in function `f_226':
poichan-01-1.c:(.text+0x92d): undefined reference to
`C_data_2dstructures_toplevel'
collect2: error: ld returned 1 exit status

H Is there something wrong on the code?
What are the C_extras_toplevel and C_data_wdstructures_toplevel?

If I used some libraries from chicken-install, should I use the compiled
"scheme to c" file too?

There must be something more to learn around the Chicken Scheme more.

Anyway, you have helped me a lot! Thank you.


2020年8月13日(木) 14:56 Kristian Lein-Mathisen :

>
> Hi,
>
> I managed to get something working on my termux, maybe that can help you:
>
> ~/o/chicken-5.2.0rc1  ➤
> echo '(print "hello")' > hello.scm   ~/o/chicken-5.2.0rc1  ➤
> ./csc -t hello.scm
>  ~/o/chicken-5.2.0rc1  ➤
> gcc -DHAVE_CHICKEN_CONFIG_H hello.c -I . runtime.c library.c eval.c
> expand.c modules.c internal.c chicken-syntax.c build-version.c -lm -llog -o
> hello
>  ~/o/chicken-5.2.0rc1  ➤ ldd hello
> libm.so
> liblog.so
> libdl.so
> libc.so
>  ~/o/chicken-5.2.0rc1  ➤ ./hello
> hello
>
> You can ignore -llog unless you're on Android.
>
> So you don't need buildtag.h. Is there a reason you can't "csc -static
> hello.scm" or "csc -static -C -static hello.scm" which is a more common
> use-case?
>
> Cheers,
> K.
>
> On Thu, Aug 13, 2020, 03:27 亀田馬志  wrote:
>
>> Thanks for your reply.
>>
>> > It seems there is a chicken-bin for U20.04LTS
>>
>> Yes, there is BINARY. I mean I could not find a SOURCE CODE package.
>> (Usually, you can take source code from the Ubuntu repository if you
>> wished to.)
>>
>
>
>> > did you try compiling hello.scm to hello.c with that?
>>
>> Yes, I did.
>> To write a single file with Scheme codes, and to compile to a SINGLE c
>> file, it is a piece of cake.
>>
>> > Are you reading the manual for Chicken 5
>>
>> Yes, of course. I followed the instructions on it.
>> You may see there:
>>
>> "Compiled to C, we get hello.c. We need the files chicken.h,
>> chicken-config.h, buildtag.h and runtime.c, which contain the basic
>> runtime system, plus the library files build-version.c, chicken-syntax.c
>> , eval.c, expand.c, internal.c, library.c and modules.c, which contain
>> the same functionality as the library that is linked into plain
>> CHICKEN-compiled applications:"
>>
>> However, as you may notice, there is no buildtag.h generated even though
>> you built Chicken Scheme from its source code.
>> Therefore, you can not proceed to the rest process using /tmp described
>> next.
>>
>> > perhaps the manual is outdated?
>>
>> OMBuddha. If what you are saying were rightwhat should I do!?
>>
>> Thanks.
>>
>>
>>
>> 
>>  ウイルス
>> フリー。 www.avast.com
>> 
>> <#m_-6378871799878235639_m_-3841790857946966358_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> 2020年8月13日(木) 6:39 Kristian Lein-Mathisen :
>>
>>>
>>> Hi,
>>>
>>> It seems there is a chicken-bin for U20.04LTS [1], did you try compiling
>>> hello.scm to hello.c with that? What is it that you're trying to acheive?
>>>
>>> I don't seem to have any buildtag.h either, perhaps the manual is
>>> outdated?
>>>
>>> Are you reading the manual for Chicken 5 [2]?
>>>
>>> K.
>>> [1]: