Category Archives: Error

Error lnk2038: detected “_ ITERATOR_ DEBUG_ Mismatched ‘level’ value of ‘0’

Problem description: the C++ program developed by Visual Studio 2010, after adding the h and CPP files of the third-party library, reported the following error when compiling and running:
Error LNK2038: “_ITERATOR_DEBUG_LEVEL” mismatches detected: value “0” mismatches value “2”Problem analysis: _ITERATOR_DEBUG_LEVEL is the system variable that records the compilation mode, 0 means that the current project is the Debug version, 2 means that the current project is the Release version.

Possible reasons 1:

Error 25 error LNK2038: Mismatch detected for "_ITERATOR_DEBUG_LEVEL": value "0" does not match value "2”

This problem is caused because the current project is the Debug version, but the library file referenced is the Release version.

“_ITERATOR_DEBUG_LEVEL” mismatch: value "2" does not match value "0"   

If the above problem is detected, then Release mode refers to Debug’s library file. This type of problem requires careful version matching when referring to files
Solution: Fix the lib file name in the attachment dependency. In Debug mode, you just use the file name of the Debug DLL, and in Release mode, you just use the Release DLL. (Debug mode DLL files usually have d, in, at the end of the file name)

Possible cause 2: Incorrect project property Settings, solution — “properties” — “C/C++–” Code generation — “runtime properties.
This property should be set to “multi-threaded debugging DLL (/MDd)” in Debug mode and” multi-threaded DLL (/MD) “in release mode. The above problem can also occur if the Settings are reversed.
Ending method: Just modify the runtime properties according to the schema.

Possible reason 3: If neither of the above reasons is true, the _ITERATOR_DEBUG_LEVEL variable may have been artificially assigned in the code.
For example, the basicexcel.cpp file contains the following statements:

#ifdef _DEBUG
#define _ITERATOR_DEBUG_LEVEL 0	// speedup iterator operations while debugging
#endif

The same problem may occur if _ITERATOR_DEBUG_LEVEL is set to 0 in Debug mode in order to speed up the program running in Debug mode, so that _ITERATOR_DEBUG_LEVEL values do not match in Debug mode.

Solution: Changing _ITERATOR_DEBUG_LEVEL to an appropriate value in the program can solve the problem.

How to Solve Error: “initializer element is not constant”

1. First, solve the problem of error reporting as shown in the title;

Take a look at the following code:

#include <stdio.h>  
int a = 1;  
int b = 2;  
int c = a+b;  
  
int main() {  
    printf("c is %d\n", c);  
    return 0;  
}  

Error during compilation of GCC-O test test.c: Initializer Element is not Constant

Reason: the value of the global variable C cannot be determined at compile time; it must be determined at run time. Why is that?Because this is the standard:
C language standard: Initializers of external variables and static variables must be constant expressions [1].
So the solution:

#include <stdio.h>  
int a = 1;  
int b = 2;  
int c; 
  
int main() {  
    c = a + b; 
    printf("c is %d\n", c);  
    return 0;  
}

———-
Similarly, the following code does not compile, and the error message is the same as above: [4]

char * p1 = (char *) malloc(10);  
int main(void)
{
。。。   
}

2. Do GCC and g++ compile according to the suffix name of the file?

If you change the source file name *.c to *.cc, and then compile with g++, no error will be reported. Even if you just change the file name to *.cc, the compiler will also compile with GCC, which can also compile the past. What is the reason?

————–
Principle:
GCC started out as GNU C Compiler, which is, as you know, a C Compiler. But later, as the project integrated more compilers in different languages, GCC stood for the GNU Compiler Collection, thus representing a Collection of compilers.
So instead of calling GCC when you compile your code, it’s more like a driver that calls the c compiler or the c++ compiler (g++) based on the suffix of your code. For example, if your code suffix is *.c, it will call the C compiler and linker to link to C’s library. If your code suffix is CPP, it will call the g++ compiler, and of course the library call will also use the c++ version (however, the GCC command does not automatically link to the library used by c++ programs, you must follow the parameter gcc-lstdc ++)

—————–
Here’s a piece of code:

#include <iostream>

using namespace std;

int a = 1;
int b = a;

