Makefile : problems using -fopenmp

General OpenMP discussion

Re: Makefile : problems using -fopenmp

Postby MarkB » Tue Jun 11, 2013 12:53 pm

And a TAB before echo "Done" as well. Sorry.
MarkB
 
Posts: 408
Joined: Thu Jan 08, 2009 10:12 am

Re: Makefile : problems using -fopenmp

Postby alessandro » Tue Jun 11, 2013 1:00 pm

If i put on this way:
Code: Select all
CC = g++
CFLAGS = -fopenmp
LDFLAGS = -fopenmp

all:test1-forum
\t echo "Done"
test1-forum:test1-forum.o
\t $(CC) $(LDFLAGS) -o test1-forum test1-forum.o

.cpp.o:
\t $(CC) $(CFLAGS) -c $<

don't work.
If i put on this other way:
Code: Select all
CC = g++
CFLAGS = -fopenmp
LDFLAGS = -fopenmp

all:test1-forum
\t echo "Done"
test1-forum:test1-forum.o
\t $(CC) $(LDFLAGS) -o test1-forum test1-forum.o

.cpp.o:
\t $(CC) $(CFLAGS) -c $<

don't work the same.
If i use the key Tab from the keyboard the result is the same.
:cry:
alessandro
 
Posts: 26
Joined: Tue Jun 11, 2013 2:14 am

Re: Makefile : problems using -fopenmp

Postby ftinetti » Tue Jun 11, 2013 2:46 pm

