Questions tagged [g++]
g++ is the C++ frontend to the GNU Compiler Collection (GCC). It's the de facto standard compiler for C, C++, Go, Fortran, and Ada on Linux and supports many other languages and platforms as well. Apart from the compiler, GCC has a toolchain (libc, libstdc++, objdump, nm etc.) that is widely used on several platforms and systems.
10,676
questions
2
votes
2
answers
87
views
`static_cast<const bool&>` with `explicit operator bool`
Consider the following:
struct C {
explicit operator bool() const {
return true;
}
};
int main() {
C c;
auto b = static_cast<const bool &>(c);
return 0;
}
...
-1
votes
0
answers
32
views
I'm struggling to compile anything with OpenCV using g++ [duplicate]
For some reason none of the commands I try are working.
Command: g++ file.cpp -o file -I C:\Users\Username\vcpkg\installed\x64-windows\include -L C:\Users\Username\vcpkg\installed\x64-windows\lib -...
2
votes
1
answer
96
views
In C++ std::ranges, how do I build a map out of a views::join result?
I'm using GCC 14 in C+23 mode. In the following code, I create a view of views of pairs, which I then flatten with views::join and put into a vector:
auto c = std::ranges::views::iota(1, 5)
| ...
-4
votes
2
answers
66
views
I was working on vs code in C++ and suddenly I got an error not showing any output in terminal [closed]
I was working on vs code in C++ and suddenly an error appeared that no output was shown in the terminal. I tried
Please help guys, because this error is hindering my work. I was working in oop on ...
1
vote
0
answers
84
views
when unique_ptr implements pimpl, assignment in a class declaration also results in: error: invalid application of 'sizeof' to incomplete type '***'
excuse me, when I was implementing pimpl with std::unique_ptr, I accidentally found that when I set pimpl to nullptr in the header file, gcc(version 9.4.0,14.1.0) cannot be compiled. But cl.exe (...
0
votes
0
answers
36
views
AIX: C++ application with shared Qt5Core lib dependency has thread-local-storage runtime issue
I am on IBM AIX-7.2 and have this sample C++ code:
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QDateTime>
#include <cstring>
int main(int argc,...
0
votes
0
answers
58
views
vs code wont run with multiple cpp files [duplicate]
hello i am a beginner and currently following learncpp 2.8 on how to use multiple code files which i was able to build and run manually but build and fail to run in vs code despite setting tasks.json ...
0
votes
0
answers
55
views
When writing my own lex/yacc, my code that was cpmpiled by g++ producted a weird bug
Could you please help me identify where the issue might be in my code, or is there possibly a problem with the compiler itself?"
I was writing my own lex/yacc by cpp. There is some codes for ...
-1
votes
0
answers
38
views
Undefined reference to `??3@YAXPEAX@Z' [duplicate]
I tried to Link my c++ programm with the Rockey library (Rockey is a company that produces usb hardware keys) but during compilation I get the following error [R4ND_Random]+0x12f): undefined reference ...
0
votes
1
answer
56
views
Valgrind complain after modifing reference return variable from a vector in c++
I am trying to modify an std::vector through the use of references, the vector lifetime is designed in such a way modifications through the reference always are valid, in other words the the reference'...
-1
votes
1
answer
70
views
clang++ and g++ Compiler gives different output when printing char pointer [duplicate]
clang++ and g++ Compiler gives different output when printing char pointer
#include <iostream>
int
main(int argc, char** argv){
char a = 'a';
char* aptr = &a;
std::cout << aptr &...
0
votes
0
answers
32
views
G++ cannot link to instantiated template static method in shared library [duplicate]
I have a simple code that's trying to link to a static method of a class template that's already instantiated in a shared library. This is the code:
#include <sym/rot3.h>
int main() {
sym::...
0
votes
0
answers
35
views
g++-9 uses newer GLIBCXX symbols when linking against libstdc++
I am facing issues with g++ linking against newer GLIBCXX symbols for std::condition_variable::wait (with g++-9/g++-10/g++-11, libstdc++.so.6.0.30):
When using std::condition_variable::wait, GLIBCXX_3....
-1
votes
1
answer
58
views
How to include opencv headers without using cmake?
I installed the opencv library by using apt:
sudo apt install libopencv-dev libopencv-contrib-dev
But how to involve the installed library into my own project without using cmake? I tried directly ...
1
vote
0
answers
39
views
How to get g++ to find .so files?
Seemingly as simple as can be: I want to link a shared object file and use a function from it. However, I can't even get this to work in the following simple use case:
In the directory /my_proj I have ...