I have installed the 2.2.1 version of the liblogicalaccess library on Kubuntu 18.04 with CMake 3.17.1 and Conan 1.25.0. I tried to follow the C++ howto of the liblogicalaccess library and on the second line of code, when running the program it gives the following error:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
./run.sh: line 9: 6781 Aborted (core dumped) bin/./github_console
main.cpp
// my first program in C++
#include <iostream>
#include <logicalaccess/dynlibrary/librarymanager.hpp>
#include <logicalaccess/readerproviders/readerconfiguration.hpp>
#include <logicalaccess/cards/chip.hpp>
int main()
{
std::cout << "Hello World!\n";
// Reader configuration object to store reader provider and reader unit selection.
std::shared_ptr<logicalaccess::ReaderConfiguration> readerConfig(new logicalaccess::ReaderConfiguration());
// Set PCSC ReaderProvider by calling the Library Manager which will load the function from the corresponding plug-in
readerConfig->setReaderProvider(logicalaccess::LibraryManager::getInstance()->getReaderProvider("PCSC"));
}
The first line of code starting with std::shared_ptr.. just runs fine, so might this be faulty code within the library or could this be a version/compatility fault. The second line calling the getReaderProvider somehow causes the error. I have no idea where to look for the fix of this error. Came from this problem originally. That was fixed but still stuck at the same code. I did some random troubelshooting but no luck. Any advice?
EDIT: My CmakeLists.txt is: project(test)
cmake_minimum_required(VERSION 3.16)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
set(CMAKE_CXX_FLAGS "-I /usr/include/PCSC")
add_executable(test main.cpp)
target_link_libraries(test PUBLIC CONAN_PKG::LogicalAccess)
conanfile.txt:
[requires]
LogicalAccess/2.2.1
[generators]
cmake
[imports]
lib, * -> lib
And to build i just run cmake --build .
in the project_folder/build.