Bitcoin Forum

Other => Beginners & Help => Topic started by: Banzak on December 12, 2017, 05:19:47 PM



Title: [SOLVED] compile adlutil with gcc on Ubuntu 16.04.3 LTS
Post by: Banzak on December 12, 2017, 05:19:47 PM
Hello,

I am stuck with compiling the adlutil from the adl_sdk_V10.2 package.

I am running:
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

the gcc version is:
  • gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 2016060

I already installed:
  • the AMD-APP-SDK-3.0
  • the amdgpu-pro-17.40.492261

the Claymore DualMiner 10.2 is running fine since 1 week.

When I am trying to compile the adlutil with the following command:
Code:
sudo gcc main.c -o adlutil -DLINUX -ldl -I ../include/

I get the following error:
Code:
main.c: In function ‘GetValue’:
main.c:815:17: warning: format ‘%d’ expects argument of type ‘int *’, but argument 4 has type ‘int’ [-Wformat=]
  fscanf_s( file,"%32s %d\n", sField, 33, iValue);
                 ^
main.c:815:17: warning: too many arguments for format [-Wformat-extra-args]
main.c: In function ‘GetHex’:
main.c:828:17: warning: format ‘%X’ expects argument of type ‘unsigned int *’, but argument 4 has type ‘int’ [-Wformat=]
  fscanf_s( file,"%32s %X\n", sField, 33, iValue);
                 ^
main.c:828:17: warning: too many arguments for format [-Wformat-extra-args]
main.c: In function ‘GetFloat’:
main.c:841:17: warning: format ‘%f’ expects argument of type ‘float *’, but argument 4 has type ‘int’ [-Wformat=]
  fscanf_s( file,"%32s %f\n", sField, 33, fValue);
                 ^
main.c:841:17: warning: too many arguments for format [-Wformat-extra-args]

How do I fix that, or what I am missing?

Thank you for your help!

Regards,
Banzak





Title: Re: compile adlutil with gcc on Ubuntu 16.04.3 LTS
Post by: Banzak on December 12, 2017, 08:01:37 PM
I solved it finally myself, there is an error in the main.c in the adlutil directory.

Here is the fix for others, go to line 819, there you will find the functions: GetValue(), GetHex() and GetFloat().

Old code to replace

Code:
int GetValue(  char * name, int * iValue, int line )
{
char sField[ 256 ];
fscanf_s( file,"%32s %d\n", sField, 33, iValue);
if ( 0 == strcmp( sField, name ) )
return ADL_OK;
else
{
sprintf_s( err, sErr, "Expected     : %s \nActual       : %s \nIn line      : %d", name, sField, line );
return ADL_ERR;
}
}

int GetHex(  char * name, int * iValue, int line )
{
char sField[ 256 ];
fscanf_s( file,"%32s %X\n", sField, 33, iValue);
if ( 0 == strcmp( sField, name ) )
return ADL_OK;
else
{
sprintf_s( err, sErr, "Expected     : %s \nActual       : %s \nIn line      : %d", name, sField, line );
return ADL_ERR;
}
}

int GetFloat(  char * name, float * fValue, int line )
{
char sField[ 256 ];
fscanf_s( file,"%32s %f\n", sField, 33, fValue);
if ( 0 == strcmp( sField, name ) )
return ADL_OK;
else
{
sprintf_s( err,  sErr, "Expected     : %s \nActual       : %s \nIn line      : %d", name, sField, line );
return ADL_ERR;
}
}

with that:
Code:
int GetValue(  char * name, int * iValue, int line )
{
char sField[ 256 ];
fscanf_s( file,"%32s %d\n", sField, iValue);
if ( 0 == strcmp( sField, name ) )
return ADL_OK;
else
{
sprintf_s( err, sErr, "Expected     : %s \nActual       : %s \nIn line      : %d", name, sField, line );
return ADL_ERR;
}
}

int GetHex(  char * name, int * iValue, int line )
{
char sField[ 256 ];
fscanf_s( file,"%32s %X\n", sField, iValue);
if ( 0 == strcmp( sField, name ) )
return ADL_OK;
else
{
sprintf_s( err, sErr, "Expected     : %s \nActual       : %s \nIn line      : %d", name, sField, line );
return ADL_ERR;
}
}

int GetFloat(  char * name, float * fValue, int line )
{
char sField[ 256 ];
fscanf_s( file,"%32s %f\n", sField, fValue);
if ( 0 == strcmp( sField, name ) )
return ADL_OK;
else
{
sprintf_s( err,  sErr, "Expected     : %s \nActual       : %s \nIn line      : %d", name, sField, line );
return ADL_ERR;
}
}

Explaination:

the error was in the function:
Code:
fscanf_s( file,"%32s %d\n", sField, 33, iValue);
you have to remove te third argument in all the functions, after that it should compile the adlutil.

Regards,
Banzak