Hmmm... I replaced "\t " by a TAB (by pressing the TAB key) in the text you posted and it works... unfortunately, TABs are "transformed" into spaces or deleted from our posts. If everything fails, you could try to download the file using https://dl.dropboxusercontent.com/u/8776798/Makefile
(and please check that there is only a TAB character in the places where you show "\t "

HTH,

Fernando.
ftinetti
 
Posts: 558
Joined: Wed Feb 10, 2010 2:44 pm

Re: Makefile : problems using -fopenmp

Postby alessandro » Tue Jun 11, 2013 10:54 pm

After download your make file i obtain that error:
$ make
Code: Select all
g++ -fopenmp -o test1-forum test1-forum.o
test1-forum.o: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o:(.text+0x0): first defined here
test1-forum.o:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o:(.rodata+0x0): first defined here
test1-forum.o: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crti.o:(.fini+0x0): first defined here
test1-forum.o:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here
test1-forum.o: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o:(.data+0x0): first defined here
test1-forum.o: In function `__data_start':
(.data+0x4): multiple definition of `__dso_handle'
/usr/lib/gcc/i686-linux-gnu/4.6/crtbegin.o:(.data+0x0): first defined here
test1-forum.o: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/i686-linux-gnu/4.6/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
test1-forum.o:(.dtors+0x4): first defined here
/usr/bin/ld: error in test1-forum.o(.eh_frame); no .eh_frame_hdr table will be created.
collect2: ld returned 1 exit status
make: *** [test1-forum] Errore 1


I obtain the same error running directly the follow line:
g++ -fopenmp -o test1-forum test1-forum.o
or
g++ -fopenmp -o test1-forum.cpp test1-forum.o
on the command line while if on the command line i use:
g++ test1-forum.cpp -o test1-forum.o -fopenmp
work fine.

ftinetti wrote:... check that there is only a TAB character in the places where you show "\t "

How i can make this check from geany?
alessandro
 
Posts: 26
Joined: Tue Jun 11, 2013 2:14 am

Re: Makefile : problems using -fopenmp

Postby MarkB » Wed Jun 12, 2013 3:21 am

Try doing a full clean rebuild: delete the executable and any .o files before you type the make command.
MarkB
 
Posts: 408
Joined: Thu Jan 08, 2009 10:12 am

Re: Makefile : problems using -fopenmp

Postby alessandro » Wed Jun 12, 2013 4:25 am

$ rm test1-forum.o
$ make
Code: Select all
make: ***  Nessuna regola per generare l'obiettivo "test1-forum.o", necessario per "test1-forum".  Arresto.

$ make all
Code: Select all
make: ***  Nessuna regola per generare l'obiettivo "test1-forum.o", necessario per "test1-forum".  Arresto.


While if i'm doing:
$ make test-forum1
Code: Select all
g++   -fopenmp  test-forum1.cpp   -o test-forum1


$ ./test-forum1
Code: Select all
Default number of automatic threads for the Pc: 2

Work and it's present the test-forum1 executable but don't test-forum1.o.

Seems to approach the solution ...
alessandro
 
Posts: 26
Joined: Tue Jun 11, 2013 2:14 am

Re: Makefile : problems using -fopenmp

Postby MarkB » Wed Jun 12, 2013 7:32 am

OK, try adding

.SUFFIXES: .o .cpp

at the start of the makefile.
MarkB
 
Posts: 408
Joined: Thu Jan 08, 2009 10:12 am

Re: Makefile : problems using -fopenmp

Postby alessandro » Wed Jun 12, 2013 8:05 am

Code: Select all
.SUFFIXES: .o .cpp
CC = g++
CFLAGS = -fopenmp
LDFLAGS = -fopenmp

all:test1-forum
   echo "Done"
   
test1-forum:test1-forum.o
   $(CC) $(LDFLAGS) -o test1-forum test1-forum.o

.cpp.o:
   $(CC) $(CFLAGS) -c $<


$ make
Code: Select all
make: ***  Nessuna regola per generare l'obiettivo "test1-forum.o", necessario per "test1-forum".  Arresto.


This time i already delete the executable before make this attempt.
alessandro
 
Posts: 26
Joined: Tue Jun 11, 2013 2:14 am

Re: Makefile : problems using -fopenmp

Postby MarkB » Wed Jun 12, 2013 9:07 am

I'm not sure what's wrong there, but let's try to be less clever:

Code: Select all
CC = g++
CFLAGS = -fopenmp
LDFLAGS = -fopenmp
         
all:test1-forum
        echo "Done"
test1-forum:test1-forum.o
        $(CC) $(LDFLAGS) -o test1-forum test1-forum.o     
test1-forum.o: test1-forum.cpp
        $(CC) $(CFLAGS) -c test1-forum.cpp


(don't forget the TABs!)
MarkB
 
Posts: 408
Joined: Thu Jan 08, 2009 10:12 am

Re: Makefile : problems using -fopenmp

Postby alessandro » Wed Jun 12, 2013 1:35 pm

Now i'm on a single-core computer with the same OS and the same gcc and both the script (so the last and the previous makefile) work fine! :!:

This solution preseve the tab during the copy and paste while if i post here don't.
After the indication of ftinetti I'm trying to pay attention to this important particular.

Code: Select all
$ make
g++ -fopenmp -c test1-forum.cpp
g++ -fopenmp -o test1-forum test1-forum.o     
echo "Done"
Done
$ ./test1-forum
Default number of automatic threads for the Pc: 1


Code: Select all
$ rm *.o test1-forum


Code: Select all
$ make all
g++ -fopenmp -c test1-forum.cpp
g++ -fopenmp -o test1-forum test1-forum.o     
echo "Done"
Done
$ ./test1-forum
Default number of automatic threads for the Pc: 1


Code: Select all
$ rm *.o test1-forum


Code: Select all
$ make test1-forum
g++ -fopenmp -c test1-forum.cpp
g++ -fopenmp -o test1-forum test1-forum.o     
$ ./test1-forum
Default number of automatic threads for the Pc: 1


When i'm on the multi-core (the only Pc where make sense to use openmp) I redo the test with the last script suggested to see if it works or not. :?:
Last edited by alessandro on Wed Jun 12, 2013 1:45 pm, edited 1 time in total.
alessandro
 
Posts: 26
Joined: Tue Jun 11, 2013 2:14 am

PreviousNext

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 9 guests

cron