Code base not finding standard C++ library header - c++

I am compiling an example application from the SDK repository of a third party vendor. I receive an error that one of the C++ header's (algorithm) cannot be found:
if [ ! -d .deps/ ]; then mkdir -p .deps/; fi
/opt/llvm-3.8.0/bin/clang++ -M -isystem/opt/tbricks/sdk/include64 -I../../.. -I../../../.. -I./../../../.. -DLINUX -DLINUX64 -DTB_USE_RCU -DURCU_INLINE_SMALL_FUNCTIONS -DU_USING_ICU_NAMESPACE=0 -DNDEBUG -D_POSIX_PTHREAD_SEMANTICS -fPIC -D_GNU_SOURCE -DTB_USE_RCU -DTB_USE_RCU -D_GLIBCXX_USE_CXX11_ABI=0 -m64 --gcc-toolchain=/opt/gcc-5.2.0 -flto=full -std=gnu++14 -D_GLIBCXX_DEPRECATED= -pipe -fno-omit-frame-pointer -ffast-math -fno-finite-math-only -pthread -march=core2 -mtune=corei7 -g -O3 -Qunused-arguments -fnon-call-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wshadow -Wpointer-arith -Wno-self-assign -Wno-unused-function -Wno-gnu-empty-initializer -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-mismatched-tags -Wno-unused-local-typedef -Wno-parentheses-equality -Wno-unused-private-field -Wno-missing-field-initializers -Wno-missing-braces -Werror=return-type -Werror=overloaded-virtual -DSTRATEGY_BUILD_PROFILE=\"release\" ../../../../shared/Helpers.cpp > .deps/Helpers.o.d
../../../../shared/Helpers.cpp:14:10: fatal error: 'algorithm' file not found
#include <algorithm>
What sets the location path to search for C++ header files, such as algorithm? Is there anything I can grep for within makefiles?

Either install g++ alongside (you need libstdc++) or use LLVM libc++ and specify it with -stdlib=libc++

Related

compile simple github fails at ext submodule

