Page 1 of 1

openmp program does not run from IDE, but runs from explorer

Posted: Wed Jun 17, 2015 3:25 pm
by xts
Hello guys,

I have a problem with running a program from the IDE.
I am trying to work with openmp, so I installed default fresh installation of codelite and TDM-GCC (with openmp support).

Now, this small testing openmp program:

Code: Select all

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

int main() { 
  #pragma omp parallel 
  printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads()); 
}

I have 3 options:

1, if I want to build and run the program (ctrl+F9) , the build process runs ok, but I get an error about missing libgomp_64-1.dll and the output window shows just "press any key to continue".

2, When I find the built .exe file in the debug folder and click it, I get some output "Hello from thread 0, nthreads 1" - output ok, but the multithread does not work.

3, when I compile it manually with g++, whoa - I get two lines "Hello from thread 1, nthreads 2" and "Hello from thread 0, nthreads 2" - output works and multi-thread part too.


Now, what am I doing wrong with setting of codelite? I added the fopenmp library to get rid of the error "Undefined reference to `omp_get_max_threads_'", now the compilation
and building is without any errors in the "Build" window.

I selected console and g++ compiler during the workspace creation.

May this be some 32/64 bit problem? I am using windows 7 x64, but the compiler is TDM-GCC-32 and this field cannot be changed in the project details.


thank you for your suggestions, and please be patient - I am total newbie to codelite (have some C experience though).

Re: openmp program does not run from IDE, but runs from expl

Posted: Wed Jun 17, 2015 3:35 pm
by eranif
Please paste the entire build log (do a full rebuild and paste it here)
See my signature for missing info in your post.

If CodeLite does not let you change the compiler, then it means that this is the only compiler you have installed on your machine

Eran

Re: openmp program does not run from IDE, but runs from expl

Posted: Wed Jun 17, 2015 5:04 pm
by xts
sorry about that. Codelite - amd64 8.0, tdm64-gcc 4.9.2-3, Windows 7 x64 professional.

Although I didn't do anything except closing and opening codelite, I don't get the option 1 anymore - now I can run the program with ctrl+F9, but it acts like option 2 - it doesn't work multi-threaded, and it is the same when I run the .exe file manually.

Still, when i compile it from the command line (>g++ main.cpp -fopenmp -o testc.exe), it runs correctly with two threads.

Build log here:

Code: Select all

C:\Windows\system32\cmd.exe /C "C:/TDM-GCC-64/bin/mingw32-make.exe -j2 SHELL=cmd.exe -e -f  Makefile"
"----------Building project:[ testc - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/x/Documents/codelite/testc/testc'
C:/TDM-GCC-64/bin/g++.exe -o ./Debug/testc @"testc.txt" -L.   -fopenmp
mingw32-make.exe[1]: Leaving directory 'C:/Users/x/Documents/codelite/testc/testc'
0 errors, 0 warnings

Re: openmp program does not run from IDE, but runs from expl

Posted: Wed Jun 17, 2015 5:14 pm
by eranif
You pasted here the link, please perform a clean, followed by build (or "Rebuild")
Also, enable the -Wall compiler option

Eran

Re: openmp program does not run from IDE, but runs from expl

Posted: Wed Jun 17, 2015 6:42 pm
by xts
build log:

Code: Select all

C:\Windows\system32\cmd.exe /C "C:/TDM-GCC-64/bin/mingw32-make.exe -j2 SHELL=cmd.exe -e -f  Makefile"
"----------Building project:[ testc - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/x/Documents/codelite/testc/testc'
mingw32-make.exe[1]: Leaving directory 'C:/Users/x/Documents/codelite/testc/testc'
mingw32-make.exe[1]: Entering directory 'C:/Users/x/Documents/codelite/testc/testc'
C:/TDM-GCC-64/bin/g++.exe  -c  "C:/Users/x/Documents/codelite/testc/testc/main.cpp" -g -O0 -Wall  -o ./Debug/main.cpp.o -I. -I.
C:/Users/x/Documents/codelite/testc/testc/main.cpp:7:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
   #pragma omp parallel
 ^
C:/TDM-GCC-64/bin/g++.exe -o ./Debug/testc @"testc.txt" -L.   -fopenmp
mingw32-make.exe[1]: Leaving directory 'C:/Users/x/Documents/codelite/testc/testc'
0 errors, 1 warnings
I can see the #pragma warning there that is probably the problem?

Where should I turn on the wall option? My compiler options (both c++ and C) are set to "-g;-O0;-Wall"

Re: openmp program does not run from IDE, but runs from expl

Posted: Wed Jun 17, 2015 8:57 pm
by xts
thanx eranif, you got me to the answer.. it seems the -fopenmp parameter was somehow ignored until I re-builded the program (instead of build-and-run ctrl+f9).

I tried to add the parameter to the compiler options, but I didn't rebuild it after that, I just pressed ctrl+f9 (build and run).

After I added it again, and rebuilded it, it's ok - I can see both threads.thanks again