Can you post your CMakelists.txt file for your project? If it is too big or you can't, then create a CMake project from one of the Qwt example programs (simpleplot maybe) and post your complete CMakelists.txt file for that.
Can you post your CMakelists.txt file for your project? If it is too big or you can't, then create a CMake project from one of the Qwt example programs (simpleplot maybe) and post your complete CMakelists.txt file for that.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
It looks like this:
Qt Code:
cmake_minimum_required(VERSION 3.22) project(plottapp) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread") # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed set(CMAKE_AUTOMOC ON) # Find the QtWidgets libraries find_package(Qt6Widgets CONFIG REQUIRED) find_package(Qt6Charts) include_directories(/usr/local/qwt-6.2.0/include) # works set(CUSTOM_LIBRARY_PATH /usr/local/qwt-6.2.0/lib) # does not work set(CMAKE_PREFIX_PATH /usr/local/qwt-6.2.0/lib) # does not work set(plottapp_SRC main.cpp plottapp.cpp mslider.cpp etc. etc. ) qt6_wrap_ui(plottapp_SRC plottapp.ui) add_executable(plottapp ${plottapp_SRC}) target_link_libraries(plottapp Qt6::Widgets Qt6::Charts qwt ) # <-- Chokes on qwt here # Install the executable install(TARGETS plottapp DESTINATION bin)To copy to clipboard, switch view to plain text mode
Last edited by d_stranz; 2nd March 2023 at 20:27. Reason: missing [code] tags
Instead of using the CUSTOM_LIBRARY_PATH or CMAKE_PREFIX_PATH, you should probably use the find_library() command, something like this:
Qt Code:
find_library( QWT NAMES qwt qwt6 PATHS /usr/local/qwt-6.2.0/lib REQUIRED ) target_link_libraries( plottapp Qt6::Widgets Qt6::Charts ${QWT} )To copy to clipboard, switch view to plain text mode
However, your problem all along could be that the library might not be named "qwt" but "qwt6"
In any case, find_library() is a better solution than changing CMake variables, which could have unintended consequences.
With Microsoft compilers, the order of libraries does not matter. In linux and gcc, the libraries might have to be listed in dependency order, i.e. (plottapp ${QWT} Qt6::Charts Qt6::Widgets)
Last edited by d_stranz; 2nd March 2023 at 20:42.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
That got me a bit further, as the libries are now found. However, I get a page full of linking errors, that I cannot make sense of. The order I list the libraries in target_link_libraries doen't seem to make a difference, and the errors are the same whether I compile for Release or Debug:
Qt Code:
[100%] Linking CXX executable plottapp /usr/bin/ld: /usr/local/qwt-6.2.0/lib/libqwt.so: undefined reference to `QtPrivate::QMetaTypeInterfaceWrapper<QVariant>::metaType@Qt_6' /usr/bin/ld: /usr/local/qwt-6.2.0/lib/libqwt.so: undefined reference to `QtPrivate::QMetaTypeInterfaceWrapper<bool>::metaType@Qt_6' /usr/bin/ld: /usr/local/qwt-6.2.0/lib/libqwt.so: undefined reference to `QtPrivate::QMetaTypeInterfaceWrapper<QSize>::metaType@Qt_6' . . . /usr/bin/ld: /usr/local/qwt-6.2.0/lib/libqwt.so: undefined reference to `QtPrivate::QMetaTypeInterfaceWrapper<QTime>::metaType@Qt_6' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/plottapp.dir/build.make:591: plottapp] Error 1 make[1]: *** [CMakeFiles/Makefile2:84: CMakeFiles/plottapp.dir/all] Error 2 make: *** [Makefile:136: all] Error 2 *** Failure: Exit code 2 ***To copy to clipboard, switch view to plain text mode
Finding Qt6Widgets is supposed to also bring in the dependencies (Qt6Gui and Qt6Core) but maybe you need to add those. Those errors look like there is a low level Qt library that is not being linked in. Maybe try putting ${QWT} at the beginning of the link libraries list, followed by Charts, Widgets, Gui, and Core. I think that is the correct dependency order.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
I tried adding Qt6Gui and Qt6Core, and all kinds of reordering, but to no avail. I have no problem using Qt Charts, so the issue must be related to Qwt.
Are you sure you are building qwt against your Qt6 installation? Can you successfully use qwt in a project built with QtCreator? (I know these are "Have you checked to see if it is plugged in?" questions, but I've done things like this in the past, where I have had mismatched builds and nothing seems to work).
It is MOC that results in all of the QMetaType references so something could be wrong with your qwt build.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
I am not absolutely sure I am building Qwt corectly. I built Qwt thus:
/usr/bin/qmake qwt.pro
make
sudo make install
The strange thing is that all the examples supplied with Qwt works perfectly when build by QtCreator.
The file qwtconfig.pri starts of with:
QWT_VER_MAJ = 6
QWT_VER_MIN = 2
QWT_VER_PAT = 0
QWT_VERSION = $${QWT_VER_MAJ}.$${QWT_VER_MIN}.$${QWT_VER_PAT}
which looks correct to me.
I do not know if it is relevant, but qwt.pro has this information at the start:
lessThan(QT_MAJOR_VERSION, 5) {
lessThan(QT_MINOR_VERSION, 8) {
error(Qt >= 4.8 required.)
}
}
include( qwtconfig.pri )
The version 5 here probably refers to Qt 5.15.3 used by Kubuntu 22.04?
qmake --version
returns
QMake version 3.1
Using Qt version 5.15.3 in /usr/lib/x86_64-linux-gnu
I noticed that there is also qmake6, which returns:
qmake6 --version
QMake version 3.1
Using Qt version 6.2.4 in /usr/lib/x86_64-linux-gnu
So I tried:
make clean
/usr/bin/qmake6 qwt.pro
make
sudo make install
but the problem persists.
What do you see when you run this?
Does it show dependencies on any of the Qt6 libraries?
How about opening the qwt.pro file in QtCreator and ensuring that you are building using a Qt6 kit?
I am afraid I am not really a linux developer, so this is getting to the limits of my knowledge and experience.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
I see:
QQt Code:
ldd: ./libqwt.so: No such file or directoryTo copy to clipboard, switch view to plain text mode
I then created a link:
but it made no difference. But output likeQt Code:
ln -s /usr/local/qwt-6.2.0/lib/libqwt.so.6.2.0 libqwt.soTo copy to clipboard, switch view to plain text mode
indicated that the lib is found. It also indicates that qwt v. 6.2.0 is used, as well as Qt6, so it appears that there isn't a version mismatch. Also, I can build the qwt examples with Qt Creator, so libqwt.so seems to be OK.Qt Code:
/usr/bin/ld: /usr/local/qwt-6.2.0/lib/libqwt.so: undefined reference to `QtPrivate::QMetaTypeInterfaceWrapper<QVariant>::metaType@Qt_6'To copy to clipboard, switch view to plain text mode
Well. sorry, but I am at the end of my ideas. I think qmake creates a Makefile, right? (I use Visual Studio on Windows for all my development, which does not use Makefiles). Maybe take a look at one of those for your qwt examples and see if there is something in the linking that is missing from your CMakelists file. Otherwise, I don't know what else to suggest.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Yes, cmake creates a makefile, but I don't find any clues there. There is a file called CMakeCache.txt, which includes:
which is the correct path. Anyway, don't spend more time on this problem. I will keep scratching my head though. One thing I haven't thought about before: does qmake use hard-coded paths?Qt Code:
Name Value QWT /usr/local/qwt-6.2.0/lib/libqwt.soTo copy to clipboard, switch view to plain text mode
Bookmarks