Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    如何调试自编求解器cpp文件的代码?

    OpenFOAM
    3
    17
    7188
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Dongdong last edited by

      用的Ubuntu+vscode平台,我想设置断点一行一行代码运行,可是为什么运行第一行就会出现“fatal error:fvCFD.H没有那个文件或目录”?

      1 Reply Last reply Reply Quote
      • D
        Dongdong last edited by

        求大神解答,在线等!!

        1 Reply Last reply Reply Quote
        • 队长别开枪
          队长别开枪 教授 last edited by 李东岳

          OpenFOAM自带wmake编译工具,具体可以参考
          http://card.weibo.com/article/h5/s#cid=230418bc7c914f0102v04p&vid=0&extparam=&from=1110006030&wm=0&ip=129.107.80.206

          D 1 Reply Last reply Reply Quote
          • D
            Dongdong @队长别开枪 last edited by

            @队长别开枪 我已经编译过了,还是不能一行行调试

            队长别开枪 1 Reply Last reply Reply Quote
            • 队长别开枪
              队长别开枪 教授 @Dongdong last edited by

              @dongdong 不知道怎么用wmake进行断点调试啊,我一般都是使用Info << << endl;看输出的值是否异常。

              D 1 Reply Last reply Reply Quote
              • D
                Dongdong @队长别开枪 last edited by

                @队长别开枪 你的意思是在代码里面加"Info << << endl;",再运行求解器比如icoFoam?

                队长别开枪 1 Reply Last reply Reply Quote
                • 队长别开枪
                  队长别开枪 教授 @Dongdong last edited by

                  @dongdong 对的,Info << #你想输出的变量# << endl;,也可能有更高级的工具,坐等坛子里的大神来回答:happy:

                  1 Reply Last reply Reply Quote
                  • W
                    wwzhao 教授 last edited by

                    编译debug版本,设置断点,用gdb调试。

                    D 1 Reply Last reply Reply Quote
                    • D
                      Dongdong @wwzhao last edited by

                      @wwzhao 怎么编译debug版本?

                      W 1 Reply Last reply Reply Quote
                      • W
                        wwzhao 教授 @Dongdong last edited by

                        @dongdong http://openfoamwiki.net/index.php/HowTo_debugging#FULLDEBUG_-_libraries

                        D 1 Reply Last reply Reply Quote
                        • D
                          Dongdong @wwzhao last edited by

                          @wwzhao “Find out from the printed stack trace which files contain the functions that crash. Copy these into your local directory.”他这个需要把所有的头文件或代码加到我的工作目录中,太多了啊,OF的头文件一环套一环的,有没有更好的方法?

                          W 1 Reply Last reply Reply Quote
                          • W
                            wwzhao 教授 @Dongdong last edited by

                            @dongdong 建议编译一个完整的debug版本,export WM_COMPILE_OPTION=Debug 设置环境变量然后编译。

                            D 1 Reply Last reply Reply Quote
                            • D
                              Dongdong @wwzhao last edited by

                              @wwzhao 已经在重新编译中...麻烦一下能不能举个例子,你是怎么一步步调试自编求解器的代码(头文件和库不在工作目录,经常找不到头文件)?

                              W 1 Reply Last reply Reply Quote
                              • W
                                wwzhao 教授 @Dongdong last edited by

                                @dongdong 要调试还是编译?听你说的好像编译还没通过?

                                D 1 Reply Last reply Reply Quote
                                • D
                                  Dongdong @wwzhao last edited by

                                  @wwzhao 编译通过了,以icoFoam举例子,我复制到user下(自编求解器所在工作目录),编译成功后,应该怎么调试呢?(vscode一直提示“找不到头文件”,这些头文件包括fvCFD,setRootCase之类的,因为像fvCFD头文件也包括了大量其它头文件,我不可能把所有这些头文件都放到工作目录)

                                  W 1 Reply Last reply Reply Quote
                                  • W
                                    wwzhao 教授 @Dongdong last edited by

                                    @dongdong 用gdb,具体用法可以查gdb的使用手册,参考 http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2008/debugging.pdf

                                    D 1 Reply Last reply Reply Quote
                                    • D
                                      Dongdong @wwzhao last edited by

                                      @wwzhao 谢谢BZ!我试试~

                                      1 Reply Last reply Reply Quote
                                      • First post
                                        Last post

                                      CFD中文网 | 东岳流体 | 京ICP备15017992号-2
                                      论坛登录问题反馈可联系 li.dy@dyfluid.com