How to fix undefined reference to QSerialPortInfo? - cmake

I have the following error:
*.cpp:*: undefined reference to `QSerialPortInfo::QSerialPortInfo()'
This question was already on this form, but I have a cmake build system.
I am using the following cmake code to enable:
find_package (Qt5 CONFIG REQUIRED Core Widgets Gui SerialPort)

add or edit
target_link_libraries(yourproj Qt5::Widgets Qt5::SerialPort)

Related

undefined reference to '__objc_class_name_...'

I am building an executable (GNUstep).
It depends on a libLibname.a static lib.
In the GNUmakefile of the executable I am linking libLibname.a like this:
executableToolName_LDFLAGS = /usr/GNUstep/Local/Library/Libraries/libLibname.a
It claims to link without errors:
Linking tool executableToolName ...
Problem: It seems to not find the symbols:
main.m:29: error: undefined reference to '._OBJC_REF_CLASS_SomeClassNameOfLibLibname'
..._LDFLAGSis only for libray targets.
For tool targets, linked libs must be listed in ADDITIONAL_OBJC_LIBS, prefixed with -l

Cannot use assimp library in Debug build configuration

I use library Assimp from imported target assimp::assimp in my project:
find_package(assimp REQUIRED 5)
target_link_libraries(${PROJECT_NAME} PUBLIC assimp::assimp)
During link stage of build of the project in Debug configuration I get an error:
src/renderer/CMakeFiles/renderer.dir/build.make:256: *** target pattern contains no '%'. Stop.
The cause of the error is that (on Archlinux) I have no /usr/lib/cmake/assimp-5.0/assimpTargets-debug.cmake and corresponding line in /usr/lib/cmake/assimp-5.0/assimpTargets.cmake. Property IMPORTED_CONFIGURATIONS of assimp::assimp target have only RELEASE value and there is no IMPORTED_LOCATION_DEBUG property, just IMPORTED_LOCATION_RELEASE.
To fix the problem it is needed to add:
set_target_properties(assimp::assimp PROPERTIES MAP_IMPORTED_CONFIG_DEBUG Release)
Right after find_package.

I'd like to know how to compile cutelyst test with cmake finding dependencies

I do not know CMake very well. I need for CMake to find the GrantLee library to compile MyApp Test in cutelyst Cutelyst Tutorial.
But when I try to compile, I got the error below.
I have this line in myapp.cpp:
#include <Cutelyst/Plugins/View/Grantlee/grantleeview.h>
That instance in my code.
auto view = new GrantleeView(this);
I got that error:
Target "MyApp" links to target "Cutelyst::View::Grantlee" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
This warning is for project developers. Use -Wno-dev to suppress it.
I have that file in my directory:
/usr/include/cutelyst2-qt5/Cutelyst/Plugins/View/Grantlee/grantleeview.h
How to add this to CMakeLists.txt, for cmake to find dependencies and compile?
Thanks in advance.

Unrecognized option "--enable-new-dtags" error during building c++ library

During building a c++ source code (configured with cmake gui) with mingw under MSYS gives following error while trying to "Linking C shared library":
Unrecognized option "--enable-new-dtags"
How can i solve this issue?
Likely --enable-new-dtags is supported only on ELF targets. For example there's a patch for Python3 distutils which sets this flag conditionally on the target platform: https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-python3/0260-MINGW-compiler-enable-new-dtags.patch . You should make sure that this flag isn't specified explicitly somewhere in your project.

Dynamic loading and symbols sharing

I'm trying to load a module library via dl in such way, that the module can access globals from the main application. How is that possible to do?
I get an error message from dlopen saying library/name.so: undefined symbol: .... The only flag used is: RTLD_NOW.
The module itself is build with libtool with -module -avoid-version.
The answer is: use -Wl,--export-dynamic when linking the main binary, so all symbols are automatically exported to the loaded libraries.
Same question, just asked differently: Receive "undefined symbol" error when loading library with dlopen