Author Archives: Robins

Go executable file error: sh:/ xxx: not found [How to Solve]

background

An error is reported when an executable file packaged by a project is executed in the alpine container

Solution:

It is judged that the lack of dependent environment leads to the unrecognization of this executable file. Install glibc to solve the problem

You can also directly change the from image to busybox: glibc

cat Dockerfile 
FROM alpine:3.14
COPY xxx /tmp/
ARG TZ="Asia/Shanghai"
ENV TZ ${TZ}
RUN  mkdir -p /opt/xxx && mv /tmp/xxx /tmp/ysera_mgtv.conf  /opt/xxx && \
     chmod 777 /opt/xxx/xxx && \
     sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories  && \
     apk add tzdata && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime  && \
     wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
     wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk && \
     apk add glibc-2.29-r0.apk

USER root
CMD ["/opt/xxx/xxx"]

How to Solve Android wireless debug Error

1. Commands for ADB related wireless debugging:

adb tcpip < PORT>

connects Android devices wirelessly through TCPIP. Port is the port number, which can be specified at will (e.g. ADB TCPIP 6666)).

ADB connect
ADB: Usage: ADB connect host [: Port]

after entering ADB connect enter on the command line, the system prompts the usage of the command:
where host is the IP address of the Android device, port is the port number specified when using the ADB TCPIP command, and: connection is used between them (e.g. ADB connect 192.168.1.188:6666).

2. Commands to supplement ADB display/designated devices

ADB devices

View current device

adb -s < device>

it is used to operate the specified equipment we want

3. Specific operation of wireless connection

1. Connect Android device with USB data cable;

2. Enter ADB TCPIP command on the command line (for example: ADB TCPIP 9999);

3. Disconnect the USB data cable (the data cable is disconnected from the device);

4. On the command line, enter ADB connect & lt; host> [:<port>] Command (for example: ADB connect 192.168.1.188:9999)

4. Problems encountered

Open the terminal command window (or terminal in as) and enter the following command:

ADB TCPIP 6666
error: more than one device/emulator

an error is reported here: “error: more than one device/emulator”
then use the following command to view the device

adb devices
List of devices attached
D1CGAP1234506666 device
192.16. 31.55:5555 device

find the device d1cgap1234506666, which is the serial number of the Android mobile phone I need to conduct wireless debugging. 172.16 can be found in its mobile phone status information 31.39 is the IP address of Android phone (the location of checking the IP address of each phone may be different).

Continue using the following command:

adb -s D1CGAP1234506666 tcpip 6666
adb -s D1CGAP1234506666 connect 172.16. 31.39:6666
connected to 172.16. 31.39:6666

connected to host [: Port] indicates that the infinite connection is successful.

[Solved] UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa6 in position 9737: ill

Django2. 2 after installation, use runserver for development. When an error occurs, the error message is only displayed on the console command line, and only one line is displayed on the front page

“A server error occurred. Please contact the administrator.”
troubleshooting is very inconvenient. Check the error information on the console carefully and give a prompt

Unicode decodeerror: ‘GBK’ codec can’t decode byte 0xa6 in position 9737: ill…
it is judged that this version of Django cannot be displayed normally due to the code reading problem of the error message code
follow the prompts to find the python installation path\lib\site_packages\Django\views\debug.Py, after it is opened, the modification is about 332 lines, which will:

    with Path(CURRENT_DIR, 'templates', 'technical_500.html').open() as fh:

Change to

    with Path(CURRENT_DIR, 'templates', 'technical_500.html').open(encoding='utf-8') as fh:

That is, set the encoding, and then restart runserver. The error information can be displayed on the page normally.

[Solved] Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 2 or 3

This plug-in is installed in GVIM

Error: jedi-vim failed to initialize Python: Jedi-vim requires Vim with support for Python 2 or 3 · Issue #1018 · davidhalter/jedi-vim (github.com)

But when you open a python file, you will be prompted with a bunch of red words, mainly because Python is not supported

There is a reply in the author:

You can enter whether Python print (‘sb ‘) or: Python 3 print (‘sb’) can run in VIM, but not input: version

Check the version of GVIM. Download the 64-bit version GVIM

The version of GVIM is now 64 bit

Check whether Python is 64-bit or not in CMD

After keeping the versions of GVIM and python 64-bit, it still doesn’t work on the command line. Opening a py file is a pile of red prompts

So add such a line of code to _vimrc to specify the path of python3

Then on the command line, type: Python 3 print (‘sb ‘)

