我正在尝试编译此软件包:http://sourceforge.net/projects/snap-graph/?source=dlp

我在这里遇到语法错误:

gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -I../include   -O3 -fomit-frame-pointer -malign-double -fstrict-aliasing -ffast-math -MT drive_seed_community_detection.o -MD -MP -MF .deps/drive_seed_community_detection.Tpo -c -o drive_seed_community_detection.o drive_seed_community_detection.c
drive_seed_community_detection.c: In function ‘identify_comm’:
drive_seed_community_detection.c:214:14: error: expected expression before ‘do’
make[2]: *** [drive_seed_community_detection.o] Fehler 1
make[2]: Leaving directory `/amd.home/home/s/workspace/snap-0.4/test'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/amd.home/home/s/workspace/snap-0.4'
make: *** [all] Error 2

出现错误的相关代码部分是。特别是第214行:queue[atomic_fetch_and_add (&k2, 1)] = w;任何想法可能是什么问题?
  /* Find and label the connected components. */
  ncomm = 0;
  for (attr_id_t kseed = 0; kseed < num_seeds; ++kseed) {
    attr_id_t k1, k2;
    const attr_id_t seedv = seeds[kseed];
    if (membership[seedv] != -2) continue;
    queue[0] = seedv;
    membership[seedv] = seedv;
    comm_root[ncomm] = seedv;

    k1 = 0;
    k2 = 1;
    do {
      const attr_id_t qkend = k2;
      attr_id_t cv = 0;
      OMP("omp parallel for reduction(+:cv)")
      for (attr_id_t k1i = k1; k1i < qkend; ++k1i) {
        const attr_id_t v = queue[k1i];
        const attr_id_t deg = xoff[v+1] - xoff[v];
        cv += deg;
        if (deg > comm_maxdeg[ncomm]) comm_maxdeg[ncomm] = deg;
        for (attr_id_t k = xoff[v]; k < xoff[v+1]; ++k) {
          const attr_id_t w = xadj[k];
          attr_id_t memb;
          if (membership[w] < -1) {
            atomic_val_compare_and_swap (memb, &membership[w], -2, seedv);
            if (memb < -1) {
              //if (membership[w] < -1) {
              //membership[w] = seedv;
              //int loc;
              //OMP("omp atomic") loc = k2++;
              queue[atomic_fetch_and_add (&k2, 1)] = w;
            }
          }
        }
      }
      k1 = qkend;
      comm_vol[ncomm] = cv;
    } while (k1 != k2);
    comm_size[ncomm] = k2;
    ++ncomm;
  }

最佳答案

仅当编译源代码时没有OpenMP支持时,才会出现您遇到的错误。

其他答案已经提供了有关如何修补源以在这种情况下也进行编译的可能性。

解决OP问题的另一种方法是在编译之前启用对OpenMP的支持。

这可以通过将适当的选项传递给configure脚本来完成:

snap-0.4$ make clean
snap-0.4$ ./configure --enable-openmp

这将产生以下输出:
snap successfully configured! Please verify that
this configuration matches with your expectations.

   User Option                         Value
------------------------------------------------------
   OpenMP support                      yes
   Enable debug                        no

...

然后使用简单的方法编译源代码
snap-0.4$ make

应该无缝地工作。

注意

这仅适用于具有#define ed的编译器:
  • __GNUC__

  • 或/和
  • __INTEL_COMPILER
  • 10-04 21:55