Jump to content



Photo
- - - - -

Compiling C-programm To Fx-addin


  • Please log in to reply
5 replies to this topic

#1 uvoK

uvoK

    Casio Fan

  • Members
  • PipPip
  • 35 posts

  • Calculators:
    CASIO fx-9860G

Posted 12 December 2008 - 06:47 PM

Hi!

I wanted to ask if it possible to compile a C-Programm to a fx-9860-Addin.

I already saw this link (http://fxsdk.sourcef...ka=BinaryFormat), and because I am using gentoo, I said crossdev -t sh3eb.

Now the GCC was downloaded.

But If I execute

sh3eb-unknown-linux-gnu-gcc -O9 -lgcc -Xlinker "-Taddin.ld" crt0.s input.c -o myaddin

it says:

/usr/libexec/gcc/sh3eb-unknown-linux-gnu/ld: error: no memory region specified for loadable section `.plt'
collect2: ld returned 1 exit status

Any ideas?

Furthermore, I don't know why to execute the compiler with the -nostdlib flag....
If I would do it, it wouldn't work, cause I am using stdio.h...

Furthermore, the wiki page says

I am assuming you are in a directory with init.c, init.s, init.h, addin.ld


but:

$ls

addin.ld  crt0.s  inputfile.c

So what are these init*-Files and what are they used for??


Hope you can help me, for I am totally clueless ...

BTW:

Program is in "computer-C", not using the special calculator-libraries/system-calls or whatever...

Edited by 2072, 22 December 2008 - 12:37 AM.


#2 Andreas B

Andreas B

    Casio Freak

  • Members
  • PipPipPipPip
  • 160 posts
  • Gender:Male
  • Location:Norway

  • Calculators:
    fx-9860G SD

Posted 12 December 2008 - 07:29 PM

Hi!
I wanted to ask if it possible to compile a C-Programm to a fx-9860-Addin.
I already saw this link (http://fxsdk.sourcef...ka=BinaryFormat), and because I am using gentoo, I said crossdev -t sh3eb.
Now the GCC was downloaded.
But If I execute
sh3eb-unknown-linux-gnu-gcc -O9 -lgcc -Xlinker "-Taddin.ld" crt0.s input.c -o myaddin
it says:

/usr/libexec/gcc/sh3eb-unknown-linux-gnu/ld: error: no memory region specified for loadable section `.plt'
collect2: ld returned 1 exit status
Any ideas?

I'm wondering why the compiler wants to use the .plt section.. can you show the main.c code?
Anyway, try adding this line into addin.ld between line 13 and 14:
.plt : { *(.plt) } > rom

Furthermore, I don't know why to execute the compiler with the -nostdlib flag....
If I would do it, it wouldn't work, cause I am using stdio.h...

It says to use -nostdlib because the gnu c library for the SH3 platform is incompatible. A small wrapper library to the common system calls and some small functions is at http://fxsdk.sourcef...?wakka=libfxsys
Note that the list of functions has not been updated. Check the header files from SVN instead: https://fxsdk.svn.so.../trunk/include/

Furthermore, the wiki page says
but:

$ls
addin.ld  crt0.s  inputfile.c
So what are these init*-Files and what are they used for??

They were remains of a previous version of the page. Should be updated now. :)

Hope you can help me, for I am totally clueless ...
BTW: Program is in "computer-C", not using the special calculator-libraries/system-calls or whatever...

Well, because the C functions available are pretty limited - even with CASIOs own provided C library, you can not expect a "PC C program" to compile for the calculator.

#3 uvoK

uvoK

    Casio Fan

  • Members
  • PipPip
  • 35 posts

  • Calculators:
    CASIO fx-9860G

Posted 12 December 2008 - 07:39 PM

Thanks!

I added the code to addin.ld, but now it says:

/usr/libexec/gcc/sh3eb-unknown-linux-gnu/ld: error: no memory region specified for loadable section `.init'
collect2: ld returned 1 exit status
:unsure:
...

However, think I'll try out libfxsys...

...

Code is here:
http://pastebin.ca/1283808

#4 Andreas B

Andreas B

    Casio Freak

  • Members
  • PipPipPipPip
  • 160 posts
  • Gender:Male
  • Location:Norway

  • Calculators:
    fx-9860G SD

Posted 12 December 2008 - 09:44 PM

There is no support for printf, scanf or any other stream-functions. That is a limitation of the calculators OS.

About the libfxsys.a library; you have to add the directory of its headers so that GCC can find them when they are #include'd.
This option does that:
-I"/path/to/includes"
And also include /path/to/library/libfxsys.a on the command line together with crt0.s and main.c.

But unless you know your way around GCC, you should instead try to run the fx-9860G SDK in Wine. It is easier, but works.

Edited by Andreas B, 12 December 2008 - 09:44 PM.


#5 uvoK

uvoK

    Casio Fan

  • Members
  • PipPip
  • 35 posts

  • Calculators:
    CASIO fx-9860G

Posted 13 December 2008 - 03:47 PM

Unfortunately, I don't know what the equivalences for printf() and scanf() are and how to use them...

#6 Andreas B

Andreas B

    Casio Freak

  • Members
  • PipPipPipPip
  • 160 posts
  • Gender:Male
  • Location:Norway

  • Calculators:
    fx-9860G SD

Posted 13 December 2008 - 05:01 PM

Your best shot is to use CASIOs SDK under Wine then. There you have access to sprintf().
Use locate() and Print() to select position and print strings. Read Casios documentation for their library.

For input, try this code: http://casio.pastebin.com/f2ef7343f




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users