• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
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...........
 
Sheriff
Posts: 22002
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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........
 
    Bookmark Topic Watch Topic
  • New Topic