c4droid怎么c语言中调用库函数数?

||||||||||||||||||
查看: 331|回复: 3
在线时间1493 小时经验值1834 最后登录注册时间帖子阅读权限90UID1415815
硕士, 积分 1834, 距离下一级还需 666 积分
TA的每日心情无聊 14:43签到天数: 3 天[LV.2]偶尔看看I
G币239 最后登录注册时间
本帖最后由 ltwo 于
22:47 编辑
写代码后运行就会出现/files/temp.c:3:error unrecognized character\xef.
在设置/选择编译器/选择其他两个编译器都要去google play下载,但我已经安装了插件库了
用过的帮帮忙吧?????万分感谢!!!!!!!!!!
在线时间1648 小时经验值3910 最后登录注册时间帖子阅读权限110UID2031678
博士后, 积分 3910, 距离下一级还需 790 积分
TA的每日心情奋斗 12:29签到天数: 5 天[LV.2]偶尔看看I
G币476 最后登录注册时间
之前用过但是不是这么会用 经常出错
坚持不懈的研究我的小T
在线时间326 小时经验值2381 最后登录注册时间帖子阅读权限90UID3418666
硕士, 积分 2381, 距离下一级还需 119 积分
该用户从未签到
G币39 最后登录注册时间
泪流满面,顶楼主!
在线时间502 小时经验值1117 最后登录注册时间帖子阅读权限80UID1623734
研究生, 积分 1117, 距离下一级还需 583 积分
TA的每日心情郁闷 15:09签到天数: 4 天[LV.2]偶尔看看I
G币167 最后登录注册时间
先把程序以及两个编译器都卸载,然后先安装编译器,再安装主程序就解决问题了。
剑舞寒江英雄胆 琴抚冷月美人心
浏览过的版块
Powered by下次自动登录
现在的位置:
& 综合 & 正文
使用C4droid和botbrew在andriod手机上编程
简单介绍如何安装使用C4droid和botbrew,以及如何在手机上用它们编写运行程序。 注意:
1:C4droid和botbrew都需要手机拥有root权限才可以正常运行。
2:本文章绝不提供任何破解程序的下载!
: He YiJun
(storysnail&at& QQ:)
Develop Team : 7fane Team
: Yang QiuXi
Art Designer : He YiJun
: 7fane Team
License 1.0
Last Update
一:使用C4droid
到google play搜索C4droid,然后下载安装,现在最新的版本是3.98,当然这么好的软件一定要收些费用的,目前的价格是¥18.61。安装好C4droid点图标运行,它会提示要下载gcc、sdl、QT的插件,按照提示到google play下载和安装。
c4driod自己的介绍文档,是英文的,很简单也比较全面,懒得翻译了,自己看吧! C4droid is a C/C++ IDE + C/C++ compiler for Android with GNU Makefile, SDL and Qt support. C4droid supports devices with ARM processors only (not devices with Intel x86 or MIPS processor). You can create your own applications on Android phone, run them (even without Internet access: compiler is offline) and export executables (for terminal apps) or APK (for apps with GUI usage). This app uses TCC and uClibc (or GCC with Bionic libc with a plugin), so it has full support of ANSI C and ISO C99. C4droid can be used for educational purposes or to practice in C/C++ language. C4droid supports syntax highlighting, code completion and source code formatting, so it is a very handy tool for programming on the go.
To get C++ support you need: 0) Enough internal memory OR root rights. C4droid doesn't require root rights for devices with more than 50MB of free internal memory. 1) Install GCC plugin (C4droid will ask you to install it). 2) Select G++ compiler in C4droid preferences. 3*) Use iostream, not iostream.h 4*) Add "" to your program (before int main)
C4droid contains a Terminal Emulator with BusyBox, so you can use Makefiles without any changes, shell commands syntax is the same as on Linux PC. To compile Makefile projects, open any file in the same folder with Makefile and long-click "Compile" to configure current directory (C4droid will create .c4droid configuration file when you'll press Ok). After configuring folder, you can press compile button and C4droid will build your project. Don't forget to enter executable name and select compilation mode (and press ok also, else changes will be discarded)
C4droid supports SDL, NativeActivity and Qt for GUI now, install SDL plugin for C4droid to use it (only GCC/G++ compiler is supported, so you need GCC plugin). (SDL is detected with #include "SDL.h", NativeActivity is detected with #include "android_native_app_glue.h", Qt is detected with #include "QtGui"). There is an experimental support for Qt using necessitas, but note that it's in alpha stage. Qt support limitations: 1) Path to Ministro libraries is hardcoded (/data/data/org.kde.necessitas.ministro/files/qt/lib), so email me if it will change. 2) If you're compiling a single-file Qt app, you must add #include "yoursourcefilenamewithcpp.moc" to the end of file. If you're using .pro file for compilation, you don't need to do that.
Quick manual: If you have found a bug or app is not working, email me.
Long click actions:
长按某一按键会有第二功能 Save button: save as. Open button: recent files. Run button: run with arguments. Compile button: configure current directory. Tab: close tab.
Result of compilation (binary or APK) can be exported using menu-&export. If you have "Illegal instruction" error, using internal compiler (TCC), install GCC plugin, GCC supports softfloat (by default).
C4droid will check license via the Internet.
Report bugs at .
Some components of this app are licensed under (L)GPL, email me to get the source code. Android is a trademark of Google Inc. Qt is a registered trademark of Digia.
相信很多ChineseMan会使用网络上流传的破解版,不过那样做真的没有必要,因为本文第二部分就会介绍botbrew!也许有人会诡辩说botbrew写不了QT和SDL程序,那好,我建议你可以玩玩botbrew basil!
我在手机上写了两个示例程序,get-www是一个单文件程序,与前几天写的《使用Code::blocks在windows下写网络程序》中的示例程序功能相同(链接地址是/?p=248)。function-fetch是一个多文件程序,它的作用是从一个指定文件中检索出特定的内容。我使用C4droid和botbrew都成功编译运行了这两个示例程序,下面是在C4droid中的运行截图。示例程序的源代码会附在本文末尾。 get-www示例程序截图
function-fetch示例程序截图
二:使用botbrew
到google play搜索botbrew,然后下载安装,botbrew是开源软件,可以访问其官方网址/来了解更多信息,当前版本为1.0.1.7,安装好botbrew点图标运行。
botbrew的主界面和程序管理器类似,在其中可以选择安装很多程序,像gcc、python、perl、lua、lynx、make等。安装好所需软件后,进入终端模拟器(终端模拟器有很多,选择一个你喜欢的下载安装即可,有些android系统会默认带一个)。输入su,取得root权限,然后再输入botbrew,然后就可以输入软件的名字来运行了,不过因为是在root下,所以这种方法是非常危险的!你可以用botbrew建立普通账户来运行,详情请参考borbrew手册/manual.htm 说到botbrew就不得不提botbrew basil,它是botbrew的升级版,但目前还处于开发状态。它可以在手机上安装一个debian环境,你可以直接下载安装debian到data分区或sdcard,安装完一个35mb左右的debian环境后就可以安装各种软件了,gcc,gdb,python,jdk,Xserver(使用前需先关掉安卓的屏幕刷新setprop ctl.stop surfaceflinger),lxde。显然手机已然变成一台计算机了!打开终端模拟器,输入 chroot /botbrew/bin/bash 然后就进入了支持高亮的bash!
2:使用botbrew的gcc编译和运行程序
昨天Ling向我提出了抗议,说写了一个sqlite-test的测试程序,也成功编译了该程序,可偏偏无法运行,还会提示没有权限!
#./sqlite-test
./sqlite-test: permission denied
然后她尝试了各种方法,用chmod修改权限,用chown修改用户和组,用export修改PATH等,不过都失败了!实际上问题并没有那么复杂,出现这个情况的原因是android只允许在特定文件夹下运行程序,例如/data,所以你需要获得系统的root权限来访问/data文件夹!如果Ling想使用botbrew的gcc编译和运行程序,那么就应该像下面这样做。
//启动终端模拟器后用su命令提升权限
//启动botbrew程序
//进入/data目录
#mkdir ling
//新建一个名为ling的目录,这样方便管理
//进入ling
#mv /sdcard/sqlite-test ./
//将sqlite-test目录以及其下的源文件移动到ling下
#cd sqlite-test
//进入sqlite-test测试程序的目录
//编译测试程序
#./sqlite-test
//测试程序就可以正常运行了!
有些朋友在看过下面的图片时可能会有疑问,不是说android只允许在特定文件夹下运行程序吗,可你的图片却显示你是直接在sdcard里面运行的测试程序!嗯,关于这个问题我只能回答“开源真好,在自己建造的系统里可以为所欲为!”
function-fetch示例程序截图
get-www示例程序截图
三:两个示例程序的源代码
get-www示例程序源代码
/********************************************************************************
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Develop Team
7fane Team
Main Programmer
(storysnail&at& QQ:)
7fane Team
License 1.0
Last Update
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
*********************************************************************************/
#include &stdlib.h&
#include &stdio.h&
#include &string.h&
#include &stdarg.h&
#include &sys/socket.h&
#include &netinet/in.h&
#include &netdb.h&
static int gw_connect(char *domain,int port)
struct hostent *site_
struct sockaddr_in s_
site_dns = gethostbyname(domain);
if(site_dns == NULL) {
printf("gethostbyname error!\n");
return -2;
printf("default ip:
%s\n",inet_ntoa(*((struct in_addr *)site_dns-&h_addr)));
for(i=0; i& site_dns-&h_length/sizeof(int); i++) {
printf("IP:%d:%s\n",i+1,inet_ntoa(*((struct in_addr *)site_dns-&h_addr_list[i])));
sock_sd = socket(AF_INET,SOCK_STREAM,0);
if(sock_sd & 0) {
printf ("socket error!");
return -1;
memset(&s_addr,0,sizeof(struct sockaddr_in));
memcpy(&s_addr.sin_addr,site_dns -&h_addr_list[0],site_dns-&h_length);
s_addr.sin_family = AF_INET;
s_addr.sin_port = htons(port);
printf("s_addr ip:
%s",inet_ntoa(*((struct in_addr *)&s_addr.sin_addr)));
return (connect(sock_sd,(struct sockaddr *)&s_addr,sizeof(struct sockaddr))
& 0 ? -1 : sock_sd);
static int gw_send(int sock_sd,char *fmt,...)
char buf [1024];
va_start(argptr,fmt);
vsprintf(buf,fmt,argptr);
va_end(argptr);
printf("Send:\n%s\n",buf);
return send(sock_sd,buf,strlen(buf),0);
void main(int argc,char **argv)
char rBuf[3];
sock_sd = gw_connect("",80);
if(sock_sd & 0)
printf("connect error!\n");
//注意:该网站只用于个人测试,在2013年11月末到期,
//如果你在之后的日期使用,请使用其它网页地址
gw_send(sock_sd,"GET /test.html\n");
gw_send(sock_sd,"%c",10);
while(read(sock_sd,rBuf,1) & 0)
printf("%c",rBuf[0]);
close(sock_sd);
function-fetch示例程序源代码
/********************************************************************************
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
function-fetch
Develop Team
7fane Team
Main Programmer
(storysnail&at& QQ:)
7fane Team
License 1.0
Last Update
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
*********************************************************************************/
#include &stdio.h&
#include &stdint.h&
#include &stdlib.h&
#include &string.h&
#include &sys/stat.h&
#include &sys/param.h&
#include &netinet/in.h&
#include "ff-read.h"
int main (int argc, char *argv[])
char filename[MAXPATHLEN];
switch (argc) {
printf ("please input the dictionary's name: ");
if (!fgets (filename, MAXPATHLEN,stdin)) {
perror ("get string error");
if (!strncpy (filename, argv[1], MAXPATHLEN)) {
perror ("copy string error");
fprintf (stderr, "Usage: %s [dictionary name]\n", argv[0]);
name_len = strlen (filename);
if (filename[name_len - 1] == '\n') {
filename[name_len - 1] = '\0';
name_len--;
strncpy (filename + name_len, ".txt", MAXPATHLEN - name_len);
printf("filename:
%s\n",filename);
ff_PrintInfo (filename);
/********************************************************************************
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Develop Team
7fane Team
Main Programmer
(storysnail&at& QQ:)
7fane Team
License 1.0
Last Update
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
*********************************************************************************/
#include &stdio.h&
#include &stdint.h&
#include &stdlib.h&
#include &string.h&
#include &sys/stat.h&
#include &sys/param.h&
#include &netinet/in.h&
#include "ff-read.h"
int ff_PrintInfo (char *filename)
char buf[1024+1];
char keyword[100];
FILE * info_
memset(buf,'\0',1024+1);
memset (keyword, '\0', 100);
info_fd = fopen (filename, "rb");
if (info_fd == NULL) {
perror ("Open information file error");
return(0);
while(!feof(info_fd)) {
if (!fgets (buf, 1024, info_fd)) {
if (!strncmp (buf, "[ff-keyword]=", sizeof ("[ff-keyword]=") - 1)) {
sscanf (buf, "[ff-keyword]=%s\n", keyword);
printf ("keyword is %s\n", keyword);
fclose (info_fd);
/********************************************************************************
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Develop Team
7fane Team
Main Programmer
(storysnail&at& QQ:)
7fane Team
License 1.0
Last Update
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
*********************************************************************************/
#ifndef __FF_READ_H__
#define __FF_READ_H__
int ff_PrintInfo (char *filename);
[sourcecode language="bash"]
/********************************************************************************
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
/*****************************************************************************
For function-fetch
Develop Team :
7fane Team
Programmer
(storysnail&at& QQ:)
7fane Team
License 1.0
Last Update
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
*********************************************************************************/
CFLAGS = -Wall -ggdb
OBJFILES = main.o ff-read.o
main:$(OBJFILES)
$(CC) $(CFLAGS) $(OBJFILES) -o main
main.o:main.c ff-read.h
$(CC) $(CFLAGS) -c main.c -o main.o
ff-read.o:ff-read.c ff-read.h
$(CC) $(CFLAGS) -c ff-read.c -o ff-read.o
rm -f *.o *~ main
7fane Team 协议 1.0
当您阅读、理解并愿意遵守以下条款时,您就拥有了获取、使用、复制、分发或通过通信 网络传播7fane Team作品的权利。
1. 7fane Team的作品可以在非商业用途下免费使用。
2. 如果软件提供了源代码,那么你可以更改源代码或软件接口以适应你的应用。
3. 在未获得7fane Team的授权之前,你不可以在商业用途下使用7fane Team的作品,
也不可以将7fane Team的作品用于营利为目的的活动。关于获得许可,请发送Email
到以获取更多信息。
4. 你不得租赁,再许可,出售,转让,抵押7fane Team的作品和服务。
5. 你不得删除或修改7fane Team作品的版权信息和相关的链接,例如网址信息或“关于窗口”
中的所有信息,除非您已经获得7fane Team的书面授权。
6. 你不可以通过修改7fane Team的作品来获得衍生作品,更不可以重新分配这些衍生作品。
7. 如果您不能遵守本协议,您的许可将被终止,您必须停止使用并删除7fane Team作品及其
副本,并且不可以再继续获取、使用、复制、分发或通过通信网络传播7fane Team作品。
8. 7fane Team拥有并保留修改本协议的权利和在本协议修改后不另行通知的权利。修改后
的新协议将适用于新的许可用户。
9. 7fane Team作品是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。
10.7fane Team对于使用其作品而生成的任何信息不承担任何责任,也不会对传播或使用
这些信息承担责任。
11. 用户出于自愿而使用本7fane Team作品,您必须了解使用的风险,我们不承诺对用户提供
任何形式的技术支持、使用担保,所以你必须承担全部风险。 关于 "7fane Team作品" 的定义:
"7fane Team作品" 包括文本、图像、音频视频、软件等由7fane Team创作的一切。
版权所有 (c),7fane Team 保留所有权利。
&&&&推荐文章:
【上篇】【下篇】c4droid怎么调用手机传感器数据_c4droid吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:36,151贴子:
c4droid怎么调用手机传感器数据收藏
求教各路大神
想买澳洲奶粉?这里有一条包税专线
写原生Android
参照c4示例代码cube.c吧
登录百度帐号推荐应用安卓智能用c4droid 编c++吗?c4droid是怎么安装的_百度知道
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。
安卓智能用c4droid 编c++吗?c4droid是怎么安装的
我有更好的答案
点击yes就OK了,当然也可能会因为手机不一样,插件会自动解压,这样换旧的插件版本试一下,因为现在网上比较乱,有些软件是大神改的,又或者手机原因,自己找吧,自动把插件数据解压到主程序了。编写程宇时在菜单&#47。。)的地址;跳出有直接下载两个最新插件(GCC。SDL,解压时自动弹出一个窗口;preference/setting complied&#47,有些最新版本运行不了,或者是GCC和SDL只能有一个正常,也或者c4可用,但两个插件用不了;G ,编译C ,在该页面也有下载c4droid主程序的下载链接自己百度&GCC_SDL_FOR-C4droid&quot。。。下载后先安装插件,成功后安装主程序,一般安卓手机都可以用的
采纳率:37%
.- 在安卓上折腾c...? 汗.. 不辛苦么
为您推荐:
其他类似问题
安卓的相关知识
等待您来回答

我要回帖

更多关于 python调用c库函数 的文章

 

随机推荐