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

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

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:

  1. #include <stdio.h>
  2. #include <omp.h>
  3. int main(void)
  4. {
  5. #pragma omp parallel num_threads(4)
  6. {
  7. printf("%d\n", omp_get_thread_num());
  8. }
  9. return 0;
  10. }

VSCode Configuration (Command-Line Arguments):

  1. "args": [
  2. "-O0",
  3. "-Wall",
  4. "-Wextra",
  5. "-fcolor-diagnostics",
  6. "-fansi-escape-codes",
  7. "-g",
  8. "${file}",
  9. "-o",
  10. "${fileDirname}\\.exe\${fileBasenameNoExtension}.exe",
  11. "-lm",
  12. "-lpthread",
  13. "-fopenmp"
  14. ],

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.

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

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

  1. #include &lt;stdio.h&gt;
  2. #include &lt;omp.h&gt;
  3. int main(void)
  4. {
  5. #pragma omp parallel num_threads(4)
  6. {
  7. printf(&quot;%d\n&quot;, omp_get_thread_num());
  8. }
  9. return 0;
  10. }
  1. &quot;args&quot;: [
  2. &quot;-O0&quot;,
  3. &quot;-Wall&quot;,
  4. &quot;-Wextra&quot;,
  5. &quot;-fcolor-diagnostics&quot;,
  6. &quot;-fansi-escape-codes&quot;,
  7. &quot;-g&quot;,
  8. &quot;${file}&quot;,
  9. &quot;-o&quot;,
  10. &quot;${fileDirname}\\.exe\${fileBasenameNoExtension}.exe&quot;,
  11. &quot;-lm&quot;,
  12. &quot;-lpthread&quot;,
  13. &quot;-fopenmp&quot;
  14. ],

答案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:

确定