• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding cc compiler in linux ... i get an error

 
karthick chinnathambi
Ranch Hand
Posts: 196
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried to compile a .c file using cc compiler which had the native code implementation of a Java file....

i got the following error.. can somebody help me out please........


cc -G -I /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/include -I /usr/lib/jvm/java-1.6.0-openjdk/include/linux HelloWorldImp.c -o libhello.so
cc: unrecognized option '-G'
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status


for your information am using fedora 11...

thanks in advance..
 
karthick chinnathambi
Ranch Hand
Posts: 196
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

gcc HelloWorldImp.c -o libhello.so
HelloWorldImp.c:1:17: error: jni.h: No such file or directory
In file included from HelloWorldImp.c:2:
HelloWorld.h:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
HelloWorldImp.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’


i tried this also and again got error.
please someone help...........
 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your first piece of code you should make sure to compile the code into a library. You missed one flag (-shared). Without this the compiler tries to create a stand-alone executable which requires a main function.
 
karthick chinnathambi
Ranch Hand
Posts: 196
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot for your reply.............
it worked............


but i couldn't understand what you said.......

can you explain me about creating shared libraries, and all these stuffs......
can you show me a good link where i can clearly learn all these stuffs....... especially those needed for JNI programming...........



Thanks a lot once again riend........
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic