Compiling QTermWidget

2019-06-03 15:32发布

I've tried to compile this custom QT widget to provide a terminal that I can embed into my application. I've compiled/installed the build tools for the program that I needed before Cmake would complete, but the make step is throwing errors that google hasn't been too helpful on:

[ 50%] Building CXX object CMakeFiles/qtermwidget5.dir/lib/kpty.cpp.o
/Users/a7c/qtermwidget/qtermwidget-master/lib/kpty.cpp:506:26: error: no member named 'ut_name' in 'utmpx'
        strncpy(l_struct.ut_name, user, sizeof(l_struct.ut_name));
                ~~~~~~~~ ^
/Users/a7c/qtermwidget/qtermwidget-master/lib/kpty.cpp:506:57: error: no member named 'ut_name' in 'utmpx'
        strncpy(l_struct.ut_name, user, sizeof(l_struct.ut_name));
                                               ~~~~~~~~ ^
/Users/a7c/qtermwidget/qtermwidget-master/lib/kpty.cpp:617:20: error: no member named 'ut_name' in 'utmpx'
        memset(ut->ut_name, 0, sizeof(*ut->ut_name));
               ~~  ^
/Users/a7c/qtermwidget/qtermwidget-master/lib/kpty.cpp:617:44: error: no member named 'ut_name' in 'utmpx'
        memset(ut->ut_name, 0, sizeof(*ut->ut_name));
                                       ~~  ^
4 errors generated.
make[2]: *** [CMakeFiles/qtermwidget5.dir/lib/kpty.cpp.o] Error 1
make[1]: *** [CMakeFiles/qtermwidget5.dir/all] Error 2
make: *** [all] Error 2

Does anyone have a solution to this problem?

And as an extension, how exactly does one effectively include a custom widget as to be usable in QT Creator?

2条回答
迷人小祖宗
2楼-- · 2019-06-03 15:59

http://pubs.opengroup.org/onlinepubs/7908799/xsh/utmpx.h.html

It looks like it doesn't include ut_name in the stock version of utmpx.h.

If you look at this version of it:

https://code.woboq.org/kde/include/bits/utmp.h.html

They have a "backwards compatibility hack" in there:

87  /* Backwards compatibility hacks.  */
88  #define ut_name     ut_user

You may want to upgrade that library that includes that header. Or just insert that #define in your code. And as a good github citizen, if it works, you should do a pull request and/or submit an issue about it so that the next person using that library doesn't run into the same issue.

Hope that helps.

查看更多
看我几分像从前
3楼-- · 2019-06-03 16:23

I don't know why the problem happened, since according to all the files I checked everything was named properly.

Adding #define ut_user ut_name to kpty.h solved the problem though.

查看更多
登录 后发表回答