Hey there! I've been learning the basics of coding for the fx-CG50 recently and came across an error with my linking to libfxcg's display.h and keyboard.h. Here is my code:

Code:
#include <fxcg/display.h>
#include <fxcg/keyboard.h>

void CopySprite(const color_t* palette, int x, int y, int width, int height) {
   color_t *VRAM = (color_t*)GetVRAMAddress();
   VRAM += LCD_WIDTH_PX * y + x;
   for (int j = y; j < y + height; j++) {
      for (int i = x; i < x + height; i++) {
         *(VRAM++) = *(palette++);
      }
      VRAM += LCD_WIDTH_PX - 16;
   }
}

int main() {
   const color_t sprite[512] = {
      0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
      0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
      0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
      0x0000,0x0000,0x0000,0xff64,0xff64,0x0000,0x0000,0x0000,0x0000,0xff64,0xff64,0x0000,0x0000,0x0000,0x0000,0x0000,
      0x0000,0x0000,0xff64,0xff64,0xff64,0xff64,0x0000,0x0000,0xff64,0xff64,0xff64,0xff64,0x0000,0x0000,0x0000,0x0000,
      0x0000,0x0000,0xff64,0x194a,0x194a,0xff64,0x0000,0x0000,0xff64,0x194a,0x194a,0xff64,0x0000,0x0000,0x0000,0x0000,
      0x0000,0x0000,0x042a,0xff64,0xff64,0xff64,0x042a,0x042a,0xff64,0xff64,0xff64,0x042a,0x0000,0x0000,0x0000,0x0000,
      0x0000,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0000,0x0000,0x0000,
      0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0000,0x0000,
      0x0726,0xfbb5,0xfbb5,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0xfbb5,0xfbb5,0x0726,0x0000,0x0000,
      0x0726,0xfbb5,0xfbb5,0x194a,0x0726,0x0726,0x194a,0x194a,0x0726,0x0726,0x194a,0xfbb5,0xfbb5,0x0726,0x0000,0x0000,
      0x042a,0x0726,0x0726,0x0726,0x194a,0x194a,0x0726,0x0726,0x194a,0x194a,0x0726,0x0726,0x0726,0x042a,0x0000,0x0000,
      0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x0000,0x0000,
      0x0000,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x0000,0x0000,0x0000,
      0x0000,0x0000,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x0000,0x0000,0x0000,0x0000,
      0x0000,0x0000,0x0000,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x0000,0x0000,0x0000,0x0000,0x0000
   };

   CopySprite(sprite, 16, 16, 16, 16);

   int key;
   while (1) GetKey(&key);

   return 0;
}


And here is the error:

Code:
main.o: In function `CopySprite(unsigned short const*, int, int, int, int)':
main.cpp:(.text+0x98): undefined reference to `_GetVRAMAddress'


