aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes regarding cc compiler in linux ... i get an error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "regarding cc compiler in linux ... i get an error" Watch "regarding cc compiler in linux ... i get an error" New topic
Author

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

karthick chinnathambi
Ranch Hand

Joined: Jul 06, 2009
Posts: 196

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.C , SCJP6-93%
(Born to Win)
karthick chinnathambi
Ranch Hand

Joined: Jul 06, 2009
Posts: 196


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

Joined: Oct 27, 2005
Posts: 19722
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
karthick chinnathambi
Ranch Hand

Joined: Jul 06, 2009
Posts: 196

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........
 
Consider Paul's rocket mass heater.
 
subject: regarding cc compiler in linux ... i get an error