使用命令行配置:
xmake f -v --cc=clang --cxx=clang++ --ld=clang++ -m debug
可以正确保存工具链为clang,正确编译代码
但是我希望能在xmake.lua里直接设置工具链,不用再执行配置指令,这么写的:
set_tools("cc", "/usr/bin/clang")
set_tools("cxx", "/usr/bin/clang++")
set_tools("ld", "/usr/bin/clang++")
add_rules("mode.debug", "mode.release")
-- add target
target("hello")
-- 之前set_tools放在这里,也不能生效
-- set kind
set_kind("binary")
-- add files
add_files("src/*.cpp")
直接执行xmake,会默认使用gcc编译,clang++来链接。为什么不是使用clang++编译呢?
请问是不是我设置错了,要如何设置才能在不用调用xmake f配置的情况下,直接可以编译呢?
输出结果:
checking for the architecture ... x86_64
configure
{
plat = linux
arch = x86_64
ccache = true
kind = static
buildir = build
host = linux
mode = release
ndk_stdcxx = true
}
checking for the gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for the /usr/bin/gcc ... ok
checking for the flags (-O3) ... ok
checking for the ccache ... no
[ 0%]: compiling.release src/main.cpp
/usr/bin/gcc -c -fvisibility=hidden -O3 -m64 -I/usr/local/include -I/usr/include -o build/.objs/hello/linux/x86_64/release/src/main.cpp.o src/main.cpp
checking for the flags (-MMD -MF) ... ok
[100%]: linking.release hello
clang++ -o build/linux/x86_64/release/hello build/.objs/hello/linux/x86_64/release/src/main.cpp.o -s -fvisibility=hidden -m64 -L/usr/local/lib -L/usr/lib
使用命令行配置:
xmake f -v --cc=clang --cxx=clang++ --ld=clang++ -m debug
可以正确保存工具链为clang,正确编译代码
但是我希望能在xmake.lua里直接设置工具链,不用再执行配置指令,这么写的:
set_tools("cc", "/usr/bin/clang")
set_tools("cxx", "/usr/bin/clang++")
set_tools("ld", "/usr/bin/clang++")
add_rules("mode.debug", "mode.release")
-- add target
target("hello")
-- 之前set_tools放在这里,也不能生效
直接执行xmake,会默认使用gcc编译,clang++来链接。为什么不是使用clang++编译呢?
请问是不是我设置错了,要如何设置才能在不用调用xmake f配置的情况下,直接可以编译呢?
输出结果:
checking for the architecture ... x86_64
configure
{
plat = linux
arch = x86_64
ccache = true
kind = static
buildir = build
host = linux
mode = release
ndk_stdcxx = true
}
checking for the gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for the /usr/bin/gcc ... ok
checking for the flags (-O3) ... ok
checking for the ccache ... no
[ 0%]: compiling.release src/main.cpp
/usr/bin/gcc -c -fvisibility=hidden -O3 -m64 -I/usr/local/include -I/usr/include -o build/.objs/hello/linux/x86_64/release/src/main.cpp.o src/main.cpp
checking for the flags (-MMD -MF) ... ok
[100%]: linking.release hello
clang++ -o build/linux/x86_64/release/hello build/.objs/hello/linux/x86_64/release/src/main.cpp.o -s -fvisibility=hidden -m64 -L/usr/local/lib -L/usr/lib