2 Replies Latest reply: Apr 3, 2011 12:46 PM by 847999 RSS

    Undefined reference to `omp_set_num_threads'

    847999
      I have downloaded the tar solaris studio file, uncompressed it in a folder in my user's home. I have added the Solaris Tool Collection and enabled it by default.

      Now when I try to run this little program:
      #include<omp.h>
      #include<stdio.h>
      #include<unistd.h>

      int main(){
      omp_set_num_threads(4);
      #pragma omp parallel num_threads(4)
      {
      //omp_get_thread_num();
      sleep(8);
      }
      }

      I get this error:

      dmake: defaulting to parallel mode.
      See the man page dmake(1) for more information on setting up the .dmakerc file.
      ubuntu --> 1 job
      ubuntu --> 2 jobs
      "/home/arthur/Downloads/SolarisStudio12.2-linux-x86-tar-ML/solstudio12.2/bin/dmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
      "/home/arthur/Downloads/SolarisStudio12.2-linux-x86-tar-ML/solstudio12.2/bin/dmake" -f nbproject/Makefile-Debug.mk dist/Debug/OracleSolarisStudio-Linux-x86/cppapplication_1
      ubuntu --> 1 job
      mkdir -p build/Debug/OracleSolarisStudio-Linux-x86
      CC -c -g -o build/Debug/OracleSolarisStudio-Linux-x86/main.o main.cpp
      ubuntu --> 1 job
      mkdir -p dist/Debug/OracleSolarisStudio-Linux-x86
      CC -o dist/Debug/OracleSolarisStudio-Linux-x86/cppapplication_1 build/Debug/OracleSolarisStudio-Linux-x86/main.o
      mkdir -p dist/Debug/OracleSolarisStudio-Linux-x86
      CC -o dist/Debug/OracleSolarisStudio-Linux-x86/cppapplication_1 build/Debug/OracleSolarisStudio-Linux-x86/main.o
      *** Error code 2
      *** Error code 1
      *** Error code 1
      build/Debug/OracleSolarisStudio-Linux-x86/main.o: In function `main':
      /home/arthur/SolStudioProjects/CppApplication_1//main.cpp:6: undefined reference to `omp_set_num_threads'
      dmake: Fatal error: Command failed for target `dist/Debug/OracleSolarisStudio-Linux-x86/cppapplication_1'
      Current working directory /home/arthur/SolStudioProjects/CppApplication_1
      dmake: Fatal error: Command failed for target `.build-conf'
      Current working directory /home/arthur/SolStudioProjects/CppApplication_1
      dmake: Fatal error: Command failed for target `.build-impl'

      BUILD FAILED (exit value 1, total time: 1s)

      Any idea?