i am trying to compile this git https://github.com/yapb/yapb locally
i am using ubuntu 64bit, and it says i must compile 32bit
i am using now
CC=clang CXX=clang meson build-clang
but get this error
FAILED: yapb.so.p/src_chatlib.cpp.o
clang -Iyapb.so.p -I. -I.. -fvisibility=hidden -flto
-fcolor-diagnostics -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall
-Winvalid-pch -Wnon-virtual-dtor -Wextra -Wpedantic -Werror -std=c++14
-fno-exceptions -O3 -DVERSION_GENERATED -fno-threadsafe-statics
-fno-exceptions -fno-rtti -m32 -pedantic -fdata-sections
-ffunction-sections -mtune=generic -fno-builtin -funroll-loops
-fomit-frame-pointer -fno-stack-protector -fvisibility=hidden
-fvisibility-inlines-hidden -msse2 -mfpmath=sse -fPIC
-isystem../ext/crlib -isystem../ext -isystem../inc -isystem..
-isystem. -MD -MQ yapb.so.p/src_chatlib.cpp.o -MF
yapb.so.p/src_chatlib.cpp.o.d -o yapb.so.p/src_chatlib.cpp.o -c
../src/chatlib.cpp
In file included from ../src/chatlib.cpp:8:
In file included from ../inc/yapb.h:10:
In file included from ../ext/hlsdk/extdll.h:28:
In file included from ../ext/crlib/crlib/string.h:17:
../ext/crlib/crlib/array.h:15:10: fatal error: 'initializer_list' file not found
#include <initializer_list>```
Double-check the pre-requisites mentioned in YaPB Building the Bot page.
Try and open a regular CMD (instead of Powershell), making sure it inherits all your previous setups (meaning its %PATH% does reference g++.exe, pip.exe, and so on.

How to associate source files with dynamic library

I need to debug Postgres foreign data wrapper mysql_fdw.so. In Clion i try to attach postgres process.
Debugger attached to process 8818
In source code of fdw i try to set break points, but it says no executable code associated with this line.
How can i associate source code? Or can i debug this in another way?
compile commands:
gcc -g3 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -g -ggdb -O0 -fno-omit-frame-pointer -I/usr/local/mysql/include -g3 -D _MYSQL_LIBNAME=\"libmysqlclient.dylib\" -I. -I./ -I/usr/local/pgsql/include/server -I/usr/local/pgsql/include/internal -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -c -o mysql_fdw.o mysql_fdw.c
gcc -g3 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -g -ggdb -O0 -fno-omit-frame-pointer -bundle -multiply_defined suppress -o mysql_fdw.so connection.o option.o deparse.o mysql_query.o mysql_fdw.o -L/usr/local/pgsql/lib -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -Wl,-dead_strip_dylibs -bundle_loader /usr/local/pgsql/bin/postgres

clang-tidy with precompiled headers and cmake does not work

I have a simple setup where CMake produces the following compile command:
cd /workspaces/cmake-general/tests/project/build/examples/hello-world && /usr/local/bin/cmake -E __run_co_compile
--iwyu=/usr/local/bin/include-what-you-use
--tidy="/usr/bin/clang-tidy;-extra-arg=-Wno-unknown-warning-option;-warnings-as-errors=*;--extra-arg-before=--driver-mode=g++"
--source=/workspaces/cmake-general/tests/project/build/examples/hello-world/CMakeFiles/example-hello-world.dir/cmake_pch.hxx.cxx --
/usr/bin/c++
-I/workspaces/cmake-general/tests/project/examples/hello-world/src
-I/workspaces/cmake-general/tests/project/build -O3 -DNDEBUG -stdlib=libc++
-fcolor-diagnostics -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion
-Wsign-conversion -Wnull-dereference -Wdouble-promotion
-Wformat=2 -Werror -std=c++20 -Winvalid-pch -fpch-instantiate-templates
-Xclang -emit-pch -Xclang -include
-Xclang /workspaces/cmake-general/tests/project/build/examples/hello-world/CMakeFiles/example-hello-world.dir/cmake_pch.hxx
-x c++-header -MD -MT examples/hello-world/CMakeFiles/example-hello-world.dir/cmake_pch.hxx.pch -MF
CMakeFiles/example-hello-world.dir/cmake_pch.hxx.pch.d -o CMakeFiles/example-hello-world.dir/cmake_pch.hxx.pch
-c /workspaces/cmake-general/tests/project/build/examples/hello-world/CMakeFiles/example-hello-world.dir/cmake_pch.hxx.cxx
which errors our with not finding
/workspaces/cmake-general/tests/project/build/examples/example-sanitizer/CMakeFiles/example-sanitizer-address.dir/cmake_pch.hxx:5:10: error: 'iostream' file not found [clang-diagnostic-error]
#include <iostream>
^
3 errors generated.
When I take --tidy="..." stuff out of the command. It fully compiles, (also if I dont specify PCHs in the CMakeLists.txt) it works.
I am not sure what the problem is exactly.
Do PCH and clang-tidy somehow not work? Why are the include directories somehow missing? I am using LLVM-12, clang-12 on Ubuntu.
Also adding -I/usr/lib/llvm-12/include/c++/v1 does not help.

x86_64-conda_cos6-linux-gnu-cc: error trying to exec 'cc1plus': execvp: No such file or directory

I am trying to install a python library but I am getting an error
building '_pyFlask' extension
/home/lisa/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/lisagoh/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/lisa/anaconda3/include -fPIC -DFLASKCOMMIT="33a2752" -DHEALPIX_DATA="/mnt/c/Users/lisa_/OneDrive/Documents/Healpix_3.70/data" -DUSEXCOMPLEX=0 -DUSEMAP2TGA=0 -I/home/lisa/anaconda3/include/python3.8 -I/mnt/c/Users/lisa_/OneDrive/Documents/Healpix_3.70/include/healpix_cxx -c src/pyFlask_wrap.cxx -o build/temp.linux-x86_64-3.8/src/pyFlask_wrap.o -fopenmp
x86_64-conda_cos6-linux-gnu-cc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command '/home/lisa/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc' failed with exit status 1
I've tried sudo apt-get g++, sudo apt-get upgrade,sudo apt-get update and they tell me I have the latest versions but it still doesn't work.
When I try g++ --print-prog-name=cc1plus I get /usr/lib/gcc/x86_64-linux-gnu/9/cc1plus but when I try to find the cc1plus file it does not exist. I'm using the Ubunto 20.04 on a Windows OS.
I'm new to Linux and any help will be greatly appreciated thank you!

What could cause clang to not find the unordered_map header?

I'm trying to compile a program I found on the web using Clang++. The Makefile generates this command:
clang++ -c -arch x86_64 -msse3 -std=c++11 -stdlib=libstdc++
-Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type
-Wno-non-virtual-dtor -Wno-exit-time-destructors -Wformat -Wmissing-braces
-Wparentheses -Wno-switch -Wunused-function -Wunused-label -Wno-unused-parameter
-Wunused-variable -Wunused-value -Wno-empty-body -Wuninitialized -Wunknown-pragmas
-Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion
-Wint-conversion -Wno-shorten-64-to-32 -Wenum-conversion -Wno-newline-eof
-Wno-c++11-extensions -Wno-logical-op-parentheses -Wno-trigraphs
-Wno-invalid-offsetof -Wno-sign-conversion -Wdeprecated-declarations
-fmessage-length=0 -fno-exceptions -fstrict-aliasing -fvisibility=hidden
-fvisibility-inlines-hidden -funsafe-math-optimizations -ftrapping-math -fno-rtti
-fpascal-strings -fasm-blocks -O3 -Iinclude/ src/main.cpp
But I get
src/main.cpp:23:10: fatal error: 'unordered_map' file not found
#include <unordered_map>
^
1 error generated.
If I compile a simple program that includes <unordered_map> running clang++ test.cpp, it compiles fine.
I'm on
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
I had the same issue when compiling glogg.
As the comments have pointed out. it was stdlib.
In the makefile after running qmake. Change this line from
CXXFLAGS = -g -Wextra -std=c++11 -DGLOGG_VERSION=\"`cat .tarball-version`\" -O2 -arch x86_64 -Wall -W $(DEFINES)
To this line below
CXXFLAGS = -g -Wextra -std=c++11 -stdlib=libc++ -DGLOGG_VERSION=\"`cat .tarball-version`\" -O2 -arch x86_64 -Wall -W $(DEFINES)
notice "-stdlib=libc++" was specified in the cxxflags. It's autospecified in the linker flags, I guess it also needs to be specified in for the C++ flags.
It says -Wno-c++11-extensions. What wrote that makefile?