c++ - 在配置了 g++ 和 gcc 的 netbeans 中使用 -fopenmp 编译

标签 c++ gcc netbeans openmp

我正在尝试配置我的 netbeans 以处理我的并行编程 C++ 代码。我可以使用命令行 (cygwin) 编译该代码,但现在为了进一步调试和编码更复杂的东西,我想转移到某个 IDE 并选择 neatbeans 来完成我的任务。一旦我在 netbeans 中单击构建我的应用程序按钮,有人可以建议我如何添加 -fopenmp 来编译我的应用程序。 (已经使用 netbeans_ 配置了 GCC 和 G++。下面是我使用 netbeans 构建代码时遇到的错误:

    cd 'D:\University\PARALLEL\ParallelTesting'
C:\dev_softwares\cygwin64\bin\make.exe -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/d/University/PARALLEL/ParallelTesting'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/paralleltesting.exe
make[2]: Entering directory '/cygdrive/d/University/PARALLEL/ParallelTesting'
mkdir -p dist/Debug/Cygwin-Windows
g++     -o dist/Debug/Cygwin-Windows/paralleltesting build/Debug/Cygwin-Windows/main.o 
build/Debug/Cygwin-Windows/main.o: In function `main':
/cygdrive/d/University/PARALLEL/ParallelTesting/main.cpp:26: undefined reference to `omp_get_thread_num'
/cygdrive/d/University/PARALLEL/ParallelTesting/main.cpp:26:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `omp_get_thread_num'
/cygdrive/d/University/PARALLEL/ParallelTesting/main.cpp:32: undefined reference to `omp_get_num_threads'
/cygdrive/d/University/PARALLEL/ParallelTesting/main.cpp:32:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `omp_get_num_threads'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/Cygwin-Windows/paralleltesting.exe' failed

p.s:并行编程世界的新手,并且已经使用 netbeans 配置了 gcc。

My gcc configuration FYI

Versions

我的测试并行代码:

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

int main (int argc, char *argv[]) 
{
int nthreads, tid;

/* Fork a team of threads giving them their own copies of variables */
#pragma omp parallel private(nthreads, tid)
  {

  /* Obtain thread number */
  tid = omp_get_thread_num();
  printf("Hello World from thread = %d\n", tid);

  /* Only master thread does this */
  if (tid == 0) 
    {
    nthreads = omp_get_num_threads();
    printf("Number of threads = %d\n", nthreads);
    }

  }  /* All threads join master thread and disband */

}

最佳答案

下面是我所做的并且有效。感谢@Hristolliev。

If it is a managed C/C++ project, then compiler options can be specified in project properties -> Build -> C++ Compiler -> Additional Options.

enter image description here

关于c++ - 在配置了 g++ 和 gcc 的 netbeans 中使用 -fopenmp 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41354144/

相关文章:

c++ - 匹配作为 void* 与 GMock 传递的 C 样式数组

c++ - 基于 Qt 的 GUI 来执行 shell 脚本

c - c 中的 x64 内联汇编以对齐指令

linux - 将符号链接(symbolic link)到 Linux 上的固定地址

sql - 创建VARCHAR FOR BIT DATA列

c++ - 消除模板类不需要的大小写

c++ - 如何销毁 CUDA 图形数据类型

c++ - 我可以扩展一个参数包并用它定义一个参数列表吗?

java - 如何向下滚动 JScrollPane 上的垂直滚动条?

netbeans - 有没有什么netbeans插件可以代替jindent?