0

I am running a c++ code with TAU (analyzing and profiling tool) on Ubuntu 20.04 LTS using some cluster. The command I am running looks like this:

tau_cxx.sh -I$FFTW3_INC wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -optLinking="-lfftw3 -lm -g" -o ../../Datasim/TauTest.out

This however is giving me the following error:

Executing> /opt/apps/gcc/5.2.0/bin/g++ -I/opt/apps/gcc5_2/mvapich22_2/fftw/3.3.8/include wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -o ../../Datasim/TauTest.out
In file included from /arcapps/cascades-broadwell-slurm/opt/apps/gcc/5.2.0/include/c++/5.2.0/cstdint:35:0,
                 from arithmeticFunctions.cpp:8:
/arcapps/cascades-broadwell-slurm/opt/apps/gcc/5.2.0/include/c++/5.2.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^

make: *** [all] Error 1

So I tried compiling with -std=c++11 like this:

tau_cxx.sh -I$FFTW3_INC -std=c++11 wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -optLinking="-lfftw3 -lm -g" -o ../../Datasim/TauTest.out

This somehow messes up my -I$FFTW3_INC and I get errors like:

undefined reference to `fftw_malloc'

I tried also linking it in my TAU options like:

tau_cxx.sh -I$FFTW3_INC wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -optLinking="-lfftw3 -lm -std=c++11 -g" -o ../../Datasim/TauTest.out

This had no effect and gave me the original error. Can someone help please I am confused.

Jamie
  • 111
  • 2
  • 1
    I *suspect* that the addition of compiler option `-std=c++11` doesn't really "mess up" the `-I$FFTW_INC` (which would be unlikely to result in `undefined reference` errors - include files *declare* objects rather than defining them), it just allows the build process to proceed to the link phase where it was going to fail anyhow for other reasons – steeldriver May 27 '21 at 22:11
  • So, you're saying that the correct way to add this flag is like: `` tau_cxx.sh -I$FFTW3_INC -std=c++11 wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -optLinking="-lfftw3 -lm -g" -o ../../Datasim/TauTest.out `` But whatever error I get after has nothing to do with `` -I$FFTW_INC``?? Ok, I am not sure how to proceed really – Jamie May 27 '21 at 22:21
  • TBH I don't know anything about tau, however the documentation suggests there's a `‐optVerbose` option - perhaps adding that would provide some additional information about the error? The docs also suggest there's a `‐optCompile=` which might be the "right" place to put `-std=c++11`. Are you able to share the `tau_cxx.sh` script? – steeldriver May 27 '21 at 22:31
  • I tried running with `` ‐optCompile="-std=c++11" and it gave me: ``g++: error: ‐optCompile=-std=c++11: No such file or directory`` – Jamie May 27 '21 at 22:37
  • OK so I guess `‐optCompile` is **not** the right place ... – steeldriver May 27 '21 at 22:45

1 Answers1

0

After adding the (required) -std=c++11 flag (strange, the default by now is -std=gnu++17 --i.e., ISO C++ 2017 + GNU extensions-- which should include the previous), you get it to compile, but the definition for fftw_malloc (presumably in some library) is missing. Check the manual page for fftw_malloc, it should tell you the correct incantation. If this is called e.g from a Makefile, check any lines LIB = or similar.

vonbrand
  • 18,156
  • 2
  • 37
  • 59
  • fftw_malloc, comes from fftw3.h library which is linked through ``-I$FFTW3_INC" and I have an ``#include "fftw3.h"`` in my cpp script I am running. I am wondering if the order when calling these flags matter or something? – Jamie May 27 '21 at 22:42
  • 1
    @Jamie `fftw_malloc` may be *declared* in fftw3.h, but it is *defined* in the `libfftw3` library, which presumably should be linked by the `-lfftw3` in your `-optLinking` string. The order of library linkage certainly does matter (at least if the underlying linker is `g++`/`ld`) however that is obscured from you by the `tau_cxx.sh` wrapper script – steeldriver May 27 '21 at 22:56