mhogomchungu/sirikali

Attempts to compile C++ with "clang" instead of "clang++"

Closed this issue · 2 comments

MacOS Monterey 12.4, Xcode-13.4.

Error:

$ make V=1
/opt/local/bin/cmake -S/Users/ur20980/src/sirikali -B/Users/ur20980/src/sirikali/build --check-build-system CMakeFiles/Makefile.cmake 0
/opt/local/bin/cmake -E cmake_progress_start /Users/ur20980/src/sirikali/build/CMakeFiles /Users/ur20980/src/sirikali/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/Users/ur20980/src/sirikali/build'
make  -f src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/build.make src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/depend
make[2]: Entering directory '/Users/ur20980/src/sirikali/build'
cd /Users/ur20980/src/sirikali/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /Users/ur20980/src/sirikali /Users/ur20980/src/sirikali/src/3rdParty/lxqt_wallet/backend /Users/ur20980/src/sirikali/build /Users/ur20980/src/sirikali/build/src/3rdParty/lxqt_wallet/backend /Users/ur20980/src/sirikali/build/src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/Users/ur20980/src/sirikali/build'
make  -f src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/build.make src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/build
make[2]: Entering directory '/Users/ur20980/src/sirikali/build'
[  0%] Building C object src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o
cd /Users/ur20980/src/sirikali/build/src/3rdParty/lxqt_wallet/backend && /opt/local/bin/clang -D_DEFAULT_SOURCE -I/Users/ur20980/src/sirikali/build -I/Users/ur20980/src/sirikali/src/3rdParty/tasks -I/Users/ur20980/src/sirikali/src/3rdParty/lxqt_wallet/frontend -I/Users/ur20980/src/sirikali/build/src/3rdParty/lxqt_wallet/frontend -O3 -std=gnu18 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk   -std=c++14 -fstack-protector-all --param ssp-buffer-size=4 -I/opt/local/include -Wextra -Wall -pedantic -Wno-unused-result -Wall -s -fPIC -pedantic -MD -MT src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o -MF CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o.d -o CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o -c /Users/ur20980/src/sirikali/src/3rdParty/lxqt_wallet/backend/lxqtwallet.c
clang: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
error: invalid argument '-std=c++14' not allowed with 'C'
make[2]: *** [src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/build.make:79: src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o] Error 1
make[2]: Leaving directory '/Users/ur20980/src/sirikali/build'
make[1]: *** [CMakeFiles/Makefile2:289: src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/all] Error 2
make[1]: Leaving directory '/Users/ur20980/src/sirikali/build'
make: *** [Makefile:139: all] Error 2

CMake output:

$ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/local -DMACPORTS=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/local/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/local/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting C++ version to C++14
-- Found PkgConfig: /opt/local/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'pwquality'
--   Found pwquality, version 1.4.0
-- found gcrypt header file at: /opt/local/include/gcrypt.h
-- found gcrypt library at: /opt/local/lib/libgcrypt.dylib
-- adding library search path of: /opt/local/lib
-- Found Qt5Widgets, version  5.15.3
-- Found Qt5Core, version  5.15.3
-- Found Qt5Network, version  5.15.3
-- Checking for module 'mhogomchungu_network'
--   No package 'mhogomchungu_network' found
-- ---------------------------------------------------------------------------
-- network support is disabled
-- ---------------------------------------------------------------------------
-- ---------------------------------------------------------------------------
-- mhogomchungu_task library will be provided by an internal library
-- ---------------------------------------------------------------------------
-- Checking for module 'lxqt-wallet'
--   No package 'lxqt-wallet' found
-- ERROR: could not find lxqt_wallet package
-- ---------------------------------------------------------------------------
-- lxqt wallet support will be provided by an internal library
-- ---------------------------------------------------------------------------
-- Found gcrypt header file: /opt/local/include/gcrypt.h
-- Found gcrypt library: /opt/local/lib/libgcrypt.dylib
-- Checking for modules 'KF5Wallet'
-- 
--------------------------------------------------------------------------
-- kwallet support NOT found, support will be discovered at runtime through dbus
-- -----------------------------------------------------------------------
-- 
--------------------------------------------------------------------------
-- libsecret support NOT found,will not build libsecret functionality
-- -----------------------------------------------------------------------
-- ---------------------------------------------------------------------------
-- Building GUI components using Qt5
-- ---------------------------------------------------------------------------


-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    MACPORTS