int main()
{
cout << b << endl;

}

The Initializer Element is not constant because GCC identifies the code as C, and C specifies that initializing global variables must be a constant expression.
If $GCC test.cc, undefined reference to ‘STD ::cout’… Wait… Error: ld returned 1 exit status. Although GCC recognized c++ code at this time, it would not automatically link c++ code base, so ld link error appeared. At this point only need to manually specify and C ++ library link C: $GCC test.cc-LSTDC ++, at this point you can smoothly through the compilation link.

———————
G++ is the c++ compiler for GCC. At compile time, g++ calls GCC, so for c++ code, the two are equivalent. But since the GCC command does not automatically associate with the library used by c++ programs, it is common to use g++ for linking, so for the sake of uniformity, compile/link all use g++, giving the illusion that c++ programs can only use g++.
So you can understand it this way: you can compile with GCC /g++, and you can link with either g++ or gcc-lstdc ++. Because GCC commands do not automatically join with libraries used by C++ programs, g++ is usually used to complete the join. But at compile time, g++ automatically calls GCC, which is equivalent.
For the above code, just $g++ test.c will compile because g++ identifies *.c files as c++ files [2].

The compiler is through the program suffix name to determine the language is C or C ++. Specifically, if the suffix is.c, GCC treats it like a c program, and g++ treats it like a c++ program; CPP suffix, both are considered as c++ programs, note that although c++ is a superset of c, but the syntax requirements of the two are different [2], for c language and c++ language suffix name problem, see [7]
(3) for 1 is the C language standard, not C++, for C++, global variables and static variables do not have to follow the initialization must be constant expression such requirements, so, if the compiler to identify the above code into C++ code, then it can be successfully compiled in the past. (And the program USES the same libraries as the C language, so it’s ok not to add -LSTDC ++ parameter.

Therefore, since the suffix name of the file is changed to *.cc, I guess that whether GCC or g++, this file is identified as c++ file, so it is clear that since it is identified as c++ file, of course not to report an error.

3, compiler strong and weak symbols

In C, global variables default to 0 if they are not initialized, that is, in the global space:
int x =0; With the int x; The effect looks the same. The difference is very big, but here it is strongly recommended that you all global variables
to initialization, the main difference between them is as follows:

the compiler when compiling for both conditions can produce two kind of symbols in the symbol table of the target file, for initialization, called
symbol, an uninitialized, called weak symbols.

if the connector encounters two duplicate symbols while connecting to the target file, it will have the following processing rule:
if there are strong symbols with multiple duplicate names, it will report an error.
if there is a strong symbol and more than one weak symbol, the strong symbol shall prevail.
if there is no strong symbol, but there are more than one weak symbol with the same name, then choose any weak symbol.

————-
So here’s a piece of code:

#include<stdio.h>
int i;
i =1;
int main()
{
printf("%d\n", i);
}

GCC test. C
Can be compiled, but with warning: Data Definition has no type or Storage class
What does that mean?I =1, the definition of an I variable has no type;
So the code looks like this:

#include<stdio.h>
#include<stdlib.h>
 
int i;
j=1;
 
int main()
{
printf( "%d\n", j);
printf( "%d\n", i);
system( "pause" );
return 0;
}

gcc test.c
This code also has warning; data definition has no type or storage class
So for I =1; The compiler takes it as the definition + initialization of a variable.
and the int I before; Because I is equal to 1; So int I is weak, it doesn’t work; [3]

However, the above two pieces of code, if using g++ compiler, that is, according to the rules of c++ compiler, will be directly error:
“J does not name a type” because c++ is a mandatory language, can not be so casual!
It is worth noting that the first paragraph of the above two code also reports an error in g++ : “I does not name a type”. It is understandable that j compilation should not pass, because j is not defined at all. Int I = 1; int I = 1; Int j = 2; int c = a+b; G++ is passable. What’s the problem?See section 4 of this article.

————–
Here’s another piece of code:

#include <stdio.h>
struct stu
{
   long number;
};

struct stu  student; 
student.number = 1;  

int main(int argc, char * argv[])
{
 printf("%d\n", student.number);
}

Why is that?
The assignment statement should be placed in the function body!
Initialization can be outside the body of the function… But the assignment must be inside the body of the function…
Moreover, not only are structures assigned, but most statements (other than declarations and definitions of functions and variables) do not allow…
So understand the difference between initialization and assignment;
(This applies to C and C ++)
**** It should also be noted that in C language, struct is required when defining structural variables, while in C ++, it is not required. Stu Student = {1}; You can, but with struct you can compile it, you can run it.

4. Why is it specified that the initial values of global and static variables must be constant expressions?
Now that we’ve solved the problem, and we’ve analyzed why we did it, we can go deeper. Why do global variables and static variables have to be initialized as constant expressions?
Global (static) storage: Divided into DATA segments and BSS segments. The DATA section (global initialization section) holds initialized global and static variables; The BSS section (global uninitialized area) holds uninitialized global and static variables as well as initialized to zero global and static variables (see here). Automatic release at the end of the program. The BBS section is automatically cleared by the system before the program execution, so uninitialized global variables and static variables are already 0 before the program execution. – The program is released by the system after completion. [5]
——-
A comparison, for the statement:

int i = 3
int main()
{
    int j = i;
    ...
}

Instead of determining the value of the local variable J at compile time, the value of I is read at run time to assign to J. The compiled connected executable does not contain the value of J, only the code for the corresponding assignment statement. In contrast, since I is a global variable and is stored in static storage, its value needs to be determined at compile time. Space will be allocated in the target file to store the value of I. There will be no assignment statement to assign the value of I at run time, and there is no corresponding code.

for the statement:

int i = 3;
int j = i;

Because J is a global variable and is stored in static storage, its value also needs to be determined at compile time. I is a variable, not a constant, and the value of I cannot be determined at compile time, which means that the value of J cannot be determined at compile time, so C will report an error.
Instead, C++ simply puts j as an uninitialized global variable in the.bss area at compile time, with the default value of 0, and then adds a statement to assign j at run time, ensuring that this statement is executed before the main function begins. So the initialization of j is actually done at run time. [6]

So, we can now answer the question raised in red in section 3:
1. For int I = 1; int j = 2; int c = a+b; This sentence, in g + + through because the statement is the c at compile time as a variable declaration, because the front of the variable c has keyword int, then the compiler will be additional add a statement c = a + b, and ensure that the statement before the main function, g + + this way to make this statement to the right by compiling.
2. For int I; I = 1; G++ does not compile. The reason is that an assignment statement like I = 1, which is different from an int c = a+b, requires a value at run time; I =1 cannot be regarded as a declaration of a variable (I variable has no type in front of it),,,,,,, etc

Tip: GCC compiler plus the -v parameter, displays compile-time details, compiler version, compilation process, etc.

Error occurred during initialization of VM Could not reserve enough space for 1572864KB object heap

Error during initialization of VM Could not reserve enough space for 1572864KB object heap
The error occurred when the virtual machine initialization
could not have stored enough space for 1572864 KB Object heap

Java virtual machine (JVM) allocated more memory than the system had available, so there was not enough space allocated to the JVM to create objects
Solutions:
1. Modify gradle.properties file
to change -xmx1536m to -xmx512m, save, Rebuild

TIP:
-xmx is to set the memory size of the VM, if the program is very memory hungry, you need to set it with this parameter. 
-Xmx512m is the maximum amount of heap memory the JVM is allowed to allocate, on demand.
-cp is the classpath, the path to load classes

2, in the personal folder (C:/Users/username /. Gradle or ~ /. Gradle)) create gradle. The properties file, add

