While Rick is definitely the expert here, I think you need to do the following:
1) Install dependencies necessary to build at all, these vary by your system but on my computer were things like FreeType, Expat, and FontConfig
2) Download AFNI source for your system
3) In afni_src folder, copy the makefile for your system and then rename the copy as just Makefile
4) Build libmri - make libmri.a (not necessary to build everything)
5) Build your code using the list of dependencies (usually helps to be in the AFNI source directory, but not required):
gcc 3dMyTest.c -o 3dMyTest -lmri -lXt -lf2c -lz -lexpat \
-I nifti/niftilib/ -I nifti/nifticdf -I nifti/znzlib -I /opt/X11/include/ \
-I rickr -L . -L /opt/X11/lib/
Depending on what your eventual goal is, you could also just use the C NIFTI library for reading/writing of NIFTI files or there are a series of libraries in Python, Ruby, MATLAB, and R for reading and writing NIFTI formatted files. I'm sure the folks over at PyMVPA and Nipy/Nibabel have done similar things. There is also the R_io library for reading and writing AFNI datasets with R.
Edited 2 time(s). Last edit at 08/13/2014 12:21PM by Peter Molfese.