Tag Archives: c++

[Solved] OpenCV error: #error “This header with legacy C API declarations has been removed from OpenCV.

Error reporting details

Error reporting reason

In the opencv version you are currently using, the definition declaration related to legacy C API has been removed, and the content of legacy can still be from legacy/constants_c.H from the header file.

Therefore, the solution is also obvious. Open the error file directly, delete the original part of the error header file, and replace it with legacy/constants_c.H.

Solution:

Open the cpp file with error
find the error header file location:

Delete the code of the header file containing the error and replace it with:

#include "opencv2/imgcodecs/legacy/constants_c.h"

Compiled successfully ~

if your problem is also solved, leave a praise~

[Solved] C++: fatal error: Killed signal terminated program cc1plus

[problem solving] C + +: fatal error: killed signal terminated program cc1plus

1. Problem description

During C + + compilation in Linux system, the following errors occur, resulting in compilation abort:

C++: fatal error: Killed signal terminated program cc1plus
compilation terminated.

2. Solution – swap partition

After consulting the relevant information, it is considered that the virtual machine is caused by insufficient memory. This problem is solved by creating swap partition, and the compilation is successful
the following is a summary of the creation and activation of swap partitions:

# Create the partition path
sudo mkdir -p /var/cache/swap/
# Set the size of the partition
# bs=64M is the block size, count=64 is the number of blocks, so the swap space size is bs*count=4096MB=4GB
sudo dd if=/dev/zero of=/var/cache/swap/swap0 bs=64M count=64
# Set permissions for this directory
sudo chmod 0600 /var/cache/swap/swap0
# Create the SWAP file
sudo mkswap /var/cache/swap/swap0
# Activate the SWAP file
sudo swapon /var/cache/swap/swap0
# Check if SWAP information is correct
sudo swapon -s

The effect diagram of partition creation and activation is as follows:

The path of the swap 0 file is under/var/cache/swap/. After compilation, if you don’t want to swap partitions, you can delete it.

Command to delete swap partition:

sudo swapoff /var/cache/swap/swap0
sudo rm /var/cache/swap/swap0

Free space command:

sudo swapoff -a
#Detailed usage: swapoff --help
#View current memory usage: --swapoff: free -m

Dev C++ Error: error: ld returned 1 exit status [How to Solve]

There are several reasons for this error: error: ld returned 1 exit status

 

Solution (Four Methods to Solve, Not All):

1.undefined reference to `__gxx_personality_v0

Or compile with g++

To compile with gcc, add -lstdc++ to the edit option linker command

2. Close the program connected to the running dev

3. Definition error

4. Compile other settings issues

C++ Error: Invoking “make -j2 -l2“ failed [How to Solve]

Note that this prompt is not the problem, that is, the error is not invoking “make – J2 – L2”, it just indicates that you use dual threaded computing, just like the dual core of a computer. Similarly, “- J4 – L4” and “- J8 – L8” will appear. As shown in the figure above, the problem is that I missed a semicolon when writing C + + code;

Error Ninja reported during dpdk20.11.1 installation and compilation

Execute CD build & amp& amp; Ninja error reporting

Cause analysis: dpdk relies on a higher version of Libpcap. The version of Libpcap carried in Python 3 is lower, so an error will be reported

terms of settlement

1、cd/home/haohan/software/PF_ Ring-6.6.0/userland/libpcap; Execute make install compilation

2. Execute ldconfig

3. Re execute CD build & amp& amp; ninja

 

Scanf_S always reports errors [How to Solve]

First let me make complaints about it.

scanf_s. You really wasted a lot of my time

At first I was going to use scanf_S when inputting floating-point data and character data, the system always reports an error, that is, there is no error in the generation solution, but debugging is not good, eh, it is not good.

That’s it. I didn’t know at first. I thought it was a floating point problem. As a result, I haven’t worked it out for a long time,

Later, by chance, I found that it was actually the problem of character data. When I was using scanf_s, the length of character data should be specified, otherwise an error will be reported, but scanf is not used. In other words, the eighth line should be changed in this way

scanf_s("%f%c%f", &a, &op,1, &b);

The specified character length is one.

I’ll check the information and update it.

error: expected ‘;‘ at end of member declaration and expected ‘)‘ before ‘&‘ toke Errors

error: expected ‘;’ at end of member declaration
error: expected ‘)’ before ‘&’ Token
error reporting

When developing c + + in Linux environment, the following compilation errors or other inexplicable errors occur while ensuring that there are no errors in the code

	error: expected ';' at end of member declaration
	error: expected ‘)’ before ‘&’ toke

Solution:
check whether the header file contains circularly. For example, a.cpp contains B.H, b.cpp contains C.H, and c.cpp contains A.H to form a ring. In this case, an error will be reported.

[Solved] QT Programme Error: error: no matching function for call to…

The following error occurred in the binding mechanism between signal and slot function:

error: no matching function for call to 'Widget::connect(QPushButton*&, void (QAbstractButton::*)(bool), Widget*, <unresolved overloaded function type>)'

The reason for the error is that when making a response call, you do not know which function to call, indicating that function reuse occurs.

void classover();
void classover(QString food);

For the above two functions, you can mask one. Which one?

When signals correspond to slot functions, two characteristics need to be noted:
1. The parameter types of signals and slots must correspond one by one
2. The number of parameters of signals and slots can be different, but the number of signal parameters must be more than that of slot functions

To sum up, the nonparametric function is retained to achieve the correct result.

How to Solev QT compilation error “cannot find – LGL”

Cause: QT cannot find the dynamic link library of OpenGL. QT usually looks for dynamic link libraries in/usr/lib directory, but some Linux distributions will place OpenGL dynamic link libraries in other directories. For example, Ubuntu will be placed in/usr/lib/i386 Linux GNU/Mesa/. There are two solutions:

Method 1: directly copy the OpenGL dynamic link library file in/usr/lib/i386 Linux GNU/Mesa/directory to/usr/lib.

Note: the built-in OpenGL library in Linux will have the version number at the end, such as LIBGL.So.1, LIBGL.So.1.2. However, the file required by QT when linking does not have a version number, that is, libgl.so. Method 2: create a soft link for the OpenGL dynamic link library file in/usr/lib/i386 Linux GNU/Mesa/directory

ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so