keygen-sh / example-cpp-cryptographic-license-files

Example of verifying cryptographically signed and encrypted license files using C++, OpenSSL, Ed25519 and AES-256-GCM.
https://keygen.sh
MIT License
9 stars 8 forks source link

fixes build bug with g++ and struct declarations #1

Closed dizcza closed 1 year ago

dizcza commented 1 year ago

Fixes

  1. g++ build command g++: error: unrecognized command-line option ‘-stdlib=libc++’
  2. struct keywords were missing resulting in
    main.cpp:146:11: error: declaration of ‘product license::product’ changes meaning of ‘product’ [-fpermissive]
    146 |   product product;
      |           ^~~~~~~
    main.cpp:111:8: note: ‘product’ declared here as ‘struct product’
    111 | struct product
      |        ^~~~~~~
    main.cpp:147:10: error: declaration of ‘policy license::policy’ changes meaning of ‘policy’ [-fpermissive]
    147 |   policy policy;
      |          ^~~~~~
    main.cpp:118:8: note: ‘policy’ declared here as ‘struct policy’
    118 | struct policy
      |        ^~~~~~
    main.cpp:148:8: error: declaration of ‘user license::user’ changes meaning of ‘user’ [-fpermissive]
    148 |   user user;
      |        ^~~~
    main.cpp:125:8: note: ‘user’ declared here as ‘struct user’
    125 | struct user

With these two fixes, the example works fine.

dizcza commented 1 year ago

@ezekg

ezekg commented 1 year ago

I'm not seeing these warnings on Darwin. What version of the G++ compiler and OS are you using?

dizcza commented 1 year ago

Ubuntu 22.04

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.3.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-xKiWfi/gcc-11-11.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-xKiWfi/gcc-11-11.3.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) 
dizcza commented 1 year ago

How to build this example in Windows? Thanks.

ezekg commented 1 year ago

No idea. I don't have a Windows machine and have never written C++ on Windows.

Contributions are welcome for a Windows build section in the README.