rjhogan / Adept-2

Combined array and automatic differentiation library in C++
http://www.met.reading.ac.uk/clouds/adept/
Apache License 2.0
163 stars 29 forks source link

error: ‘class Timer’ has no member named ‘new_activity’ (and other errors due to Timer.h) #24

Closed barracuda156 closed 1 year ago

barracuda156 commented 1 year ago
test_checkpoint.cpp: In function ‘int main(int, char**)’:
test_checkpoint.cpp:45: error: ‘class Timer’ has no member named ‘print_on_exit’
test_checkpoint.cpp:69: error: ‘class Timer’ has no member named ‘new_activity’
test_checkpoint.cpp:70: error: ‘class Timer’ has no member named ‘new_activity’
test_checkpoint.cpp:76: error: invalid conversion from ‘int’ to ‘const char*’
test_checkpoint.cpp:76: error:   initializing argument 1 of ‘void Timer::start(const char*)’
test_checkpoint.cpp:137: error: invalid conversion from ‘int’ to ‘const char*’
test_checkpoint.cpp:137: error:   initializing argument 1 of ‘void Timer::start(const char*)’
test_checkpoint.cpp:236: error: ‘class Timer’ has no member named ‘stop’
make[1]: *** [test_checkpoint.o] Error 1
make: *** [check-recursive] Error 1
barracuda156 commented 1 year ago

Same error when building 2.1.1 and master branch.

barracuda156 commented 1 year ago

Okay, that is actually not a single test but a general problem:

/usr/bin/g++-4.2 -pipe -Os -arch ppc -fopenmp -I/opt/local/include  -I../include  -c test_array_speed.cpp
test_array_speed.cpp: In function ‘int main()’:
test_array_speed.cpp:18: error: ‘class Timer’ has no member named ‘print_on_exit’
test_array_speed.cpp:40: error: ‘class Timer’ has no member named ‘new_activity’
test_array_speed.cpp:41: error: ‘class Timer’ has no member named ‘new_activity’
test_array_speed.cpp:42: error: ‘class Timer’ has no member named ‘new_activity’
test_array_speed.cpp:43: error: ‘class Timer’ has no member named ‘new_activity’
test_array_speed.cpp:44: error: ‘class Timer’ has no member named ‘new_activity’
test_array_speed.cpp:45: error: ‘class Timer’ has no member named ‘new_activity’
test_array_speed.cpp:54: error: invalid conversion from ‘int’ to ‘const char*’
test_array_speed.cpp:54: error:   initializing argument 1 of ‘void Timer::start(const char*)’
test_array_speed.cpp:62: error: ‘class Timer’ has no member named ‘stop’
test_array_speed.cpp:77: error: invalid conversion from ‘int’ to ‘const char*’
test_array_speed.cpp:77: error:   initializing argument 1 of ‘void Timer::start(const char*)’
test_array_speed.cpp:85: error: ‘class Timer’ has no member named ‘stop’
test_array_speed.cpp:107: error: invalid conversion from ‘int’ to ‘const char*’
test_array_speed.cpp:107: error:   initializing argument 1 of ‘void Timer::start(const char*)’
test_array_speed.cpp:112: error: ‘class Timer’ has no member named ‘stop’
test_array_speed.cpp:129: error: invalid conversion from ‘int’ to ‘const char*’
test_array_speed.cpp:129: error:   initializing argument 1 of ‘void Timer::start(const char*)’
test_array_speed.cpp:134: error: ‘class Timer’ has no member named ‘stop’
test_array_speed.cpp:158: error: invalid conversion from ‘int’ to ‘const char*’
test_array_speed.cpp:158: error:   initializing argument 1 of ‘void Timer::start(const char*)’
test_array_speed.cpp:166: error: ‘class Timer’ has no member named ‘stop’
test_array_speed.cpp:171: error: invalid conversion from ‘int’ to ‘const char*’
test_array_speed.cpp:171: error:   initializing argument 1 of ‘void Timer::start(const char*)’
test_array_speed.cpp:179: error: ‘class Timer’ has no member named ‘stop’
make[1]: *** [test_array_speed.o] Error 1
make: *** [check-recursive] Error 1
barracuda156 commented 1 year ago

@rjhogan Could you take a look why it fails?

rjhogan commented 1 year ago

My guess is that your compile settings have added a -I argument to the command line containing another Timer.h file and it is reading the wrong one. It should be reading the one in the include directory, and indeed in test/Makefile there is a -I../include argument.

barracuda156 commented 1 year ago

My guess is that your compile settings have added a -I argument to the command line containing another Timer.h file and it is reading the wrong one. It should be reading the one in the include directory, and indeed in test/Makefile there is a -I../include argument.

@rjhogan Thank you, I will check that!

What about aReal error with new GCC? https://github.com/rjhogan/Adept-2/issues/25

