xeus-cling icon indicating copy to clipboard operation
xeus-cling copied to clipboard

make && make install error while using cpp-argparse 3.0

Open anutosh491 opened this issue 1 year ago • 5 comments

(xeus-cling) anutosh491@spbhat68:~/QuantStack/xeus-cling/build$ make && make install
[  9%] Building CXX object CMakeFiles/xeus-cling.dir/src/xinterpreter.cpp.o
[ 18%] Building CXX object CMakeFiles/xeus-cling.dir/src/xoptions.cpp.o
[ 27%] Building CXX object CMakeFiles/xeus-cling.dir/src/xmagics/executable.cpp.o
/home/anutosh491/QuantStack/xeus-cling/src/xmagics/executable.cpp: In member function 'xcpp::argparser xcpp::executable::get_options()':
/home/anutosh491/QuantStack/xeus-cling/src/xmagics/executable.cpp:70:16: error: use of deleted function 'xcpp::argparser::argparser(const xcpp::argparser&)'
   70 |         return argpars;
      |                ^~~~~~~
In file included from /home/anutosh491/QuantStack/xeus-cling/src/xmagics/executable.cpp:37:
/home/anutosh491/QuantStack/xeus-cling/include/xeus-cling/xoptions.hpp:21:12: note: 'xcpp::argparser::argparser(const xcpp::argparser&)' is implicitly deleted because the default definition would be ill-formed:
   21 |     struct argparser : public argparse::ArgumentParser
      |            ^~~~~~~~~
/home/anutosh491/QuantStack/xeus-cling/include/xeus-cling/xoptions.hpp:21:12: error: use of deleted function 'argparse::ArgumentParser::ArgumentParser(const argparse::ArgumentParser&)'
In file included from /home/anutosh491/QuantStack/xeus-cling/include/xeus-cling/xoptions.hpp:15,
                 from /home/anutosh491/QuantStack/xeus-cling/src/xmagics/executable.cpp:37:
/home/anutosh491/conda_root/envs/xeus-cling/include/argparse/argparse.hpp:1477:3: note: declared here
 1477 |   ArgumentParser(const ArgumentParser &other) = delete;
      |   ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xeus-cling.dir/build.make:146: CMakeFiles/xeus-cling.dir/src/xmagics/executable.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:166: CMakeFiles/xeus-cling.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I think the readme can specify the version to be below 3.0 (currently it says that the version can be somewhere around 2.9)

anutosh491 avatar Nov 10 '23 11:11 anutosh491

on gentoo linux i have a problem compiling with cpp-argparse v2.9 or v3.0

this is with 3.0:

/home/ufk/src/xeus-cling/src/xmagics/executable.cpp: In member function 'xcpp::argparser xcpp::executable::get_options()':
/home/ufk/src/xeus-cling/src/xmagics/executable.cpp:70:16: error: use of deleted function 'xcpp::argparser::argparser(const xcpp::argparser&)'
   70 |         return argpars;
      |                ^~~~~~~
In file included from /home/ufk/src/xeus-cling/src/xmagics/executable.cpp:37:
/home/ufk/src/xeus-cling/include/xeus-cling/xoptions.hpp:21:12: note: 'xcpp::argparser::argparser(const xcpp::argparser&)' is implicitly deleted because the default definition would be ill-formed:
   21 |     struct argparser : public argparse::ArgumentParser
      |            ^~~~~~~~~
/home/ufk/src/xeus-cling/include/xeus-cling/xoptions.hpp:21:12: error: use of deleted function 'argparse::ArgumentParser::ArgumentParser(const argparse::ArgumentParser&)'
In file included from /home/ufk/src/xeus-cling/include/xeus-cling/xoptions.hpp:15,
                 from /home/ufk/src/xeus-cling/src/xmagics/executable.cpp:37:
/home/ufk/miniforge3/envs/xeus-cling/include/argparse/argparse.hpp:1477:3: note: declared here
 1477 |   ArgumentParser(const ArgumentParser &other) = delete;
      |   ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xeus-cling.dir/build.make:146: CMakeFiles/xeus-cling.dir/src/xmagics/executable.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:166: CMakeFiles/xeus-cling.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

and v2.9:

/home/ufk/src/xeus-cling/src/xmagics/executable.cpp: In member function ‘xcpp::argparser xcpp::executable::get_options()’:
/home/ufk/src/xeus-cling/src/xmagics/executable.cpp:70:16: error: use of deleted function ‘xcpp::argparser::argparser(xcpp::argparser&&)’
   70 |         return argpars;
      |                ^~~~~~~
In file included from /home/ufk/src/xeus-cling/src/xmagics/executable.cpp:37:
/home/ufk/src/xeus-cling/include/xeus-cling/xoptions.hpp:21:12: note: ‘xcpp::argparser::argparser(xcpp::argparser&&)’ is implicitly deleted because the default definition would be ill-formed:
   21 |     struct argparser : public argparse::ArgumentParser
      |            ^~~~~~~~~
/home/ufk/src/xeus-cling/include/xeus-cling/xoptions.hpp:21:12: error: use of deleted function ‘argparse::ArgumentParser::ArgumentParser(argparse::ArgumentParser&&)’
In file included from /home/ufk/src/xeus-cling/include/xeus-cling/xoptions.hpp:15:
/home/ufk/miniforge3/envs/xeus-cling/include/argparse/argparse.hpp:1479:3: note: declared here
 1479 |   ArgumentParser(ArgumentParser &&) noexcept = delete;
      |   ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xeus-cling.dir/build.make:146: CMakeFiles/xeus-cling.dir/src/xmagics/executable.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:166: CMakeFiles/xeus-cling.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

