Project

General

Profile

CDO 1.9.0 building error with CMOR- undefined reference to cmor_*

Added by Jianyu Liu over 6 years ago

Hi,

I'm building CDO 1.9.0 with gcc 4.9.2 and CMOR 2.9.3

Firstly, it got an error of "invalid conversion from ‘void*’ to ‘char**’", like this

In file included from cdo_int.h:42:0,
                 from CMOR.cc:3:
CMOR.cc: In function ‘void parse_cmdline(list_t*, char**, int, char*)’:
dmemory.h:35:71: error: invalid conversion from ‘void*’ to ‘char**’ [-fpermissive]
 #  define   Malloc(s)      memMalloc((s), __FILE__, __func__, __LINE__)
                                                                       ^
CMOR.cc:3592:20: note: in expansion of macro ‘Malloc’
           values = Malloc(100 * sizeof(char *));
^

I set -fpermissive to downgrade it to a warning to suppress this error and passed compilation of CMOR.cc

But at the link time, it complained a lot of errors of 'undefined reference to `cmor_*', like this

cdo-CMOR.o: In function `setup_dataset(list_t*, int, int*)':
CMOR.cc:(.text+0x4005): undefined reference to `cmor_setup(char*, int*, int*, int*, char*, int*)'
CMOR.cc:(.text+0x43a8): undefined reference to `cmor_dataset(char*, char*, char*, char*, char*, int, char*, char*, char*, char*, int, int, int*, char*, char*, int, int, char*, char*, double*, char*)'
cdo-CMOR.o: In function `register_z_axis(list_t*, int, int, int, char*, int*, int*, char*, int)':
CMOR.cc:(.text+0x54a3): undefined reference to `cmor_axis(int*, char*, char*, int, void*, char, void*, int, char*)'
CMOR.cc:(.text+0x5604): undefined reference to `cmor_axis(int*, char*, char*, int, void*, char, void*, int, char*)'

I did specify the include path and lib path of cmor, and I could make sure the path is valid and has been passed to compiler correctly.

And I also checked that all of cmor_* have been defined in libcmor.a

Here are the output of nm

jliu@helios:cdo-1.9.0 $ nm src/cdo-CMOR.o | grep cmor_setup
U Z10cmor_setupPcPiS0_S0_S_S0

jliu@helios:cdo-1.9.0 $ nm /scratch/singadm/pkg_helios/cmor/2.9.3/lib/libcmor.a | grep cmor_setup
000000000000220b T cmor_setup
U cmor_setup
0000000000000b71 T cmor_setup_cff_
0000000000000b25 T cmor_setup_cff_nolog_
000000000002d9f0 T _cmor_users_functions_MOD_cmor_setup_ints
000000000002e160 T __cmor_users_functions_MOD_cmor_setup_nc_char
U cmor_setup_cff

U cmor_setup_cff_nolog_

Wondering how to fix this problem.

Thanks for your time

Regards

Jerry


Replies (2)

RE: CDO 1.9.0 building error with CMOR- undefined reference to cmor_* - Added by Jianyu Liu over 6 years ago

Hi,

Just an update

It's a name mangling issue. CMOR library was compiled by C. It needs to touch src/CMOR.cc like this

#ifdef __cplusplus
extern "C" {
#endif

#include "cmor.h" 
#include "cmor_func_def.h" 

#ifdef __cpluscplus
}
#endif

RE: CDO 1.9.0 building error with CMOR- undefined reference to cmor_* - Added by Fabian Wachsmann over 6 years ago

Hi Jerry,
thanks for the message, the next CDO update will include your suggested code. Maybe you also need to rename variables of the CMOR library called 'template' because cplusplus interprets this as a keyword (you have to do when using CMOR3).
If you have access to mistral and if you can go without the newest CDO 1.9.0 updates, I can recommend you to use the cdo-version (1.8.2 with CMOR): /work/bm0021/cdo_incl_cmor/cdo_06_14_2017_cmor2/cdo-git/src/cdo. The advantage is, I can fix bugs in that version quickly.
Note that CMOR2 is appropriate to create CMIP5 standard - if you want to produce CMIP6 compliant data you have to use CMOR3.
I am still improving the operator, so if you have more suggestions, let me know.
Best regards,
Fabi

    (1-2/2)