rjhogan commented 1 year ago

That's something else - I'm just fixing that and will reply to the other issue

barracuda156 commented 1 year ago

@rjhogan Looks like you are absolutely right: Macports prefix comes in front, and there is another timer.h there:

/usr/bin/g++-4.2 -pipe -Os -arch ppc -fopenmp -I/opt/local/include  -I../include  -c test_misc.cpp

I will think how to reverse the sequence. (Another option would be declaring a conflict at build time with the port responsible for that header.)

UPD. I guess this is the reason, in Makefile:

COMPILE_FLAGS = $(CXXFLAGS) $(CPPFLAGS) $(ADEPT_FLAGS) -I../include

So I can just patch this to:

COMPILE_FLAGS = $(CXXFLAGS) -I../include $(CPPFLAGS) $(ADEPT_FLAGS)
rjhogan commented 1 year ago

Yes that's the place to do it - I'll post a fix to the other problem and include this change

barracuda156 commented 1 year ago

@rjhogan Another question here, I do not want to open a separate issue for it, since not sure if it is an error or not:

In file included from test_no_lib.cpp:18:
../include/adept_source.h:46:2: warning: #warning "The adept_source.h header file has not been edited so BLAS matrix multiplication and LAPACK linear-algebra support have been disabled"

I got the same trying to build ESL which depends on adept too.

Is that header supposed to be manually edited or something in the build systems fails to pick the presence of OpenBLAS?

Configure has this:

configure: ********************* Summary **************************************
configure:   CXX = /usr/bin/g++-4.2 
configure:   CPPFLAGS = -I/opt/local/include
configure:   CXXFLAGS = -pipe -Os -arch ppc -fopenmp
configure:   LDFLAGS =  -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-rpath,/opt/local/lib/libgcc -arch ppc
configure:   LIBS = -ladolc  -lopenblas 
configure: Typing "make; make install" will install Adept header files in ${prefix}/include
configure: and the static and shared libraries as ${exec_prefix}/lib/libadept.*, where
configure: prefix=/opt/local
configure: ********************* Libraries used by Adept **********************
configure: BLAS (Basic Linear Algebra Subprograms) will be used: BLAS_LIBS = -lopenblas
configure:   Number of BLAS threads may be controlled at run time
configure: LAPACK (Linear Algebra Package) will be used: LAPACK_LIBS = 
configure: ********************* Libraries used by test programs **************
configure: GNU Scientific Library (GSL) found; Adept will compile all the
configure: example programs.
configure: ********************* Benchmark program ****************************
rjhogan commented 1 year ago

Normal behaviour for this test, explained in section 1.2.2 of the documentation http://www.met.reading.ac.uk/clouds/adept/adept_documentation_2.1.pdf

barracuda156 commented 1 year ago

Yes that's the place to do it - I'll post a fix to the other problem and include this change

So the header problem is fixed, tests build fine, one fails on 10.6.8 (not too surprising, perhaps, may work better with a new GCC):

test_adept... PASSED
test_adept_with_and_without_ad... PASSED
test_radiances... PASSED
test_gsl_interface... PASSED
test_misc... PASSED
test_checkpoint... PASSED
test_thread_safe... ./run_tests.sh: line 18: 85425 Abort trap              ./$TEST >> $LOG 2> $STDERR
*** FAILED ***
terminate called after throwing an instance of 'terminate called recursively
terminate called recursively
terminate called recursively
test_array_speed... PASSED
test_no_lib... PASSED
test_radiances_array... PASSED
test_constructors... PASSED
test_arrays... PASSED
test_arrays_active... PASSED
test_arrays_active_pausable... PASSED
test_fixed_arrays... PASSED
test_fixed_arrays_active... PASSED
test_derivatives... PASSED
test_array_derivatives... PASSED
test_thread_safe_arrays... PASSED
test_complex_arrays... PASSED
test_packet_operations... PASSED
test_fastexp... PASSED
test_reduce_active... PASSED
test_minimizer... PASSED

1 programs failed in some way - see detailed output in test_results.txt

make[1]: *** [run-tests] Error 1

Test log: test_results.txt

rjhogan commented 1 year ago

Thread-local storage is not supported on some older Macs, although I'm not sure when it started to work as I'm on MacOS 12.6 and it works fine. Might be related to gcc version too - v4 is very old

barracuda156 commented 1 year ago

Thread-local storage is not supported on some older Macs, although I'm not sure when it started to work as I'm on MacOS 12.6 and it works fine. Might be related to gcc version too - v4 is very old

That should be solved by using gcc12, it emulates TLS, good for most purposes on 10.5+. I will try it, when you post a fix for that other error.

barracuda156 commented 1 year ago

Closing this issue, since TLS error is due to OS/compiler, and header sequence is fixed.