The weird thing is, the function that gives me the error, GetVRAMAddress, is declared in display.h, and before this I tried out the PrintXY variable, which is declared in the same header, and it worked without a hitch. It would also be useful to provide a solid guide to linking headers to this file properly, as before this I've only ever linked headers to solutions.
Thanks a lot,
emibudd
Both of those functions should be included in the libfxcg static archive (because they're both syscalls), so my best guess without more information is that you have a weird build of libfxcg that's missing things.

Please supply full output from your build process and information on where you got the tools and libraries from.
Tari wrote:
Both of those functions should be included in the libfxcg static archive (because they're both syscalls), so my best guess without more information is that you have a weird build of libfxcg that's missing things.

Please supply full output from your build process and information on where you got the tools and libraries from.

Sure thing. I downloaded libfxcg-master from github (https://github.com/Jonimoose/libfxcg) and then took the fxcg folder (libfxcg-master\include) and pasted it into the include folder of my SDK (PrizmSDK-0.3\include). Is that the wrong way to do it?
You haven't included your build output. However:

Just taking the include files is not sufficient- you must also copy the static libraries that match your header files, because libfxcg consists of more than just headers. The important file is libfxcg.a, and there may also be a libc.a that you should have.
Tari wrote:
You haven't included your build output. However:

Just taking the include files is not sufficient- you must also copy the static libraries that match your header files, because libfxcg consists of more than just headers. The important file is libfxcg.a, and there may also be a libc.a that you should have.

I tried copying those libraries into the lib folder in the SDK and it said they were duplicates, same with the entire folder. I tried typing in

Code:
#include <lib/libfxcg.a>
and
Code:
#include <lib/libc.a>
in case that was what you meant but that gave me more errors. If by build output you mean the rest of the text I get when I build the project, when I put in those two extra includes it's:

Code:
C:\Users\emili\Documents\PrizmSDK-0.3\projects\frogsine>..\..\bin\make.exe
      0 [main] [ 21964 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer.  Please report this problem to
the public mailing list cygwin@cygwin.com
sh3eb-elf-g++ -MMD -MP -MF C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/build/main.d -Os -Wall -mb -m4a-nofpu -mhitachi -nostdlib   -IC:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/build -IC:/Users/emili/Documents/PrizmSDK-0.3/include -c C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp -o main.o
C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp:4:25: fatal error: lib/libfxcg.a: No such file or directory
compilation terminated.
make[1]: *** [main.o] Error 1
make: *** [build] Error 2


And when I don't put the extra ones in, it's:

Code:
C:\Users\emili\Documents\PrizmSDK-0.3\projects\frogsine>..\..\bin\make.exe
      0 [main] [ 19368 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer.  Please report this problem to
the public mailing list cygwin@cygwin.com
sh3eb-elf-g++ -MMD -MP -MF C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/build/main.d -Os -Wall -mb -m4a-nofpu -mhitachi -nostdlib   -IC:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/build -IC:/Users/emili/Documents/PrizmSDK-0.3/include -c C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/src/main.cpp -o main.o
sh3eb-elf-g++  main.o -mb -m4a-nofpu -mhitachi -nostdlib -TC:/Users/emili/Documents/PrizmSDK-0.3/common/prizm.ld -Wl,-static -Wl,-gc-sections  -LC:/Users/emili/Documents/PrizmSDK-0.3/lib -lfxcg -lgcc -o C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/frogsine.bin
main.o: In function `CopySprite(unsigned short const*, int, int, int, int)':
main.cpp:(.text+0x98): undefined reference to `_GetVRAMAddress'
collect2: ld returned 1 exit status
make[1]: *** [C:/Users/emili/Documents/PrizmSDK-0.3/projects/frogsine/frogsine.bin] Error 1
make: *** [build] Error 2
Quote:
I tried copying those libraries into the lib folder in the SDK and it said they were duplicates, same with the entire folder. I tried typing in

Yes, you should replace the existing ones. The SDK package includes libraries (headers and .a archives) so if you're getting new headers you must also get new library archives.

And you can get everything but the compiler from the most recent release on Github. Inspired by everybody having trouble with this I'm also working on automating binary releases.
Tari wrote:
Quote:
I tried copying those libraries into the lib folder in the SDK and it said they were duplicates, same with the entire folder. I tried typing in

Yes, you should replace the existing ones. The SDK package includes libraries (headers and .a archives) so if you're getting new headers you must also get new library archives.

And you can get everything but the compiler from the most recent release on Github. Inspired by everybody having trouble with this I'm also working on automating binary releases.

I'm not sure I get what you mean. I tried downloading that version but I realized the lib folder is completely empty, doesn't contain any of the library files. I thought maybe I had to build it and they'd appear, but the folder doesn't have a make.bat file, and the readme just says to change the toolchain prefix, which I'm not really sure what they are and thought I could leave as the default, and then says to "make", even though the files aren't there. Is there something I'm missing? And yeah, a binary release of this would be really useful.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement