This:


Code:

#include <stdio.h>
#include <display.h>
void main()
{
   Bdisp_AllCr_VRAM();
}


returns this:


Code:


In function `main':
test.c:(.text+0x5): undefined reference to `Bdisp_AllCr_VRAM'
collect2: ld returned 1 exit status
bash: ./a.out: No such file or directory


Why is that?
Because you're not including the right files to use Bdisp_AllCr_VRAM. Please please please EVERYONE who is having issues compiling programs for the Prizm, look at existing programs' code to get an idea of what it the right thing to do. I don't recall offhand which header file that's in, but I think it's probably display_syscalls.h or fxCG_Display.h. Check those files for that function definition. Also, it looks like you're using GCC, I assume you've got it all set up according to how Tari and Jonimus specify? I haven't actually done this yet so I can exactly help.

Of course, what I'm saying about includes could be wrong because of GCC, maybe they renamed the includes and such (which would upset me, I want backwards compilability!), but either way, it's not including the right include.
You've having trouble because you're not building with our defined process at all. The undefined reference error is thrown by the linker (Bdisp_AllCr_VRAM is indeed provided by display.h in libfxcg) because it can't find the library file providing that function, implying your library include paths are wrong. Coupled with the fact that you're building to a file a.out, you either didn't use our Makefile as a template at all or removed things willy-nilly without understanding what you were doing.
You should also not be using stdio (never mind you don't even use it in that one-liner), and doing so with the options outlined below will cause errors when compiling.

As we covered in IRC a little bit yesterday afternoon, the GCC toolchain is currently a bit 'squiffy', in that it should work in most situations, but you should be sure you understand what you're doing before trying to change things [much].

Do the following to compile without using our Makefile (requires the lib and include directories from the GCC SDK, also crt0.s and prizm.lkr), with your file test.c. This is all one line; your browser might wrap it since it's long:

Code:
$ sh3eb-elf-gcc -m4a-nofpu -mb -mhitachi -Wall -nostdlib -Iinclude -lfxcg -lgcc -Llib -Tprizm.lkr -Wl,-static -o test.bin test.c crt0.s
(disclaimer: I didn't test that exact command)

Since I'm feeling generous, what all the options do:
-m4a-nofpu -mhitachi -mb
Compile for SH4A without using the FPU, complying to the Renesas (formerly Hitachi) ABI and for a big-endian system.
-Wall
Give lots of warnings when compiling.
-nostdlib -lgcc
Don't use the standard library provided by GCC (notably crt0), but do still link against libgcc (needed to do some operations which are not easily done on the processor, such as floating-point math).
-Iinclude -Llib -lfxcg
Look for include files in the include directory and library files in the lib directory, both needed to pick up libfxcg. Link against libfxcg as well.
-Wl,-static -Tprizm.lkr
Tell the linker to build a static binary and link with the script in prizm.lkr.
-o test.bin
Write output to test.bin.
test.c crt0.s
Build test.c and crt0.s. (If crt0 were to be omitted, you'd get linker errors about the .pretext section being missing)

You can then feed that into mkg3a:

Code:
$ mkg3a test.bin


Based on the Makefile in what I think is the latest PrizmSDK package, you can change a few lines and get the same effect:

Code:
SOURCES=test.c
...
BIN=test.bin

I also suggest changing the mkg3a line (line 16) to resemble my example earlier in this post, since the additional -n options merely serve to clutter up your command line (pre-0.1c mkg3a needed those, but not anymore).
Raylin, were you able to successfully build a program using the PrizmSDK yet? Tari gave you a very thorough and helpful reference there. Smile
I got a Hello World program going!
Raylin wrote:
I got a Hello World program going!
Built and tested on your calculator? If so, that's superb; what's next for you? More learning, or specific projects? I think you're relatively new to C, so I'd vote more learning.
More learning for me. Razz
Raylin wrote:
More learning for me. Razz
Any idea of what kind of toy programs you want to try making?
Probably gonna start with another Hello World program (with color this time) then I'll try a simple move program. Then, I'll make that program again with color. After all that, I'll move on to GUI and drawing shenanigans.
sorry I be cut into this topic, but what would be the .bat format for that, Tari? I imagine it would be pretty close, but I don't have CMake and I won't be able to install it anyways Razz
Raylin wrote:
Probably gonna start with another Hello World program (with color this time) then I'll try a simple move program. Then, I'll make that program again with color. After all that, I'll move on to GUI and drawing shenanigans.
Sounds like a good plan. Don't forget that if you want to do sprites, you should use the sprite routines in the Useful Prizm Routines topic, which I will be gradually improving over time, most likely.
Ashbad wrote:
sorry I be cut into this topic, but what would be the .bat format for that, Tari? I imagine it would be pretty close, but I don't have CMake and I won't be able to install it anyways Razz

You don't need cmake, you need GNU make (or a compatible implementation). My patch package for the SDK includes the MinGW make binary and whatever libraries it depends on; just extract to the same place your PrizmSDK is and replace any existing files with the ones from my archive (also includes some fixes to the Makefile):
http://media.taricorp.net/PrizmSDK-patch1.7z

Run bin\make.exe from the main SDK directory.
Tari, does it also include that swath of missing .dlls that Jonimus has on his server?
... can you upload it in .zip format? I can't get anything that opens it on my computer >_>
Ashbad wrote:
... can you upload it in .zip format? I can't get anything that opens it on my computer >_>
You can use 7-zip on Windows to open .7z (and .rar, and .tar/.gz/.tar.tz/.bz2, and a host of other awesome formats); you really should have it anyway.
That's the thing -- my computer has admin privileges that block me out of using any type of installer -- plus, since I don't care much for compression on my computer (I have 70% of my space still left) I never thought of really having one. I could try to convince my dad to type in the password for the installer, but that could take many, many weeks of convincing from my earlier experience trying to get him to type in the password so I could get Netbeans. So, if possible, can someone add a .zip version? Razz
The 7-zip command line version looks like it doesn't require installation, just running from (duh) the command line. Check it out:

http://www.7-zip.org/download.html
Why don't you use a portable version of 7-zip that runs off a USB drive?
souvik1997 wrote:
Why don't you use a portable version of 7-zip that runs off a USB drive?
Very good, Souvik, that was going to be my next suggestion if he didn't like the command-line version. Great minds! Wink
hmm -- Kerm, I got that this morning, but the compiled HTML help file doesn't work for me -- therefore, I have no idea what the arguments are for it Sad But, if you happen to know, that would be very helpful Wink
  
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 3
» 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