jhorzek / lessSEM

lessSEM estimates sparse structural equation models.
https://jhorzek.github.io/lessSEM/
GNU General Public License v2.0
7 stars 1 forks source link

compiler error Gnu+11 vs C++14 #364

Closed brandmaier closed 9 months ago

brandmaier commented 10 months ago

I tried to compile the package but get an error, which probably is due to an incompatibility with C++ versions:

In file included from ../inst/include/lesstimate/include/lesstimate/ista_penalties.h:7,
                 from ../inst/include/lesstimate/include/lesstimate.h:6,
                 from ../inst/include/lessSEM.h:4,
                 from RcppExports.cpp:4:
../inst/include/lesstimate/include/lesstimate/ista_mixedPenalty.h: In function 'void lessSEM::initializeMixedProximalOperators(lessSEM::proximalOperatorMixedPenalty&, const std::vector<lessSEM::penaltyType>&)':
../inst/include/lesstimate/include/lesstimate/ista_mixedPenalty.h:448:68: error: 'make_unique' is not a member of 'std'
  448 |       std::unique_ptr<proximalOperatorMixedNone> currentPen = std::make_unique<proximalOperatorMixedNone>();
      |                                                                    ^~~~~~~~~~~
../inst/include/lesstimate/include/lesstimate/ista_mixedPenalty.h:448:68: note: 'std::make_unique' is only available from C++14 onwards

I tried to compile on a Windows machine with standard R 4.2 as shipped. It seems to provide/assume only the gnu++11 standard. Any easy fixes that come to your mind?

Thanks!

jhorzek commented 10 months ago

Hi Andreas,

Thanks for reporting the issue! I've switched to a new package structure a few months back, where the optimizer library (lesstimate) is now a separate project imported as a git submodule. The std::make_unique function is used in the newest version of lesstimate and requires C++14. Unfortunately, the install instructions in the readme were out of date, sorry for that! The following should work:

git clone --branch development --recurse-submodules https://github.com/jhorzek/lessSEM.git

Then install the package as usual. In the development branch C++14 is specified as C++ standard. If you want to use the main branch

git clone --recurse-submodules https://github.com/jhorzek/lessSEM.git

should work without C++14. This should download an older version of lesstimate. Please let me know if that fixes the issues!

Best, Jannik

brandmaier commented 9 months ago

Hi Jannik,

thanks! This worked beautifully.

Best, Andreas