org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m

Tidb2.1 reports Error statement count 5001 exceeded the transaction limit, autocommit = false

Error:
statement count 5001 exceeds the transaction limitation, autocommit = false


-- Explanation.
stmt-count-limit
Limit on the maximum number of statements allowed in a TiDB transaction.
Default: 5000
TiDB will return statement count 5001 exceeds the transaction limitation if there is no rollback or commit after more than stmt-count-limit statements in a transaction, autocommit = false error.

-- Solution.
conf/tidb.yml
Modify the file parameters.

 txn_local_latches:
  # Enable local latches for transactions. Enable it when
  # there are lots of conflicts between transactions.
  # enabled: true
  # capacity: 1024000

Method 1: Comment out the parameter enabled: true and set it to false
Method 2: Set the parameter capacity: 1024000 to very

Restart tidb after the parameters are modified.

error: could not install *smartsocket* listener: Address already in use PM8:49 ADB server didn’t AC…

Enter adb command in the terminal and the error is as follows:
localhost:work zhangyg$ adb devices
List of devices attached
adb server version (32) doesn’t match this client (36); killing…
error: could not install *smartsocket* listener: Address already in use
ADB server didn’t ACK
* failed to start daemon *
error: cannot connect to daemon

The reason for the error was that I chose Android Tools using Genymotion, so it caused a conflict with ADB program under Android SDK.
Click [Settings] in the main interface of Genymotion as shown below:

