vscode编译头文件问题“undefined reference.....”

m66rk9t 2020-11-15 10:29:46
头文件和main程序文件放在同一文件夹了,预处理指令中没有波浪线和错误提示,但是运行时提示“undefined reference........”错误,有大佬帮帮我么
...全文
1240 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿麦 2020-11-19
  • 打赏
  • 举报
回复
许多年过去了,赵4老师还是如此的独领风骚
自信男孩 2020-11-16
  • 打赏
  • 举报
回复
靠猜是猜不出来或猜不全的。建议楼主贴全代码和对应的编译提示~
赵4老师 2020-11-16
  • 打赏
  • 举报
回复
这是链接错误。 需要在链接选项中添加依赖的库文件。
赵4老师 2020-11-16
  • 打赏
  • 举报
回复
上贴中红字应改为 “/link /LIBPATH:附加依赖库.lib所在目录", “/link 附加依赖库.lib" //zhao4zhong1添加(^_^)
赵4老师 2020-11-16
  • 打赏
  • 举报
回复
https://code.visualstudio.com/docs/cpp/config-msvc From the main menu, choose Terminal > Configure Default Build Task. In the dropdown, which will display a tasks dropdown listing various predefined build tasks for C++ compilers. Choose cl.exe build active file, which will build the file that is currently displayed (active) in the editor. Tasks C++ build dropdown This will create a tasks.json file in a .vscode folder and open it in the editor. Your new tasks.json file should look similar to the JSON below: { "version": "2.0.0", "tasks": [ { "type": "shell", "label": "cl.exe build active file", "command": "cl.exe", "args": [ "/Zi", "/EHsc", "/Fe:", "${fileDirname}\\${fileBasenameNoExtension}.exe", "${file}", “/link /LIBPATH:附加依赖库.lib所在目录", “/link /IMPLIB:附加依赖库.lib" //zhao4zhong1添加(^_^) ], "problemMatcher": ["$msCompile"], "group": { "kind": "build", "isDefault": true } } ] } The command setting specifies the program to run; in this case that is "cl.exe". The args array specifies the command-line arguments that will be passed to cl.exe. These arguments must be specified in the order expected by the compiler. This task tells the C++ compiler to take the active file (${file}), compile it, and create an executable file (/Fe: switch) in the current directory (${fileDirname}) with the same name as the active file but with the .exe extension (${fileBasenameNoExtension}.exe), resulting in helloworld.exe for our example.

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