-- Build files have been written to: /Users/ur20980/src/sirikali/build

Subsequent build:

$ make V=1
/opt/local/bin/cmake -S/Users/ur20980/src/sirikali -B/Users/ur20980/src/sirikali/build --check-build-system CMakeFiles/Makefile.cmake 0
/opt/local/bin/cmake -E cmake_progress_start /Users/ur20980/src/sirikali/build/CMakeFiles /Users/ur20980/src/sirikali/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/Users/ur20980/src/sirikali/build'
make  -f src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/build.make src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/depend
make[2]: Entering directory '/Users/ur20980/src/sirikali/build'
cd /Users/ur20980/src/sirikali/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /Users/ur20980/src/sirikali /Users/ur20980/src/sirikali/src/3rdParty/lxqt_wallet/backend /Users/ur20980/src/sirikali/build /Users/ur20980/src/sirikali/build/src/3rdParty/lxqt_wallet/backend /Users/ur20980/src/sirikali/build/src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/Users/ur20980/src/sirikali/build'
make  -f src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/build.make src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/build
make[2]: Entering directory '/Users/ur20980/src/sirikali/build'
[  0%] Building C object src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o
cd /Users/ur20980/src/sirikali/build/src/3rdParty/lxqt_wallet/backend && /opt/local/bin/clang -D_DEFAULT_SOURCE -I/Users/ur20980/src/sirikali/build -I/Users/ur20980/src/sirikali/src/3rdParty/tasks -I/Users/ur20980/src/sirikali/src/3rdParty/lxqt_wallet/frontend -I/Users/ur20980/src/sirikali/build/src/3rdParty/lxqt_wallet/frontend -O3 -std=gnu18 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk   -std=c++14 -fstack-protector-all --param ssp-buffer-size=4 -I/opt/local/include -Wextra -Wall -pedantic -Wno-unused-result -Wall -s -fPIC -pedantic -MD -MT src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o -MF CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o.d -o CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o -c /Users/ur20980/src/sirikali/src/3rdParty/lxqt_wallet/backend/lxqtwallet.c
clang: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
error: invalid argument '-std=c++14' not allowed with 'C'
make[2]: *** [src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/build.make:79: src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o] Error 1
make[2]: Leaving directory '/Users/ur20980/src/sirikali/build'
make[1]: *** [CMakeFiles/Makefile2:289: src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/all] Error 2
make[1]: Leaving directory '/Users/ur20980/src/sirikali/build'
make: *** [Makefile:139: all] Error 2

Relevant env vars:

$ env | grep clan
CCC=clang++
CLANGFORMAT=/opt/local/bin/clang-format-mp-14
CXX=clang++
CC=clang
$  type clang++
clang++ is /opt/local/bin/clang++
$ clang++ -v
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ cmake --version
cmake version 3.22.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Try now and see if it works.

The problem was caused by passing a C++ compiler option to a C compiler.

GCC works but it produces a warning

[  108s] [  0%] Building C object src/3rdParty/lxqt_wallet/backend/CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o
[  108s] cd /usr/src/packages/BUILD/obj-i586-linux-gnu/src/3rdParty/lxqt_wallet/backend && /usr/bin/cc  -D_DEFAULT_SOURCE -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2  -O3 -DNDEBUG -I/usr/src/packages/BUILD/obj-i586-linux-gnu -I/usr/src/packages/BUILD/src/3rdParty/tasks -I/usr/src/packages/BUILD/src/3rdParty/lxqt_wallet/frontend -I/usr/src/packages/BUILD/obj-i586-linux-gnu/src/3rdParty/lxqt_wallet/frontend    -Wextra -Wall -pedantic -std=c++14 -fstack-protector-all --param ssp-buffer-size=4 -I/usr/include -Wextra -Wall -pedantic -Wno-unused-result -Wall -s -fPIC -pedantic -o CMakeFiles/lxqtwallet-backend.dir/lxqtwallet.c.o   -c /usr/src/packages/BUILD/src/3rdParty/lxqt_wallet/backend/lxqtwallet.c
[  108s] cc1: warning: command line option '-std=c++1y' is valid for C++/ObjC++ but not for C
[  108s] Linking C static library liblxqtwallet-backend.a

The problem was caused by passing a C++ compiler option to a C compiler.

Indeed. Hopefully it's fixed once and for all.

GCC works but it produces a warning

I'm not sure every GCC version would work.

Try now and see if it works.

Thank you! It compiles and works correctly now.