GoAhead_在Eclipse下尝试构建工程

1.新建C工程并设置交叉编译器

在这里插入图片描述
在这里插入图片描述
工程文件上出现莫名的红色的‘X’
在这里插入图片描述

program “g++” not found in PATH .

命令行敲“g++”,提示Command “g++” not found, but can be install with:

sudo apt-get install g++

安装g++成功:
在这里插入图片描述
在启动之前,设置Vbox的网络为网卡桥接,选择无线网络。就可以在虚拟机下连上网。安装成功后,按照如下步骤设置即可消除之前的g++没有发现的错误。
在这里插入图片描述

2. Eclipse 导入已有Makefile工程

Eclipse支持makefile导入工程,这样工程的效率很大提高。
New–>others–> C/C++ --> MakeFile Project with Existing Code --> 输入工程名+导入文件
在这里插入图片描述

3. Build

点击project–>Build All,此时在Console窗口输出相关的编译信息,和在目录下输入make时一致。
在这里插入图片描述
可是,这个编译使用的是GCC编译,看编译信息“build/linux-x64-default”可看出。

3.1 添加路径

/etc/profile和~/.bashrc

3.2 设置Debug 启动参数

这里是一定要配置启动参数。
goahead运行时,需要一定的配置参数。–home就是切换到某个目录
/opt/goahead-4.1.0/test/web 是网页放置的目录。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
Action ajaxtest is not defined,是因为网页请求的函数名和goahead中定义的不一样。
Segmentation fault错误:C语言错误造成的。
在这里插入图片描述

3.3 错误:XML Parsing Error: syntax error

在这里插入图片描述
虽然定时请求成功了,出现XML Prasing Error:syntax error错误。但是在Windows,使用Chrome浏览器请求并没有出现该反馈。在Ubuntu上使用的是Foxfire浏览器,是否是浏览器的差异导致。

  • 解决:
    网上查说:这是FireFox有的,Chrome没有,解决的办法是增加Content-Type:”text/plain”
    参考解决方法
If you look in the developer console, you can see that Firefox is interpreting the plain text data as another format (likely XML). Firefox tires to parse the data as XML, but can't because it's not valid XML which results in "Syntax error" being printed to the console.
Fixing this problem for me involved editing the server so it returned the following header:
Content-Type: "text/plain"
This only appeared to be an issue with Firefox, Chrome did not encounter this issue. There is a Firefox bug here which seems to touch on the issue.

3.4 在GoAhead增加http 头部内容

查阅API发现有两个函数

int websWriteHeader (Webs *wp, cchar *key, cchar *fmt, ...)
//This routine writes a response header. It should be invoked after calling websWriteHeaders to write the standard headers and before websWriteEndHeaders. This routine differs from websWrite in that it traces header values to the log
void websWriteHeaders (Webs *wp, ssize contentLength, cchar *redirect)
//Write a set of standard response headers.

修改如下:则不会出现XML Parse Error错误。

1.websWriteHeaders(wp, -1, 0);  
2.websWriteHeader(wp, "Content-Type", "application/json");  
3.websWriteEndHeaders(wp); 

备注:Json数据有特定的Content-Type,是application/json

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值