0

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.

R D
  • 13
  • 4
  • Try to build from sources `conan install --build` probably there is an incompatibility with your environment. – uilianries May 27 '20 at 16:49
  • Assuming you use GCC, ABI compatibility issue may cause such a crash when exceptions are thrown. Maybe worth it to double check you use a consistent version across the lib and the target ? Try forcing the `compiler.libcxx=libstdc++11` flag when you build... – Jean-Mathieu Vermosen May 27 '20 at 18:26
  • Which compiler (gcc?) and which compiler version? Any special flags that are you using in your build? If you could share the build script, that could be useful. Looks there is binary incompatibility between the existing package (I assume from ConanCenter?) and the app you are building using the package. – drodri May 27 '20 at 23:44
  • @uilianries I don't have an environment. I run and build just by console commands: cmake --build . and ./executable_name – R D May 28 '20 at 10:33
  • @RD environment I mean by your compiler version, glibc version, libcxx, ... there are many variables. Again, you should build your package from sources first. Please, take on Conan docs: https://docs.conan.io/en/latest/reference/commands/consumer/install.html?#build-options – uilianries May 28 '20 at 12:47

0 Answers0