Select Use Custom Android SDK Tools, and then select the Androd SDK root directory, as shown in the figure below:

Restarting Genymotion’s virtual machine will solve the problem.

Remember an android app startup error Error running: Default Activity not found

The errors are shown in the figure below:

Reason 1:
This is because it is possible that When we delete the activity during the operation, Android Studio automatically removes our activity tag information from the Androidmanifest.XML, but when we create the activity again, it does not automatically fill in our activity information, so we need to fill it out manually.
Reason 1 Solution:
Fill in the Activity tag information in the Androidmanifest.xml:

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

Reason 2:
Because of the requirement, projects do not need the Activity class. This is because When you create a project, AndroidStudio defaults to Lunche, which requires activity, so it will report an error.
Reason 2 solutions:
Step 1: Go to the Settings page

Step 2: Set it to Nothing in launch.

[Elasticsearch Exception]Found interface org.elasticsearch.common.bytes.BytesReference

24322; normal information

Found interface org.elasticsearch.common.bytes.BytesReference, but class was expected

picture of child problems.

https://stackoverflow.com/questions/61029889/error-at-createindex-elasticsearch-using-elasticsearchoperations-why-is-the-by

To solve the solution,

<elasticsearch.version> 7.6.2

<dependency>
         <groupId>org.elasticsearch.client</groupId>
         <artifactId>elasticsearch-rest-high-level-client</artifactId>
         <version>${elasticsearch.version}</version>
     </dependency>

[Solved] when using jupyter notebook, “terminated worker error” appears

Error:
When calling pandas_profiling.ProfileReport(df) using Jupyter Notebook, an error is reported “A worker process managed by the executor was unexpectedly terminated. This could be caused by a segmentation fault while calling the function or by an excessive memory usage causing the Operating System to kill the worker.”The solution is as follows.
    Terminal type pip list , view joblib-0.13.2 type pip uninstall joblib type pip install -U joblib

Restart the kernel, then execute the code again and it runs successfully!

ValueError: Negative dimension size caused by subtracting 2 from 1 for…

ValueError: Negative dimension size caused by subtracting 2 from 1 for ‘{{node max_pooling2d_1/MaxPool}} = MaxPoolT=DT_FLOAT, data_format=“NHWC”, explicit_paddings=[], ksize=[1, 2, 2, 1], padding=“VALID”, strides=[1, 2, 2, 1]’ with input shapes: [?,1,128,64].
channel Order problem
Add the code
from keras import backend as K
K.set_image_data_format(‘channel_first’)
Done!

How to Solve k8s Nodal issues: /sys/fs/cgroup/memory/docker: no space left on device\““: unknown.

When some nodes of k8s run for a period of time, an error is reported: sys/FS/CGroup/memory/docker: no space left on device \ “: unknown

The docker’s memory is full, probably because SELinux = is on

Permanent closure solution:

VI/etc/SELinux/config, change SELinux = enforcing to SELinux = disabled, then save and exit

Then restart the computer

The node can be used after re running

Of course, this is: basic entrance examination of intelligent gtalent operation engineer

If it is only used temporarily, then directly: setenforce 0

docker: Error response from daemon: OCI runtime create failed: container_ linux.go:345: starting container process caused “process_ linux.go:275: applying cgroup configuration for process caused \”mkdir /sys/fs/cgroup/memory/docker: no space left on device\””: unknown.
ERRO[0000] error waiting for container: context canceled