Calculator Community > Calculator C

Tutorial - Setting up C Development Environment for the TI-Nspire

(1/20) > >>

apcalc:
TI-Nspire C Development Set Up For Ndless Version 1.7

Many people on this website, including myself, have had questions/problems on setting up a C development environment for the TI-Nspire. Because of this, I thought I would write this tutorial to clearly describe the steps to set up a development environment, compile a file, and describe some of the common errors when compiling.

Setting up a Windows C development environment

Two programs are needed for a Windows C development environment:  MSYS, and the YAGARTO toolchain.  You will also need a copy of Ndless for some tools needed to compile.

First, you must install MSYS, which is, according to its website "MSYS, a contraction of "Minimal SYStem", is a Bourne Shell command line interpreter system. Offered as an alternative to Microsoft's cmd.exe, this provides a general purpose command line environment, which is particularly suited to use with MinGW, for porting of many Open Source applications to the MS-Windows platform; it includes a small selection of Unix tools, chosen to facilitate that objective, and using it is a necessary prerequisite for building mingwPORTs."  Here is the link to install MSYS.

http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/msys-core/msys-1.0.11/MSYS-1.0.11.exe/download

Then, you must install YAGARTO, which is a GNU ARM toolchain for Windows.  When you install, make sure the box "Add YAGARTO's to your PATH variable" is checked.  Here is the link.

http://sourceforge.net/projects/yagarto/

Finally, you have to add the Ndless /sdk/bin Directory to your path variable.  If you are running Windows Vista or Windows 7, you can add to the Path variable by press the "Windows" key.  Then, type Path in the search field and choose option two, "Edit the system environment variables".  A dialog box should open up; click "Environment Variables" near the bottom of the dialog box.  A new dialog box should pop up; in the second field, navigate to the "Path" variable and click "edit", then add the Ndless /sdk/bin directory to the end of the list.

To confirm that you have successfully added to the path variable, open the command prompt and type:


--- Code: ---echo %path%

--- End code ---

It should be at the end of the list.

You now have all of the components needed for a C development environment for Windows.  In the next section, I will explain how to compile a file.

Compiling a file

For this example, we will compile the Ndless demo.  First, it is probably best to start with a fresh copy of Ndless, which can be downloaded from the following link.  After you download, unzip the file and remember the file directory to the folder.  You will need this soon.

http://www.ticalc.org/archives/files/fileinfo/426/42626.html

Now, open MSYS and set the current directory to the folder in Ndless that contains the Ndless demo.  Do this by typing "cd <Place Ndless folder path here>/src/samples/particles.  Now type "make".  The Ndless demo should have successfully compiled! You should have received the message:


--- Code: ---$ make
nspire-gcc -Os -Wall -W -c main.c
nspire-gcc -Os -Wall -W -c utils.c
nspire-gcc -Os -Wall -W -c vector.c
nspire-gcc -Os -Wall -W -c particle.c
nspire-gcc -Os -Wall -W -c particle_system.c
nspire-gcc -Os -Wall -W -c gravity_particles.c
nspire-ld  main.o utils.o vector.o particle.o particle_system.o gravity_particles.o -o particles.elf
arm-none-eabi-objcopy -O binary particles.elf ../../calcbin/samples/particles.tns

--- End code ---

If you received this message, or something close to it, you are now ready to start developing in C for the Nspire!  The easiest way to do so is simply to edit the "main.c" file.  Look in the files "common.h", "utils.h", and "os.h" to find commands you can use.  Likewise, there are several functions in the Nspire libraries, which are documented at hackspire.  Also, there are some very useful header files in the tread "Post your Nspire routines here" here at Omnimaga.  If you did not receive this message shown above, you probably received an error message.  In the next section, I will list common error messages and methods to fix them.

Common Error Messages

If you are getting an error message about a file not being found (such as MakeTNS.exe, FlashEdit.exe, nsprie-gcc), make sure you added the bin/ of Ndless to your path variable.  Check this by opening a command prompt window and typing:


--- Code: ---echo %PATH%

--- End code ---

Note:  If you are attempting to build Ndless and you are getting errors, please ensure that the following directories are in your path:
1. MSYS /bin
2. MinGW /bin
3. Ndless Root /bin (created by "make" in the tools directory of Ndless)
4. 7zip Root
5. YAGARTO /bin

If the Ndless /sdk/bin/ directory is not listed in the %PATH% list, follow the procedure above to add it.

If your error message is not listed here, or you have any other questions about the instillation process, feel free to post a reply below and I will try to edit this post and add new error messages here. Thank you!  Good luck developing!

Also, If you do not like using notepad/wordpad to type your code in a text editor with colorized syntax, you can use different text editors such as gedit, Programmers Notepad 2, and Notepad++, all of which have syntax highlighting for C code.

In addition, you can also use the Eclipse C/C++ IDE for developing Ndless programs.  More information on setting up this IDE, and linking it with the GDB Debugging support incorporated into the TI-Nspire Emulator Ncubate can be found in this video on YouTube:

fb39ca4:
I found it easier to install YAGARTO tools (at least in windows), which can be run from cmd.exe, so I can just create a batch file that just contains "make".
Download YAGARTO tools:
http://www.yagarto.de/download/yagarto/yagarto-tools-20100703-setup.exe

DJ Omnimaga:
Nice that should be useful :D

Thanks apcalc fro posting this :D

bwang:
Excellent :)
This should be stickied. Someday, this sub-forum will have many threads in it, and this tutorial will be hard to find.

DJ Omnimaga:
Stickied

Navigation

[0] Message Index

[#] Next page

Go to full version