初步使用xmake

473 阅读1分钟

在阿里云服务器环境下练习使用xmake

创建一个xmake文件

mkdir xmake_test && cd xmake_test //先创建一个目录
xmake create --root

根据提示,更改指令

xmake create --root

创建成功

create xmake_test ...
  [+]: xmake.lua
  [+]: src/main.cpp
  [+]: .gitignore
create ok!

这个时候当前目录下会生成一个与xmake_test同名的文件夹xmake_test

cd xmake_test

可以发现新文件夹xmake_test中会有一个lua文件和src文件夹, src文件夹为存放源代码的文件,目前已有main.cpp,根据个人需要添加

构建的过程: 回到src的上一级,也就是有lua文件的目录下

xmake --root

成功:

checking for platform ... linux
checking for architecture ... x86_64
[ 25%]: compiling.release src/main.cpp
[ 50%]: linking.release xmake_test
[100%]: build ok!

这个时候会生成一个新的文件夹build,用来存放可执行文件,具体路径为

/xmake_test/build/linux/x86_64/release

执行的话

xmake run --root

即可。

相比CMake非常简单。

1.如果系统提示:

error: Running xmake as root is extremely dangerous and no longer supported.
As xmake does not drop privileges on installation you would be giving all
build scripts full access to your system.
Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.

那么在指令后加上 --root即可

xmake create --root
xmake run --run