Closed pankajd-57 closed 1 year ago
Please do not use -lslurmdb flag. Also find where is the accounting_storage_mysql.so library file (normally it is at the /usr/lib64/slurm/accounting_storage_mysql.so path), and add its directory to compile command with -L flag, such as -L/usr/lib64/slurm.
gcc -I/opt/slurm-21/include -lslurm -L/opt/slurm-21/lib -lslurm -L/opt/slurm-21/lib/slurm spart.c -o spart
However i get error as
spart.c:(.text+0x349f): undefined reference to slurm_perror' /usr/bin/ld: spart.c:(.text+0x34e1): undefined reference to
slurm_perror'
/usr/bin/ld: spart.c:(.text+0x3b13): undefined reference to slurm_load_ctl_conf' /usr/bin/ld: spart.c:(.text+0x3b23): undefined reference to
slurm_perror'
/usr/bin/ld: spart.c:(.text+0x3b46): undefined reference to `slurm_load_jobs'
Actual contents of /opt/slurm-21/include : slurm
ls /opt/slurm-21/include/slurm/ pmi.h slurmdb.h slurm_errno.h slurm.h slurm_version.h smd_ns.h spank.h
Actual contents of /opt/slurm-21/lib:
libslurm.a libslurm.la libslurm.so libslurm.so.36 libslurm.so.36.0.0 libslurm.so.37 libslurm.so.37.0.0 slurm
slurm dir contenains :
ls /opt/slurm-21/lib/slurm/accounting_storage_mysql.so
Your include file located at /opt/slurm-21/include/slurm/ directory, but you include (with -I) the /opt/slurm-21/include directory. Please use correct directory (-I/opt/slurm-21/include/slurm)
Thank you for response. However, below issue of not finding of slurm.h comes.
gcc -I/opt/slurm-21/include/slurm -lslurm -L/opt/slurm-21/lib spart.c -o spart
spart.c:11:10: fatal error: slurm/slurm.h: No such file or directory
11 | #include <slurm/slurm.h>
| ^~~~~~~
compilation terminated.
If I do like this :
gcc -I/opt/slurm-21/include/slurm -I/opt/slurm-21/include -lslurm -L/opt/slurm-21/lib spart.c -o spart, then
/usr/bin/ld: /tmp/cc012TF0.o: in function main': spart.c:(.text+0x349f): undefined reference to
slurm_perror'
/usr/bin/ld: spart.c:(.text+0x34e1): undefined reference to slurm_perror' /usr/bin/ld: spart.c:(.text+0x3b13): undefined reference to
slurm_load_ctl_conf'
/usr/bin/ld: spart.c:(.text+0x3b23): undefined reference to slurm_perror' /usr/bin/ld: spart.c:(.text+0x3b46): undefined reference to
slurm_load_jobs'
/usr/bin/ld: spart.c:(.text+0x3b56): undefined reference to slurm_perror' /usr/bin/ld: spart.c:(.text+0x3b79): undefined reference to
slurm_load_node'
/usr/bin/ld: spart.c:(.text+0x3b89): undefined reference to slurm_perror' /usr/bin/ld: spart.c:(.text+0x3bae): undefined reference to
slurm_load_partitions'
/usr/bin/ld: spart.c:(.text+0x3bbe): undefined reference to slurm_perror' /usr/bin/ld: spart.c:(.text+0x3cb0): undefined reference to
slurmdb_connection_get'
/usr/bin/ld: spart.c:(.text+0x3cce): undefined reference to slurm_perror' /usr/bin/ld: spart.c:(.text+0x3cfb): undefined reference to
slurm_list_create'
/usr/bin/ld: spart.c:(.text+0x3d1b): undefined reference to slurm_list_append' /usr/bin/ld: spart.c:(.text+0x3d25): undefined reference to
slurm_list_create'
/usr/bin/ld: spart.c:(.text+0x3d45): undefined reference to slurmdb_associations_get' /usr/bin/ld: spart.c:(.text+0x3d5b): undefined reference to
slurm_list_iterator_create'
/usr/bin/ld: spart.c:(.text+0x3d71): undefined reference to slurm_list_count' /usr/bin/ld: spart.c:(.text+0x3db7): undefined reference to
slurm_list_next'
/usr/bin/ld: spart.c:(.text+0x3de2): undefined reference to slurm_list_count' /usr/bin/ld: spart.c:(.text+0x3e2c): undefined reference to
slurmdb_qos_get'
/usr/bin/ld: spart.c:(.text+0x3e42): undefined reference to slurm_list_iterator_create' /usr/bin/ld: spart.c:(.text+0x3e62): undefined reference to
slurm_list_iterator_reset'
/usr/bin/ld: spart.c:(.text+0x3ea8): undefined reference to slurm_list_next' /usr/bin/ld: spart.c:(.text+0x3f0d): undefined reference to
slurm_list_count'
/usr/bin/ld: spart.c:(.text+0x3f2f): undefined reference to slurm_list_iterator_create' /usr/bin/ld: spart.c:(.text+0x3f7c): undefined reference to
slurm_list_next'
/usr/bin/ld: spart.c:(.text+0x3faa): undefined reference to slurmdb_qos_str' /usr/bin/ld: spart.c:(.text+0x4031): undefined reference to
slurm_list_iterator_destroy'
/usr/bin/ld: spart.c:(.text+0x4049): undefined reference to slurm_list_iterator_destroy' /usr/bin/ld: spart.c:(.text+0x4058): undefined reference to
slurm_list_destroy'
/usr/bin/ld: spart.c:(.text+0x4067): undefined reference to slurm_list_iterator_destroy' /usr/bin/ld: spart.c:(.text+0x4076): undefined reference to
slurm_list_destroy'
/usr/bin/ld: spart.c:(.text+0x4b7d): undefined reference to slurm_get_select_nodeinfo' /usr/bin/ld: spart.c:(.text+0x7af8): undefined reference to
slurm_free_job_info_msg'
/usr/bin/ld: spart.c:(.text+0x7b07): undefined reference to slurm_free_node_info_msg' /usr/bin/ld: spart.c:(.text+0x7b16): undefined reference to
slurm_free_partition_info_msg'
/usr/bin/ld: spart.c:(.text+0x7b25): undefined reference to `slurm_free_ctl_conf'
collect2: error: ld returned 1 exit status
Yes, you are right. Sorry. But there is an awkward status: the slurm_perror is defined at slurm_errno.h, and the slurm_load_ctl_conf is defined at slurm.h. I don't understand.
Right..How to go about this? Any workaround? Thanks.
I uploaded a new version of the spart command (v1.5.1). Would you try new version.
We have slurm 21.08.6 installed under /opt, which is non standard installation. While compiling the spart utility using below command
gcc -lslurm -lslurmdb spart.c -o spart -I/opt/slurm-20.11.7/include -L/opt/slurm-20.11.7/lib
I get :
############# /usr/bin/ld: cannot find -lslurmdb ###########################
Deatils of the compilation : spart.c: In function ‘main’: spart.c:411:24: warning: implicit declaration of function ‘slurmdb_qos_str’; did you mean ‘slurmdb_qos_get’? [-Wimplicit-function-declaration] 411 | qos2 = (char )slurmdb_qos_str(qosn_list, atoi(qos)); | ^
~~~~~~ | slurmdb_qos_get spart.c:411:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 411 | qos2 = (char )slurmdb_qos_str(qosn_list, atoi(qos)); | ^ In file included from spart.c:20: spart_output.h: In function ‘sp_column_header_print’: spart_output.h:229:47: warning: ‘%s’ directive output may be truncated writing up to 2147483648 bytes into a region of size 64 [-Wformat-truncation=] 229 | snprintf(cresult, SPART_MAX_COLUMN_SIZE, "%s", spcol->column_width, | ^~~ spart_output.h:229:46: note: assuming directive output of 4095 bytes 229 | snprintf(cresult, SPART_MAX_COLUMN_SIZE, "%s", spcol->column_width, | ^~~~~ spart_output.h:229:5: note: ‘snprintf’ output between 1 and 2147483649 bytes into a destination of size 64 229 | snprintf(cresult, SPART_MAX_COLUMN_SIZE, "%s", spcol->column_width, | ^~~~~~~~~~~~~~~~ 230 | spcol->line1); |~~~~~ spart_output.h:232:47: warning: ‘%s’ directive output may be truncated writing up to 2147483648 bytes into a region of size 64 [-Wformat-truncation=] 232 | snprintf(cresult, SPART_MAX_COLUMN_SIZE, "%s", spcol->column_width, | ^~~ spart_output.h:232:46: note: assuming directive output of 4095 bytes 232 | snprintf(cresult, SPART_MAX_COLUMN_SIZE, "%s", spcol->column_width, | ^~~~~ spart_output.h:232:5: note: ‘snprintf’ output between 1 and 2147483649 bytes into a destination of size 64 232 | snprintf(cresult, SPART_MAX_COLUMN_SIZE, "%s", spcol->column_width, | ^~~~~~~~~~~~~~~~ 233 | spcol->line2); |~~~~~ spart.c: In function ‘main’: spart.c:727:56: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size between 0 and 4095 [-Wformat-truncation=] 727 | snprintf(mem_result, SPART_INFO_STRING_SIZE, "%s(%s)", | ^~ 728 | spgres[0].gres_name, strtmp); |~~ spart.c:727:7: note: ‘snprintf’ output between 3 and 8193 bytes into a destination of size 4096 727 | snprintf(mem_result, SPART_INFO_STRING_SIZE, "%s(%s)", | ^~~~~~~~~~~~~~ 728 | spgres[0].gres_name, strtmp); |~~~~~~~~ spart.c:733:58: warning: ‘(’ directive output may be truncated writing 1 byte into a region of size between 0 and 4095 [-Wformat-truncation=] 733 | snprintf(mem_result, SPART_INFO_STRING_SIZE, ",%s(%s)", | ^ spart.c:733:9: note: ‘snprintf’ output between 4 and 8194 bytes into a destination of size 4096 733 | snprintf(mem_result, SPART_INFO_STRING_SIZE, ",%s(%s)", | ^~~~~~~~~~~~~~~ 734 | spgres[j].gres_name, strtmp); |~~~~~~~~ spart.c:746:56: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size between 0 and 4095 [-Wformat-truncation=] 746 | snprintf(mem_result, SPART_INFO_STRING_SIZE, "%s(%s)", | ^~ 747 | spfeatures[0].gres_name, strtmp); |~~ spart.c:746:7: note: ‘snprintf’ output between 3 and 8193 bytes into a destination of size 4096 746 | snprintf(mem_result, SPART_INFO_STRING_SIZE, "%s(%s)", | ^~~~~~~~~~~~~~ 747 | spfeatures[0].gres_name, strtmp); |~~~~~~~~ spart.c:752:58: warning: ‘(’ directive output may be truncated writing 1 byte into a region of size between 0 and 4095 [-Wformat-truncation=] 752 | snprintf(mem_result, SPART_INFO_STRING_SIZE, ",%s(%s)", | ^ spart.c:752:9: note: ‘snprintf’ output between 4 and 8194 bytes into a destination of size 4096 752 | snprintf(mem_result, SPART_INFO_STRING_SIZE, ",%s(%s)", | ^~~~~~~~~~~~~~~ 753 | spfeatures[j].gres_name, strtmp); |~~~~~~~~ /usr/bin/ld: cannot find -lslurmdb collect2: error: ld returned 1 exit status/usr/bin/ld: cannot find -lslurmdb