Output normal

Reopen a py file and enter After that, I found that the prompts were normal, and there were no previous prompts

After tossing me for a day, I am irritable, by the way, I have to install a plug-in>pip install jedi

[Solved] idea Run gui Error: Error:Abnormal build process termination:

Error reported by idea running program:

Error:Abnormal build process termination: 
"C:\Program Files\Java\jdk1.8.0_181\bin\java" -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=\"\" -Djdt.compiler.useSingleThread=true -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djava.net.preferIPv4Stack=true -Dio.netty.initialSeedUniquifier=3130135518625661539 -Dfile.encoding=GBK -Djps.file.types.component.name=CommunityFileTypes -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IdeaIC2017.1 "-Didea.home.path=D:\intellij\IntelliJ IDEA Community Edition 2017.1.3" -Didea.config.path=C:\Users\Administrator\.IdeaIC2017.1\config -Didea.plugins.path=C:\Users\Administrator\.IdeaIC2017.1\config\plugins -Djps.log.dir=C:/Users/Administrator/.IdeaIC2017.1/system/log/build-log "-Djps.fallback.jdk.home=D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/jre64" -Djps.fallback.jdk.version=1.8.0_112-release -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/Administrator/.IdeaIC2017.1/system/compile-server/xmpos_version_1cf37ff8/_temp_ -Djps.backward.ref.index.builder=true -Dkotlin.incremental.compilation.experimental=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"C:\Users\Administrator\AppData\Local\Temp\kotlin-idea-1543655368645972493-is-running\" -classpath "D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_121/lib/tools.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/optimizedFileManager.jar" org.jetbrains.jps.cmdline.Launcher "D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/util.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/snappy-in-java-0.5.1.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/forms_rt.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/openapi.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-builders-6.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/protobuf-2.5.0.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/idea_rt.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jdom.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/resources_en.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/log4j.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/annotations.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/asm-all.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jna-platform.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/nanoxml-2.2.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/oromatcher.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jgoodies-forms.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/trove4j.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-builders.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/netty-all-4.1.9.Final.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-model.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/javac2.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jna.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/commons-io-2.2.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/commons-lang-2.6.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-base-services-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-base-services-groovy-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-cli-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-core-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-logging-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-messaging-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-model-core-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-model-groovy-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-native-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-process-services-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-resources-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-tooling-api-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-tooling-extension-api.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-tooling-extension-impl.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-version-info-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-wrapper-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/guava-jdk5-17.0.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/jansi-1.14.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/kryo-2.22.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/minlog-1.2.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-freebsd-amd64-libcpp-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-freebsd-amd64-libstdcpp-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-freebsd-i386-libcpp-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-freebsd-i386-libstdcpp-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-amd64-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-amd64-ncurses5-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-amd64-ncurses6-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-i386-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-i386-ncurses5-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-i386-ncurses6-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-osx-amd64-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-osx-i386-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-windows-amd64-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-windows-i386-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/objenesis-1.2.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/reflectasm-1.07.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/resources_en.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/gson-2.5.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/jarutils.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/ant/lib/ant-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/IntelliLang/lib/intellilang-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Groovy/lib/groovy-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Groovy/lib/groovy-rt-constants.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/eclipse/lib/eclipse-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/eclipse/lib/common-eclipse-util.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/jps/android-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/jps/android-gradle-jps.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/android-common.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/android-rt.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/sdk-common.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/repository.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/sdklib.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/common.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/jarutils.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/layoutlib-api.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/manifest-merger.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-runtime.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-reflect.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-android-extensions-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-android-extensions-compiler-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/javaFX/lib/javaFX-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/javaFX/lib/common-javaFX-plugin.jar" org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 49368 17dc4cd1-443b-4591-a8f4-08f506e32d55 C:/Users/Administrator/.IdeaIC2017.1/system/compile-server
Build process started. Classpath: D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_121/lib/tools.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/optimizedFileManager.jarError connecting to 127.0.0.1:49368; reason: Connection refused: no further information: /127.0.0.1:49368io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /127.0.0.1:49368    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)    at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:352)    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:612)  at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559)    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection refused: no further information
    ... 15 more
Exiting.
---------------------

Delete unused jdks:

Open the control panel, select the program or function, find the unused Java JDK and uninstall it.

[Solved] JAVA Beginners’ Error: Exception in thread “main“ java.io.FileNotFoundException

0x00 overview

During the practice in the Java IO flow chapter, an error was found when running the code, saying that the file path is incorrect.

