Hi!, Assuming you have a "hadoop" command available (i.e. the $HADOOP_HOME/bin/hadoop script), try to do:
export CLASSPATH=`hadoop classpath` And then try to run your ./a.out. Does this help? Also, user questions may go to u...@hadoop.apache.org. The hdfs-dev@hadoop.apache.org is for Apache HDFS project developer/development discussions alone. I've moved your thread to the proper place. On Thu, Feb 28, 2013 at 4:59 PM, Philip Herron <redbr...@gcc.gnu.org> wrote: > Hey all > > I am trying to use the c api to access hdfs: > > #include <stdio.h> > #include <stdlib.h> > > #include <string.h> > #include <assert.h> > > #include <hdfs.h> > > int main (int argc, char ** argv) > { > hdfsFS fs = hdfsConnect ("default", 0); > assert (fs); > > const char * wp = "test"; > hdfsFile wf = hdfsOpenFile (fs, wp, O_WRONLY | O_CREAT, > 0, 0, 0); > if (!wf) > { > fprintf (stderr, "Failed to open %s for writing!\n", wp); > exit (-1); > } > > const char * buffer = "Hello, World!"; > tSize num_written_bytes = hdfsWrite (fs, wf, (void *) buffer, > strlen (buffer) + 1); > assert (num_written_bytes); > if (hdfsFlush (fs, wf)) > { > fprintf (stderr, "Failed to 'flush' %s\n", wp); > exit (-1); > } > hdfsCloseFile(fs, wf); > > return 0; > } > > -- > > gcc t.c -lhdfs -lpthread -L/usr/java/default/lib/amd64/server -ljvm -Wall > > But i am getting: > > Environment variable CLASSPATH not set! > getJNIEnv: getGlobalJNIEnv failed > a.out: t.c:12: main: Assertion `fs' failed. > Aborted > > Not sure what i need to do now to get this example working. > > --Phil -- Harsh J