xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.04k stars 785 forks source link

error: attempt to concatenate local 'p' (a nil value) #933

Closed pchuan98 closed 4 years ago

pchuan98 commented 4 years ago

我在Windows10,Qt15.14.2,VSCode下,先使用xmake自动生成的Qt项目,但是在编译过程中一直出现

C:\Users\adm\Desktop\untitled4\demo\test>xmake f -p mingw --sdk=C:\Qt\Qt5.14.2\Tools\mingw730_64 -P .
checking for the architecture ... x86_64
checking for the mingw directory ... C:\Qt\Qt5.14.2\Tools\mingw730_64
error: attempt to concatenate local 'p' (a nil value)

这种问题,请问是我什么位置没有配置好么?还是命令输入有问题? 这是默认生成的detect文件

"
{
    ["detect.sdks.find_mingw"] = {
        mingw = {
            cross = "x86_64-w64-mingw32-",
            sdkdir = [[C:\Qt\Qt5.14.2\Tools\mingw730_64]],
            bindir = [[C:\Qt\Qt5.14.2\Tools\mingw730_64\bin]]
        }
    },
    ["detect.sdks.find_qt"] = { },
    __version = "2.3.6",
    find_program = {
        qmake = [[C:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\qmake]]
    }
}

默认生成的xmake.lua

add_rules("mode.debug", "mode.release")

target("test")
    add_rules("qt.widgetapp")
    add_headerfiles("src/*.h")
    add_files("src/*.cpp")
    add_files("src/mainwindow.ui")
    -- add files with Q_OBJECT meta (only for qt.moc)
    add_files("src/mainwindow.h")

希望知道的能帮忙解答一下,万分感谢!

waruqi commented 4 years ago

-P . 不用加 追加一下 -vD 给我看下详细的栈信息

pchuan98 commented 4 years ago

-P . 不用加 追加一下 -vD 给我看下详细的栈信息

C:\Users\adm\Desktop\untitled4\test>xmake f -p mingw --sdk=C:\Qt\Qt5.14.2\Tools\mingw730_64 -vD
checking for the architecture ... x86_64
checking for the mingw directory ... C:\Qt\Qt5.14.2\Tools\mingw730_64
checking for the qmake ... C:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\qmake
error: @programdir\core\main.lua:284: @programdir\core\project\project.lua:882: @programdir\core\base\path.lua:84: attempt to concatenate local 'p' (a nil value)
stack traceback:
    [@programdir\core\base\path.lua:84]: in function 'join'
    [@programdir\modules\detect\sdks\find_qt.lua:171]: in function '_find_qt'
    [@programdir\modules\detect\sdks\find_qt.lua:201]: in function 'find_qt'
    [@programdir\rules\qt\env\xmake.lua:33]:
    [C]: in function 'load'
    [@programdir\core\project\target.lua:68]: in function '_load_rule'
    [@programdir\core\project\target.lua:88]: in function '_load_rules'
    [@programdir\core\project\target.lua:100]: in function '_load_all'
    [@programdir\core\project\target.lua:139]: in function '_load'
    [@programdir\core\project\project.lua:451]: in function '_load_targets'
    [@programdir\core\project\project.lua:880]: in function 'targets'
    [@programdir\actions\config\main.lua:127]: in function '_check_target'
    [@programdir\actions\config\main.lua:277]:
    [C]: in function 'load'
    [@programdir\core\base\task.lua:520]: in function 'run'
    [@programdir\core\main.lua:282]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:317]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:792: in function 'raise'
        @programdir\core\main.lua:284: in function 'cotask'
        @programdir\core\base\scheduler.lua:317: in function <@programdir\core\base\scheduler.lua:315>
waruqi commented 4 years ago

有个qt环境值没取到,你执行 C:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\qmake -query 给我看下所有的qt 环境配置

pchuan98 commented 4 years ago

C:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\qmake -query