0x01 solution

Error code

package FileDemo2;

import java.io.File;
import java.io.IOException;

public class FileDemo2 {
    public static void main(String[] args) throws IOException {
        // Requirement 1:Create a file java.txt in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f1 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\FileDemo2\\java.txt");
        System.out.println(f1.createNewFile());
        System.out.println("--------------");


        // Requirement 2:Create a directory in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f2 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\FileDemo2\\JavaSE\\");
        System.out.println(f2.mkdir());
        System.out.println("--------------");

        // Requirement 3:Create a multi-level directory in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory \JavaSE\JavaEE\
        File f3 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\FileDemo2\\JavaSE\\JavaEE\\");
        System.out.println(f3.mkdirs());
        System.out.println("--------------");

        // Requirement 4:Create a file javaSE.txt in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f4 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\FileDemo2\\javaSE.txt");
        System.out.println(f4.createNewFile());
        System.out.println("--------------");
    }
}

For the revised code, add \src

package FileDemo2;

import java.io.File;
import java.io.IOException;

public class FileDemo2 {
    public static void main(String[] args) throws IOException {
        // Requirement 1:Create a file java.txt in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f1 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\src\\FileDemo2\\java.txt");
        System.out.println(f1.createNewFile());
        System.out.println("--------------");


        // Requirement 2:Create a directory in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f2 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\src\\FileDemo2\\JavaSE\\");
        System.out.println(f2.mkdir());
        System.out.println("--------------");

        // Requirement 3:Create a multi-level directory in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory \JavaSE\JavaEE\
        File f3 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\src\\FileDemo2\\JavaSE\\JavaEE\\");
        System.out.println(f3.mkdirs());
        System.out.println("--------------");

        // Requirement 4:Create a file javaSE.txt in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f4 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\src\\FileDemo2\\javaSE.txt");
        System.out.println(f4.createNewFile());
        System.out.println("--------------");
    }
}

The absolute path of the file needs to be obtained in the IDE. Here, copy-absoulte path is used to find that there is more \\src in the file path

[Solved] VS winsock.h and ws2def.h a large number of redefined error

Error reporting reason:

We know that Windows network programming requires at least two header files: winsock2.h and windows.h, and there is an old version of winsock.h before WinSock2.0. It is the order in which these three header files are included that causes the above problems.

The content of winsock2.h has the following macro definitions at the beginning of the file:

#ifndef _WINSOCK2API_
#define _WINSOCK2API_
#define _WINSOCKAPI_   /* Prevent inclusion of winsock.h in windows.h */

......
...
......

/*
 * Pull in WINDOWS.H if necessary
 */
#ifndef _INC_WINDOWS
#include <windows.h>
#endif /* _INC_WINDOWS */

This is the most common protection measure to prevent repeated inclusion of header files.
The definition of _WINSOCKAPI_ prevents the inclusion of the old file winsock.h, that
is, if the user includes winsock2.h first, then it is not allowed to include winsock.h. The
second half of the effect is: if the user does not include windows.h ( _INC_WINDOWS (defined in windows.h) automatically includes it to define the types and constants required by WinSock2.0.

Now switch to windows.h, we will find the following: (Note: here is the difference between windows.h in MS’s Platform SDK and the file that comes with VC)

#ifndef _MAC
#include <winperf.h>
#include <winsock.h>
#endif

In fact, it is easy to understand that files contain each other, and the definition order leads to the inclusion of Winsock before Winsock 2, which will lead to a large number of repeated definition errors.

Solution:

Find the code that contains windows.h and Winsock2.h, let Winsock2 be included before windows
(or write a header file to solve this problem)

In StdAfx.h add:

#include <WinSock2.h>
#include <windows.h>

It can be solved.

If it is found that the solution does not contain these two files, it is possible that the content is used in the development package or other files.

[Solved] interceptor Cross-Domain Access-Control-Allow-Origin Error

I use vue3 + spring boot, which is developed by front-end and back-end separation technology. For cross-domain problems, I add the following code:

@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedHeaders(CorsConfiguration.ALL)
                .allowedMethods(CorsConfiguration.ALL)
                .allowCredentials(true)
                .maxAge(3600); // No further pre-testing required within 1 hour (send OPTIONS request)
    }

}

The above code is useless, and then it is used in the interceptor to add the following code:

String origin = request.getHeader("Origin");
response.setHeader("Access-Control-Allow-Origin", origin);

Add to solve the problem.