Linux JNIʵÀý¼°ÆäJNI³ÌÐòÉè¼ÆÄ£°å
¼òµ¥ÊµÀý˵Ã÷´ý²¹³ä£¬ÊµÀýÔ´Âë¿ÉÔÚ´ËÁ´½ÓÏÂÔØhttp://d.download.csdn.net/down/2389895/sanlinux
jniNative.cpp
#include "jniNative.h"
#include "mymain.h"
#include <stdio.h>
JNIEXPORT void JNICALL Java_HelloWorld_print(JNIEnv *env, jobject arg, jstring instring)
{
const char *str = (const char *)env->GetStringUTFChars(instring, JNI_FALSE);
printf("HELLO,%s\n",str);
env->ReleaseStringUTFChars(instring,str);
return;
}
JNIEXPORT void JNICALL Java_HelloWorld_test(JNIEnv *env, jobject arg, jstring instring)
{
const jbyte *str = (const jbyte *)env->GetStringUTFChars(instring, JNI_FALSE);
test((const char *)str);
env->ReleaseStringUTFChars(instring, (const char *)str);
return;
}
jniNative.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */
//javac HelloWorld.java
//javah HelloWorld
//Copy from HelloWorld.h
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: print
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_HelloWorld_print
(JNIEnv *, jobject, jstring);
/*
* Class: HelloWorld
* Method: test
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_HelloWorld_test
(JNIEnv *, jobject, jstring);
#ifdef __cplusplus
}
#endif
#endif
mymain.cpp
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mymain.h"
void test(const char *str)
{
char ch[50];
int len = 0;
strcat(ch,"Hello ");
&nbs
Ïà¹ØÎĵµ£º
½øÈëlinuxºó·¢ÏÖ£¬°²×°ÏµÍ³Ê±Ã»°²×°ÖÐÎÄ×ÖÌ壬ÏÔʾ¶¼ÊÇÂÒÂë¡£
¡¡¡¡Ã»°ì·¨£¬µ½ÍøÉÏËÑËѰɡ£ÕÒµ½¸ö½â¾ö·½·¨¡£
¡¡¡¡´ó¼ÒƽʱʹÓÃϰ¹ßÁ˵ÄwinxpÀïÃæµÄËÎÌå¡¢»¹Óз½ÕýÅŰæÏµÍ³ÀïÃæµÄ·ÂËÎÌå¡¢¹«ÎÄÖеķ½ÕýС±êËεȵȣ¬ÕâЩ×ÖÌå¶¼ÊÇÉÌÒµ¹«Ë¾¿ª·¢³öÀ´ÓÃÔÚ×Ô¼ºµÄ²úÆ·Öеģ¬ÊÇÓаæÈ¨µÄ£¬ËùÒÔlinux²»ÄÜÄùýÀ´¾ÍÓá£Èç¹ûÄ㻹ûÓÐÌý˵¹ ......
vi±à¼ÃüÁî
½øÈë±à¼Ä£Ê½ --> i (insert) »òÕß a (append)
½øÈëÃüÁîģʽ --> Esc
ÃüÁîģʽ³£ÓòÙ×÷:
ɾ³ýÒ»ÐÐ --> dd
¸´ÖÆÒ»ÐÐ --> yy
Õ³Ìù --> p ( yy ºÍ p ÊǽáºÏʹÓÃ)
Ìæ»» --> :s/oldwords/newwords Ìæ»»µ±Ç°ÐÐ :%s/oldwords/newwords Ìæ»»ËùÓÐ
×¢:ÌØÊâ×Ö·ûÓÃ"\"תÒå&n ......
------linuxÉ豸Çý¶¯³ÌÐòµÄ¼ò½é
֮ǰֻÊÇ×öÏîÄ¿µÄʱºòÓùýÒ»¶Îʱ¼älinux£¬¶ÔlinuxÆäʵ²»ÔõôÊìϤ£¬µ«ÊÇ´óÖµIJÙ×÷£¬±à³ÌµÄ·½·¨£¬¹¤¾ß(eclipse, gcc)·½Ã滹ÊÇÉÔ΢¶®Ò»µãµÄ£¬¶ÔÓÚÎÒÀ´Ëµ£¬Ò»Ö±Ê¹ÓõÄÊÇCÓïÑÔ£¨¶àÊýǶÈëʽϵͳ¿ª·¢Ê¹Óã©£¬Ò»Ö±Ï뻨µãʱ¼äÀ´ºÃºÃµÄѧϰһÏÂlinuxϵÄÇý¶¯¿ª·¢£¬ÕýºÃÕâ¶Îʱ¼äÒ»Ö±ÔÚ´ýÒµ½×¶Î£¬¾ÍºÃº ......
»·¾³: LINUX ÆóÒµ°æ5.0
boost_1.40, zlib_1.53, lua_1.5
¹¤¾ß: codelite
ÈçºÎ±àÒëboost, zlib, lua:
±àÒëboost:
1. ½øÈëboost_1_40_0Îļþ¼Ð
2. ./bootstrap.sh
3. ./bjam install
¾ÍÕâ3²½¾Í×°ºÃboostÁË
±àÒëlua:
make
make g ......
Platform and tools: Ubuntu 9.04
Step 1, Download the nios linux tallbal
wget http://www.niosftp.com/pub/linux/nios2-linux-20090929.tar
or use xunlei to fix it.
Step2,
tar xvf nios2-linux-20090929.tar
cd nios2-linux
./checkout
Step 3, Generate the fpga.h f ......