编译成功,但没有控制台输出。

huangapple go评论70阅读模式
英文:

Compiled successfully, but no console output

问题

I'm trying to use LLVM on Windows.
I've installed llvm-mingw (https://github.com/mstorsjo/llvm-mingw/releases/tag/20220906), and it works like a charm.
Everything works well, but pthread and openmp.

Code compilation done with no errors, so I think there's no linking issue or something like that.
Notice that there's no compilation or linking error below, but no console output.

Where did I go wrong? Here's my C code and VSCode configuration (command-line arguments).

C Code:

#include <stdio.h>
#include <omp.h>

int main(void)
{
    #pragma omp parallel num_threads(4)
    {
        printf("%d\n", omp_get_thread_num());
    }

    return 0;
}

VSCode Configuration (Command-Line Arguments):

"args": [
    "-O0",
    "-Wall",
    "-Wextra",
    "-fcolor-diagnostics",
    "-fansi-escape-codes",
    "-g",
    "${file}",
    "-o",
    "${fileDirname}\\.exe\${fileBasenameNoExtension}.exe",
    "-lm",
    "-lpthread",
    "-fopenmp"
],

Reference Image

英文:

I'm trying to use LLVM on windows.
I've installed llvm-mingw(https://github.com/mstorsjo/llvm-mingw/releases/tag/20220906), and it works like a charm.
Everything works well, but pthread and openmp.

Code compilation done with no errors, so I think there's no linking issue or something like that.
Notice that there's no compilation or linking error below, but no console out.

 PS C:\Users\first\Developments\Temp&gt; clang -Wall -Wextra -fopenmp .\test.c
 PS C:\Users\first\Developments\Temp&gt; ./a.exe
 PS C:\Users\first\Developments\Temp&gt;

Where did I go wrong? Here's my c code and vscode configuration(cmd args).

#include &lt;stdio.h&gt;
#include &lt;omp.h&gt;

int main(void)
{
    #pragma omp parallel num_threads(4)
    {
        printf(&quot;%d\n&quot;, omp_get_thread_num());
    }

    return 0;
}
&quot;args&quot;: [
    &quot;-O0&quot;,
    &quot;-Wall&quot;,
    &quot;-Wextra&quot;,
    &quot;-fcolor-diagnostics&quot;,
    &quot;-fansi-escape-codes&quot;,
    &quot;-g&quot;,
    &quot;${file}&quot;,
    &quot;-o&quot;,
    &quot;${fileDirname}\\.exe\${fileBasenameNoExtension}.exe&quot;,
    &quot;-lm&quot;,
    &quot;-lpthread&quot;,
    &quot;-fopenmp&quot;
],

答案1

得分: 0

由于所谓的“人为错误”。除非涉及浮点小数,计算机从不撒谎。

问题在于我没有正确设置环境。
我没有在PATH中添加.dll文件的路径。

现在我已经修复了它们,它正常运行!

英文:

It was because of so called "Human Error". The computers never lies unless it deals with floating point decimals.

The problem was that I didn't setup the environment properly.
I did not add path of .dll files in PATH.

Now that I fixed them, it works like a charm!

huangapple
  • 本文由 发表于 2023年2月19日 01:46:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75495236.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定