Win7 VS2013环境编译Squirrel 3.0.7

Squirrel是一个类似Lua,但是更面向对象的脚本语言。

国内这个介绍很少,环境配置更是没有任何文章提到,花了点时间搞定了,备忘记录下过程。

首先是下载,写本文时Squirrel最新版本为3.0.7

http://www.squirrel-lang.org/

解压后用VS2013打开squirrel.dsw,转换后有一个error提示,但是是关于备份的,所以可以忽略。

注意不要习惯性的在Solution上点Build,这样会有问题,因为默认运行时库是MT而非MD的,

在工程属性页

C/C++ >> Code Generation >> Runtime Library

改成MD和MDd

然后是默认编译出来的是MuitiByte的,而现在一般新建项目应该都是Unicode的了。

所以在工程属性页

General >> Character Set

中设成Unicode字符集,再编译就可以了

注意文件要带BOM头

http://forum.squirrel-lang.org/default.aspx?g=posts&m=5689

Squirrel's dofile expects a BOM(see http://en.wikipedia.org/wiki/Byte_order_mark) at the beginning of a UTF8 file (0xEF,0xBB,0xBF) and UCS2 (0xFEFF).
if you cannot add a BOM to your files you'll either have to modify the sqstd to default to unicode(it defaults to ASCII) or write you own reader function and use sq_compile().

编译后得到1个sq.exe和2个lib,sqstdlib.lib和squirrel.lib

然后就和一般的库一样使用了

测试文件在SQUIRREL3etc目录,下面有2个文件

minimal.c

test.nut

注意这个test.nut是ANSI的,要自己存成带BOM头的UTF8,如果你是直接用的默认,那就可以直接用

原文地址:https://www.cnblogs.com/kileyi/p/5005033.html