Log4cxx Casting FileInputStreamPtr To InputStreamPtr
09:56 01 Dec 2025

I am attempting to cast a log4cxx::FileInputStreamPtr to InputStreamPtr. On Windows using the Visual Studio 2019 compiler, this works without issue. My current implementation is:

log4cxx::helpers::Properties properties;
log4cxx::helpers::InputStreamPtr inputStream = std::make_shared(resourceDirectory.string());

properties.load(inputStream);

However, on Linux with GCC 8.5, the compiler throws the following error:

error: conversion from ‘std::shared_ptrlog4cxx::helpers::InputStream’ to non-scalar type ‘log4cxx::helpers::InputStreamPtr’ {aka ‘log4cxx::helpers::ObjectPtrTlog4cxx::helpers::InputStream’} requested log4cxx::helpers::InputStreamPtr inputStream = std::static_pointer_castlog4cxx::helpers::InputStream(fileInputStream);

I then tried the following approach:

std::shared_ptr fileInputStream = std::make_shared(resourceDirectory.string());
log4cxx::helpers::InputStreamPtr inputStream = std::static_pointer_cast(fileInputStream);

Again, this compiles fine with Visual Studio 2019, but GCC produces a similar error:

error: conversion from ‘std::shared_ptrlog4cxx::helpers::InputStream’ to non-scalar type ‘log4cxx::helpers::InputStreamPtr’ {aka ‘log4cxx::helpers::ObjectPtrTlog4cxx::helpers::InputStream’} requested

Do you have any suggestions to resolve this issue? I understand the compiler version is quite old, but upgrading is not an option—I need to work with GCC 8.5.

c++ linux gcc log4cxx