473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

error while compiling jni.h

Hi,

I am getting a very strange error

ubuntu:~/docs/jni/jniexamples/chap2/HelloWorld$ gcc
-I/usr/local/share/jdk1.5.0_05/include
-I/usr/local/share/jdk1.5.0_05/include/linux HelloWorld.c
/usr/lib/gcc/i486-linux-gnu/4.0.2/../../../../lib/crt1.o: In function
`_start':
.../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status

How can I fix it?

thank you very much,

Marcelo
Nov 22 '05 #1
7 3899
send the code u were trying to compile ....

Nov 22 '05 #2

Marcelo wrote:
Hi,

I am getting a very strange error

ubuntu:~/docs/jni/jniexamples/chap2/HelloWorld$ gcc
-I/usr/local/share/jdk1.5.0_05/include
-I/usr/local/share/jdk1.5.0_05/include/linux HelloWorld.c
/usr/lib/gcc/i486-linux-gnu/4.0.2/../../../../lib/crt1.o: In function
`_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status

How can I fix it?


By writing a function called int main() or int main(int , char**)

Nov 22 '05 #3
HelloWorld.c is:

#include <jni.h>
#include <stdio.h>
#include "HelloWorld.h"

JNIEXPORT void JNICALL
Java_HelloWorld_print(JNIEnv *env, jobject obj)
{
printf("Hello World!\n");
return;
}

---HelloWorld.java ----------
class HelloWorld {
private native void print();
public static void main(String[] args) {
new HelloWorld().print();
}
static {
System.loadLibrary("HelloWorld");
}
}

This is a jni program from the Sun Tutorial.

thanks for your help,.

Marcelo
PS: the command
gcc -I/usr/local/share/jdk1.5.0_05/include
-I/usr/local/share/jdk1.5.0_05/include/linux HelloWorld.c

Nov 22 '05 #4
If iam not wrong the .cpp file should be compiled into a shared object
library/DLL. Next the java class using the native function should use
some standard calls to utilize the Shared Object/DLL.

No wonder youe code returns such an error.... how can it produce an
executable if it does not find main .. so compile it into a Shared
Object.

Nov 22 '05 #5
Sorry , i was typing ".cpp file" since this list was for cpp.But the
same explanation holds good for C also.

Nov 22 '05 #6
Sorry , i was typing ".cpp file" since this group was for cpp.But the
same explanation holds good for C also.

Nov 22 '05 #7
Procrastinx wrote:
If iam not wrong the .cpp file should be compiled into a shared object
library/DLL. Next the java class using the native function should use
some standard calls to utilize the Shared Object/DLL.

No wonder youe code returns such an error.... how can it produce an
executable if it does not find main .. so compile it into a Shared
Object.

great idea!!!

with the -shared option it works just fine

thanks alot

Marcelo
Nov 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matt | last post by:
Just out of the blue all of my code has given a 'Could not instantiate the resource processor.' error on compiling. This apparently means your installation of VS .Net has lost the plot. So I've...
6
by: bmwrob | last post by:
I’m very new in C++ programming and am trying to make a decoder tool just for the purpose of learning. I started my project in VC++ 6.0, but after a change of PC, I continued my programming in VS...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
0
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'. It happens with...
2
by: teddybyte | last post by:
my script below is: #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, ...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
1
by: sahilrekhi | last post by:
Hi i am working on a graphical user interface deisgn programme. when i compile the file i i get the following output with the mentioned errors: 1>------ Rebuild All started: Project: guiq,...
1
by: SQACPP | last post by:
I have an error when compiling a simple form project... I just start a new Form project and add a new PictureBox in a form(or anything that generate the .resx file) After that when compiling I...
0
by: dami.gupta | last post by:
I am building a chm file using sandcastle and am following instructions on https://blogs.msdn.com/sandcastle/archive/2006/07/29/682398.aspx I am following all the commands which are...
6
by: JR | last post by:
The code below compiles and runs perfectly in Windows XP Pro, Using MS VS 2005. If I compile with g++ (cygwin) using the following command line: g++ -pedantic -Weffc++ -Wall -Wctor-dtor-privacy ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.