C:\Users\adm>C:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\qmake -query
QT_SYSROOT:
QT_INSTALL_PREFIX:C:/Qt/Qt5.14.2/5.14.2/mingw73_64
QT_INSTALL_ARCHDATA:C:/Qt/Qt5.14.2/5.14.2/mingw73_64
QT_INSTALL_DATA:C:/Qt/Qt5.14.2/5.14.2/mingw73_64
QT_INSTALL_DOCS:C:/Qt/Qt5.14.2/Docs/Qt-5.14.2
QT_INSTALL_HEADERS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/include
QT_INSTALL_LIBS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib
QT_INSTALL_LIBEXECS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/bin
QT_INSTALL_BINS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/bin
QT_INSTALL_TESTS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/tests
QT_INSTALL_PLUGINS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/plugins
QT_INSTALL_IMPORTS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/imports
QT_INSTALL_QML:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/qml
QT_INSTALL_TRANSLATIONS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/translations
QT_INSTALL_CONFIGURATION:
QT_INSTALL_EXAMPLES:C:/Qt/Qt5.14.2/Examples/Qt-5.14.2
QT_INSTALL_DEMOS:C:/Qt/Qt5.14.2/Examples/Qt-5.14.2
QT_HOST_PREFIX:C:/Qt/Qt5.14.2/5.14.2/mingw73_64
QT_HOST_DATA:C:/Qt/Qt5.14.2/5.14.2/mingw73_64
QT_HOST_BINS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/bin
QT_HOST_LIBS:C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib
QMAKE_SPEC:win32-g++
QMAKE_XSPEC:win32-g++
QMAKE_VERSION:3.1
QT_VERSION:5.14.2
waruqi commented 4 years ago

我在test分支上加了点调试信息,你安装下这里面的包 https://github.com/xmake-io/xmake/actions/runs/233688773

然后同样的执行,再给我一份完整的输出信息

pchuan98 commented 4 years ago

https://github.com/xmake-io/xmake/actions/runs/233688773

您好,可能因为网络问题,我这里下载多次都显示压缩包损坏,如果可以的话能发到我邮箱里么?pchuan98@qq.com

buaayhq commented 4 years ago

我的和这个情况一样,用test分支打印信息如下


checking for the architecture ... x86_64
results QT_SYSROOT:
QT_INSTALL_PREFIX:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
QT_INSTALL_ARCHDATA:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
QT_INSTALL_DATA:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
QT_INSTALL_DOCS:C:/Qt/Qt5.14.2/Docs/Qt-5.14.2
QT_INSTALL_HEADERS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/include
QT_INSTALL_LIBS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib
QT_INSTALL_LIBEXECS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin
QT_INSTALL_BINS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin
QT_INSTALL_TESTS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/tests
QT_INSTALL_PLUGINS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins
QT_INSTALL_IMPORTS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/imports
QT_INSTALL_QML:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/qml
QT_INSTALL_TRANSLATIONS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/translations
QT_INSTALL_CONFIGURATION:
QT_INSTALL_EXAMPLES:C:/Qt/Qt5.14.2/Examples/Qt-5.14.2
QT_INSTALL_DEMOS:C:/Qt/Qt5.14.2/Examples/Qt-5.14.2
QT_HOST_PREFIX:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
QT_HOST_DATA:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
QT_HOST_BINS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin
QT_HOST_LIBS:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib
QMAKE_SPEC:win32-msvc
QMAKE_XSPEC:win32-msvc
QMAKE_VERSION:3.1
QT_VERSION:5.14.2

kv { "QT_SYSROOT" }

