英文:
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"
],
英文:
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> clang -Wall -Wextra -fopenmp .\test.c
PS C:\Users\first\Developments\Temp> ./a.exe
PS C:\Users\first\Developments\Temp>
Where did I go wrong? Here's my c code and vscode configuration(cmd args).
#include <stdio.h>
#include <omp.h>
int main(void)
{
#pragma omp parallel num_threads(4)
{
printf("%d\n", omp_get_thread_num());
}
return 0;
}
"args": [
"-O0",
"-Wall",
"-Wextra",
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}\\.exe\${fileBasenameNoExtension}.exe",
"-lm",
"-lpthread",
"-fopenmp"
],
答案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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论