undefined reference error when using QT 5.15.2 with cmake
tedcriss opened this issue · 0 comments
tedcriss commented
Hello,
There is a problem when I compile QZXing with QT 5.15.2 + cmake, as pic bellow shows.
How can I fix it?
This is the CMake file in root dir.
cmake_minimum_required(VERSION 3.5)
project(FileTrans VERSION 0.1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets Multimedia MultimediaWidgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Multimedia MultimediaWidgets REQUIRED)
include_directories(${Qt5MultimediaWidgets_INCLUDE_DIRS})
include_directories(QZXing)
set(PROJECT_SOURCES
main.cpp
widget.cpp
widget.h
widget.ui
QrCode.cpp
QrSegment.cpp
BitBuffer.cpp
BitBuffer.h
QrCode.h
QrSegment.h
QtCameraCapture.h
QtCameraCapture.cpp
)
add_subdirectory(QZXing)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(FileTrans
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET FileTrans APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(FileTrans SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(FileTrans
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(FileTrans PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia Qt${QT_VERSION_MAJOR}::MultimediaWidgets QZXing)
set_target_properties(FileTrans PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(FileTrans)
endif()