kfirufk avatar Dec 04 '23 09:12 kfirufk

me too in Arch Linux https://aur.archlinux.org/packages/xeus-cling#comment-947511

carlosal1015 avatar Dec 19 '23 15:12 carlosal1015

Thank you for forwarding this @carlosal1015. I have now learned a little more about C++ and am trying to solve this problem. The && symbol in the error messages is essentially referring to the moving of objects in C++. The README of argparse mentions that copying and moving are forbidden (see also https://github.com/p-ranav/argparse/issues/260). My first instinct is now to wrap argparser in a unique_ptr so it can be returned without copying.

(In the event that this solution cause undefined behavior [e.g. maybe due to things being freed when going out of scope], one could add another layer of indirection by using callbacks in order to keep things on the stack for a longer period of time. I made a sketch of this kind of solution as well but hopefully it won't be necessary to use it.)

JoelSjogren avatar Jan 06 '24 20:01 JoelSjogren

For any arch linux user wishing to build and install xeus-cling with my changes:

  • git clone https://aur.archlinux.org/xeus-cling.git
  • makepkg inside the downloaded folder (it will give the error discussed above)
  • copy over the new contents of src/xmagics from my branch
  • makepkg --noextract -si

JoelSjogren avatar Jan 06 '24 22:01 JoelSjogren

Many thanks @JoelSjogren. ~I will push soon~. Pushed,

carlosal1015 avatar Jan 06 '24 22:01 carlosal1015

@anutosh491 I am also facing the same build error. Did you figure out how to solve this? There's a PR #512 too but not being merged yet. I am using Ubuntu 22.04.4.

(xeus-cling) ukiyo@ukiyo-Nitro-AN515-44:~/xeus-cling/build$ cmake && make install
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

[  9%] Building CXX object CMakeFiles/xeus-cling.dir/src/xmagics/executable.cpp.o
/home/ukiyo/xeus-cling/src/xmagics/executable.cpp: In member function 'xcpp::argparser xcpp::executable::get_options()':
/home/ukiyo/xeus-cling/src/xmagics/executable.cpp:70:16: error: use of deleted function 'xcpp::argparser::argparser(const xcpp::argparser&)'
   70 |         return argpars;
      |                ^~~~~~~
In file included from /home/ukiyo/xeus-cling/src/xmagics/executable.cpp:37:
/home/ukiyo/xeus-cling/include/xeus-cling/xoptions.hpp:21:12: note: 'xcpp::argparser::argparser(const xcpp::argparser&)' is implicitly deleted because the default definition would be ill-formed:
   21 |     struct argparser : public argparse::ArgumentParser
      |            ^~~~~~~~~
/home/ukiyo/xeus-cling/include/xeus-cling/xoptions.hpp:21:12: error: use of deleted function 'argparse::ArgumentParser::ArgumentParser(const argparse::ArgumentParser&)'
In file included from /home/ukiyo/xeus-cling/include/xeus-cling/xoptions.hpp:15,
                 from /home/ukiyo/xeus-cling/src/xmagics/executable.cpp:37:
/home/ukiyo/miniforge3/envs/xeus-cling/include/argparse/argparse.hpp:1477:3: note: declared here
 1477 |   ArgumentParser(const ArgumentParser &other) = delete;
      |   ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xeus-cling.dir/build.make:146: CMakeFiles/xeus-cling.dir/src/xmagics/executable.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:166: CMakeFiles/xeus-cling.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

b1shtream avatar Mar 25 '24 05:03 b1shtream

Hey @JoelSjogren @chococandy63 @carlosal1015

I believe #522 should be the correct fix for this. Y'all can have a look

anutosh491 avatar Apr 16 '24 06:04 anutosh491

Looks fine to me if it works. I don't know exactly what the versioning constraints are for but your approach with references is technically simpler than my unique_ptr approach.

JoelSjogren avatar Apr 16 '24 07:04 JoelSjogren

Exactly. It's a simpler approach and supports compatibility with cpp-argparse 3.xx

anutosh491 avatar Apr 16 '24 07:04 anutosh491

Hey @JoelSjogren @chococandy63 @carlosal1015

I believe #522 should be the correct fix for this. Y'all can have a look

Thanks, I replaced old PR with this one in AUR package.

carlosal1015 avatar Apr 16 '24 22:04 carlosal1015

Hi @JoelSjogren @chococandy63 looks like that this patch is not working for argparse 3.0-2.

https://aur.archlinux.org/packages/xeus-cling#comment-968030

carlosal1015 avatar Apr 18 '24 11:04 carlosal1015

I'm facing the same error, with cling 0.9 , argparse 3.0 and nlohmann-json 3.11.2

Hi @JoelSjogren @chococandy63 looks like that this patch is not working for argparse 3.0-2.

https://aur.archlinux.org/packages/xeus-cling#comment-968030

But this ticket is closed. Should a new one be opened? @carlosal1015 Which fix has been used in Arch?

papoteur-mga avatar Jul 17 '24 18:07 papoteur-mga