shenkonghui / issue

问题记录
0 stars 0 forks source link

vscode问题集合 #153

Open shenkonghui opened 2 years ago

shenkonghui commented 2 years ago

使用code-runner 直接运行main.cc文件报错

[Running] cd "/root/src/cmake-demo/1.demo-curr-dir/" && gcc main.c -o main && "/root/src/cmake-demo/1.demo-curr-dir/"main
/tmp/ccnmCTj1.o:在函数‘main’中:
main.c:(.text+0x21):对‘add’未定义的引用
collect2: error: ld returned 1 exit status

settings.json中修改编译的语句,将$fileName修改为*cc

    "code-runner.executorMap": {
        "cpp": "cd $dir && g++ *.cc -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
    }

该问题解决

但是无法识别头文件

buffer_pool_control.cc:1:10: fatal error: my_sys.h: 没有那个文件或目录
 #include <my_sys.h>
          ^~~~~~~~~~
compilation terminated.

c_cpp_properties.json文件中增加如下,无效

            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/include/**"
            ],

c_cpp_properties.json不支持code-runner 插件。 目前看下来如果想要运行需要在运行命令中增加-I参数指定头文件路径.

但是包含了头文件路径太多了,也无法采用**方式匹配子目录,放弃了...

    "code-runner.executorMap": {
        "cpp": "cd $dir && g++ *.cc -o $fileNameWithoutExt -I /root/src/mysql-server-mysql-5.7.35/include  -I /root/src/mysql-server-mysql-5.7.35/cmake-build-debug/build/include -I /root/src/mysql-server-mysql-5.7.35/libbinlogevents/export -I  /root/src/mysql-server-mysql-5.7.35/sql && $dir$fileNameWithoutExt "
    }