kv { "QT_INSTALL_PREFIX", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64" }

kv { "QT_INSTALL_ARCHDATA", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64" }

kv { "QT_INSTALL_DATA", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64" }

kv { "QT_INSTALL_DOCS", "C", "/Qt/Qt5.14.2/Docs/Qt-5.14.2" }

kv { "QT_INSTALL_HEADERS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/include" }

kv { "QT_INSTALL_LIBS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib" }

kv { "QT_INSTALL_LIBEXECS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin" }

kv { "QT_INSTALL_BINS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin" }

kv { "QT_INSTALL_TESTS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/tests" }

kv { "QT_INSTALL_PLUGINS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins" }

kv { "QT_INSTALL_IMPORTS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/imports" }

kv { "QT_INSTALL_QML", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/qml" }

kv { "QT_INSTALL_TRANSLATIONS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/translations" }

kv { "QT_INSTALL_CONFIGURATION" }

kv { "QT_INSTALL_EXAMPLES", "C", "/Qt/Qt5.14.2/Examples/Qt-5.14.2" }

kv { "QT_INSTALL_DEMOS", "C", "/Qt/Qt5.14.2/Examples/Qt-5.14.2" }

kv { "QT_HOST_PREFIX", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64" }

kv { "QT_HOST_DATA", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64" }

kv { "QT_HOST_BINS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin" }

kv { "QT_HOST_LIBS", "C", "/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib" }

kv { "QMAKE_SPEC", "win32-msvc" }

kv { "QMAKE_XSPEC", "win32-msvc" }

kv { "QMAKE_VERSION", "3.1" }

kv { "QT_VERSION", "5.14.2" }

qtenvs { QT_VERSION = "5.14.2", QMAKE_VERSION = "3.1", QMAKE_SPEC = "win32-msvc", QMAKE_XSPEC = "win32-msvc" }

error: attempt to concatenate local 'p' (a nil value)

waruqi commented 4 years ago

大概知道了 QT_INSTALL_ARCHDATA:C:/Qt/Qt5.14.2/5.14.2/msvc2017_64

在 win 上取得环境值,按 : 分隔 key/value ,被 C: 里面的 冒号干扰了,我一会改下。

waruqi commented 4 years ago

我改好了,可以直接执行 xmake update -s dev 更新下脚本,或者直接到 https://github.com/xmake-io/xmake/actions/runs/233884380 上下载安装包 重装下 (目前还在 build 中。)

pchuan98 commented 4 years ago

xmake update -s dev

已解决,谢谢了。

C:\Users\adm\demo\test2>xmake
checking for the architecture ... x64
checking for the Microsoft Visual Studio (x64) version ... 2015
checking for the Qt SDK directory ... C:/Qt/Qt5.14.2/5.14.2/msvc2015_64
checking for the Qt SDK version ... 5.14.2
[ 28%]: compiling.qt.ui src\mainwindow.ui
[ 42%]: compiling.qt.moc src\mainwindow.h
[ 57%]: compiling.release src\main.cpp
[ 71%]: compiling.release src\mainwindow.cpp
[ 85%]: linking.release test2.exe
[100%]: build ok!
warning: add_cxflags("-fPIC") is ignored, please pass `{force = true}` or call `set_policy("check.auto_ignore_flags", false)` if you want to set it.
buaayhq commented 4 years ago

这个安装包运行之后出现如下问题:

$ xmake
checking for the architecture ... x86_64
checking for the Qt SDK directory ... C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
checking for the Qt SDK version ... 5.14.2
error: please run `xmake f -p mingw --mingw=/mingw64` to support Qt/Mingw64 on Msys!

我没有用mingw环境

改成如下的命令可以编译:

$ xmake f -p windows
checking for the architecture ... x64
checking for the Microsoft Visual Studio (x64) version ... 2019
checking for the Qt SDK directory ... C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
checking for the Qt SDK version ... 5.14.2
waruqi commented 4 years ago

这个安装包运行之后出现如下问题:

$ xmake
checking for the architecture ... x86_64
checking for the Qt SDK directory ... C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
checking for the Qt SDK version ... 5.14.2
error: please run `xmake f -p mingw --mingw=/mingw64` to support Qt/Mingw64 on Msys!

我没有用mingw环境

改成如下的命令可以编译:

$ xmake f -p windows
checking for the architecture ... x64
checking for the Microsoft Visual Studio (x64) version ... 2019
checking for the Qt SDK directory ... C:/Qt/Qt5.14.2/5.14.2/msvc2017_64
checking for the Qt SDK version ... 5.14.2

我不知道你配置的平台和运行环境,自己看下 下面哪个条件没满足

        if is_plat("windows") or (is_plat("mingw") and is_host("windows")) then
            target:add("runenvs", "PATH", qt.bindir)
            target:set("runenv", "QML2_IMPORT_PATH", qt.qmldir)
            target:set("runenv", "QML_IMPORT_TRACE", "1")
        elseif is_plat("msys", "cygwin") then
            raise("please run `xmake f -p mingw --mingw=/mingw64` to support Qt/Mingw64 on Msys!")
        end
pchuan98 commented 4 years ago

我改好了,可以直接执行 xmake update -s dev 更新下脚本,或者直接到 https://github.com/xmake-io/xmake/actions/runs/233884380 上下载安装包 重装下 (目前还在 build 中。)

请问VSCode插件也是您负责的么?在使用xmake创建project的时候我遇到了这个问题

> Executing task: xmake create -t qt.widgetapp -l c++ -P c:\temp\demo <

create demo ...
error: project directory (C:\temp\demo) is not empty!
The terminal process "C:\Windows\System32\cmd.exe /d /c xmake create -t qt.widgetapp -l c++ -P c:\temp\demo" failed to launch (exit code: 4294967295).

Terminal will be reused by tasks, press any key to close it.

提示的是这个文件夹不是空的,但是我的这个文件夹里面是没有东西的。

waruqi commented 4 years ago
xmake create -t qt.widgetapp -l c++ -P

确认下是否真的为空,是否存在隐藏文件,或者通过 xmake l os.emptydir "c:\temp\demo" 判断下

    if not os.emptydir(projectdir) then
        -- otherwise, check whether it is empty
        raise("project directory (${underline}%s${reset}) is not empty!", projectdir)
    end

另外,不同的问题,请另开issues