Ubuntu22.04下Anacodna3的qmake和Qt的qmake冲突问题
- 一、问题描述
- 二、原因分析
- 三、解决办法
一、问题描述
Ubuntu22.04下Anacodna3的qmake和Qt的qmake冲突问题
zhy@zhy-HP:~/Sources/mpv-examples/libmpv/qt$ make
g++ -c -pipe -g -Wall -Wextra -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../../../anaconda3/include/qt -I../../../../anaconda3/include/qt/QtWidgets -I../../../../anaconda3/include/qt/QtGui -I../../../../anaconda3/include/qt/QtCore -I. -I../../../../anaconda3/include -I/opt/conda/conda-bld/qt-main_1660123285207/_build_env/bin/../x86_64-conda-linux-gnu/sysroot/usr/include -I/opt/conda/conda-bld/qt-main_1660123285207/_build_env/bin/../x86_64-conda-linux-gnu/sysroot/usr/include/libdrm -I/opt/conda/conda-bld/qt-main_1660123285207/_build_env/bin/../x86_64-conda-linux-gnu/sysroot/usr/include -I../../../../anaconda3/mkspecs/linux-g++ -o qtexample.o qtexample.cpp
g++ -pipe -g -Wall -Wextra -dM -E -o moc_predefs.h ../../../../anaconda3/mkspecs/features/data/dummy.cpp
/home/zhy/anaconda3/bin/moc -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /home/zhy/Sources/mpv-examples/libmpv/qt/moc_predefs.h -I/home/zhy/anaconda3/mkspecs/linux-g++ -I/home/zhy/Sources/mpv-examples/libmpv/qt -I/home/zhy/anaconda3/include/qt -I/home/zhy/anaconda3/include/qt/QtWidgets -I/home/zhy/anaconda3/include/qt/QtGui -I/home/zhy/anaconda3/include/qt/QtCore -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -I/usr/include/c++/11/backward -I/usr/lib/gcc/x86_64-linux-gnu/11/include -I/usr/local/include -I/usr/include/x86_64-linux-gnu -I/usr/include qtexample.h -o moc_qtexample.cpp
g++ -c -pipe -g -Wall -Wextra -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../../../anaconda3/include/qt -I../../../../anaconda3/include/qt/QtWidgets -I../../../../anaconda3/include/qt/QtGui -I../../../../anaconda3/include/qt/QtCore -I. -I../../../../anaconda3/include -I/opt/conda/conda-bld/qt-main_1660123285207/_build_env/bin/../x86_64-conda-linux-gnu/sysroot/usr/include -I/opt/conda/conda-bld/qt-main_1660123285207/_build_env/bin/../x86_64-conda-linux-gnu/sysroot/usr/include/libdrm -I/opt/conda/conda-bld/qt-main_1660123285207/_build_env/bin/../x86_64-conda-linux-gnu/sysroot/usr/include -I../../../../anaconda3/mkspecs/linux-g++ -o moc_qtexample.o moc_qtexample.cpp
g++ -Wl,-rpath,/home/zhy/anaconda3/lib -o qtexample qtexample.o moc_qtexample.o
-lmpv /home/zhy/anaconda3/lib/libQt5Widgets.so /home/zhy/anaconda3/lib/libQt5Gui.so /home/zhy/anaconda3/lib/libQt5Core.so -L/opt/conda/conda-bld/qt-main_1660123285207/_build_env/bin/../x86_64-conda-linux-gnu/sysroot/usr/lib64 -lGL -lpthread
/usr/bin/ld: /lib/x86_64-linux-gnu/libcaca.so.0: undefined reference to `mousemask@NCURSESW6_5.1.20000708'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcaca.so.0: undefined reference to `nonl@NCURSESW6_5.1.20000708'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcaca.so.0: undefined reference to `noecho@NCURSESW6_5.1.20000708'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcaca.so.0: undefined reference to `init_pair@NCURSESW6_5.1.20000708'
二、原因分析
检查问题,说 libcaca 有问题,查看该库的依赖问题
ldd /lib/x86_64-linux-gnu/libcaca.so.0
输入无问题
linux-vdso.so.1 (0x00007ffc14d1d000)libslang.so.2 => /lib/x86_64-linux-gnu/libslang.so.2 (0x00007fbbde800000)libncursesw.so.6 => /lib/x86_64-linux-gnu/libncursesw.so.6 (0x00007fbbdebc2000)libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007fbbdeb90000)libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fbbdeb74000)libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbbde400000)libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbbde719000)/lib64/ld-linux-x86-64.so.2 (0x00007fbbdecf9000)
则定位到是库的引用问题,这里的库应该是qt的环境库
home/zhy/anaconda3/lib/libQt5Gui.so /home/zhy/anaconda3/lib/libQt5Core.so
正确的库
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so /usr/lib/x86_64-linux-gnu/libQt5Gui.so
三、解决办法
指定 qmake 即可
/usr/bin/qmake
make
编译则正常通过了
zhy@zhy-HP:~/libmpv/qt$ /usr/bin/qmake
zhy@zhy-HP:~/libmpv/qt$ make
g++ -o qtexample qtexample.o moc_qtexample.o -lmpv /usr/lib/x86_64-linux-gnu/libQt5Widgets.so/usr/lib/x86_64-linux-gnu/libQt5Gui.so /usr/lib/x86_64-linux-gnu/libQt5Core.so -lGL -lpthread