win7 vscode mingw c++ 报错 file format not recognized treating as linker script

问题:file format not recognized; treating as linker script
原因:是自己写了其他的头文件和cpp,然后在test.cpp中包含调用,发现自己写的其他的cpp也生成了exe,所以直接把这个cpp里函数的实现都加到了头文件中,删掉这个cpp,后重启vscode可以正常调用了。

问题:C:\Users\ADMINI~1\AppData\Local\Temp\cco2hL7X.o:UDPClient.cpp:(.text+0x6f4): undefined reference to `__imp_WSACleanup’

原因:
实现socket通信时会用到下面这一句代码

#pragma comment(lib,"ws2_32.lib")

这要求我们在task.json中添加-lws2_3,在settings.json 中也要添加上。
task.json 中添加的位置为:

"windows": {
                "command": "g++",
                "args": [

                    "\"${file}\"",
                    "--std=c++11",
                    "-lwsock32",
                    "-lws2_32",
                    "-lglut32",//使用glut
                    "-lglu32",
                    "-lopengl32",
                    "-o",
                    "${fileBasenameNoExtension}.exe"
settings.json中添加的位置为:

“code-runner.executorMap”: {
“c”: “cd KaTeX parse error: Expected 'EOF', got '&' at position 5: dir &̲& gcc 'fileName’ -o ‘KaTeX parse error: Expected 'EOF', got '&' at position 109: …ec-charset=GBK &̲& &'dir$fileNameWithoutExt’”,
“cpp”: “cd KaTeX parse error: Expected 'EOF', got '&' at position 5: dir &̲& g++ 'fileName’ -o ‘KaTeX parse error: Expected 'EOF', got '&' at position 130: …ec-charset=GBK &̲& &'dir$fileNameWithoutExt’”


你可能感兴趣的:(Bugs)