sgminer-dev / sgminer

Scrypt GPU miner
GNU General Public License v3.0
633 stars 825 forks source link

lpthread problem in android #516

Closed Saikatsaha1996 closed 2 years ago

Saikatsaha1996 commented 3 years ago

Hello help wanted... Android OS Termux environment OpenCL found But make error If anybody can please help...

sgminer.c:7762:25: error: use of undeclared identifier 'PTHREAD_CANCEL_ASYNCHRONOUS'

make[2]: Leaving directory '/data/data/com.termux/files/home/sgminer/sph' make[2]: Entering directory '/data/data/com.termux/files/home/sgminer' fatal: No names found, cannot describe anything. CC sgminer-sgminer.o clang-12: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument] sgminer.c:282:23: warning: implicit conversion from 'unsigned long long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Wimplicit-const-int-float-conversion] double current_diff = 0xFFFFFFFFFFFFFFFFULL;


sgminer.c:3589:26: warning: passing 'const char *const *' to parameter of type 'char *const *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
  execv(initial_args[0], (EXECV_2ND_ARG_TYPE)initial_args);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/usr/include/unistd.h:96:44: note: passing argument to parameter '__argv' here
int execv(const char* __path, char* const* __argv);
                                           ^
sgminer.c:5003:3: warning: implicit declaration of function 'pthread_setcanceltype' is invalid in C99 [-Wimplicit-function-declaration]
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
  ^
sgminer.c:5003:25: error: use of undeclared identifier 'PTHREAD_CANCEL_ASYNCHRONOUS'
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
                        ^
sgminer.c:5040:3: warning: implicit declaration of function 'pthread_setcanceltype' is invalid in C99 [-Wimplicit-function-declaration]
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
  ^
sgminer.c:5040:25: error: use of undeclared identifier 'PTHREAD_CANCEL_ASYNCHRONOUS'
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
                        ^
sgminer.c:6660:3: warning: implicit declaration of function 'pthread_setcancelstate' is invalid in C99 [-Wimplicit-function-declaration]
  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
  ^
sgminer.c:6660:26: error: use of undeclared identifier 'PTHREAD_CANCEL_DISABLE'
  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
                         ^
sgminer.c:6701:30: error: use of undeclared identifier 'PTHREAD_CANCEL_ENABLE'
      pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                             ^
sgminer.c:6956:30: error: use of undeclared identifier 'PTHREAD_CANCEL_ENABLE'
      pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                             ^
sgminer.c:6972:26: error: use of undeclared identifier 'PTHREAD_CANCEL_ENABLE'
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                         ^
sgminer.c:7276:7: warning: implicit declaration of function 'pthread_setcancelstate' is invalid in C99 [-Wimplicit-function-declaration]
      pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
      ^
sgminer.c:7276:30: error: use of undeclared identifier 'PTHREAD_CANCEL_DISABLE'
      pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
                             ^
sgminer.c:7282:30: error: use of undeclared identifier 'PTHREAD_CANCEL_ENABLE'
      pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                             ^
sgminer.c:7283:7: warning: implicit declaration of function 'pthread_testcancel' is invalid in C99 [-Wimplicit-function-declaration]
      pthread_testcancel();
      ^
sgminer.c:7660:3: warning: implicit declaration of function 'pthread_setcanceltype' is invalid in C99 [-Wimplicit-function-declaration]
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
  ^
sgminer.c:7660:25: error: use of undeclared identifier 'PTHREAD_CANCEL_ASYNCHRONOUS'
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
                        ^
sgminer.c:7762:3: warning: implicit declaration of function 'pthread_setcanceltype' is invalid in C99 [-Wimplicit-function-declaration]
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
  ^
sgminer.c:7762:25: error: use of undeclared identifier 'PTHREAD_CANCEL_ASYNCHRONOUS'
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
                        ^
9 warnings and 10 errors generated.
make[2]: *** [Makefile:977: sgminer-sgminer.o] Error 1
make[2]: Leaving directory '/data/data/com.termux/files/home/sgminer'
make[1]: *** [Makefile:1580: all-recursive] Error 1
make[1]: Leaving directory '/data/data/com.termux/files/home/sgminer'
make: *** [Makefile:682: all] Error 2
Pyogenics commented 3 years ago

Android doesn't support all posix threading stuff. However there is a work around.

Include this file in files where you get pthread related errors. I trust you can do that independently.

Saikatsaha1996 commented 3 years ago

Android doesn't support all posix threading stuff. However there is a work around.

Include this file in files where you get pthread related errors. I trust you can do that independently.

Thank you I will try 😊

Saikatsaha1996 commented 2 years ago

Android doesn't support all posix threading stuff. However there is a work around.

Include this file in files where you get pthread related errors. I trust you can do that independently.

Can you guide me where I need to add this file? I already installed libbthread

Pyogenics commented 2 years ago

Include it wherever you receive pthread errors. From the error in you original message, you should include the file in sgminer.c. You may still get errors in other places.

Saikatsaha1996 commented 2 years ago

Include it wherever you receive pthread errors. From the error in you original message, you should include the file in sgminer.c. You may still get errors in other places.

Please @Pyogenics help me sir.. after add #include now i got a single error.. please help..

Screenshot_2022-05-07-00-37-00-840_com termux

Pyogenics commented 2 years ago

Try #include <pthread> in bthread.h

Saikatsaha1996 commented 2 years ago

Try #include <pthread> in bthread.h

Okay okay trying

Saikatsaha1996 commented 2 years ago

Try #include <pthread> in bthread.h

@Pyogenics WWWWoowwww nice pthread-cancel problem solved πŸ€—πŸ˜‹πŸ₯°

New error found.. but I think it is not pthread-cancel related ..

Thank you so much.. thank you soooo much for your help 😊..!.. finding solutions long time ago.. actually i don't know any programing language that's why facing problem..

I am not miner.. but trying to experiential purpose only.. Screenshot_2022-05-07-01-18-44-121_com termux

Pyogenics commented 2 years ago

I will have to look at the code, further reply will come later.

Saikatsaha1996 commented 2 years ago

I will have to look at the code, further reply will come later.

πŸ₯°πŸ₯°πŸ˜‹πŸ˜‹πŸ€—πŸ€—πŸ˜„πŸ˜„ Okay πŸ˜ƒπŸ‘ŒπŸ‘ŒπŸ‘Œ thank you sooo much!

Saikatsaha1996 commented 2 years ago

@Pyogenics this is full error codes

Screenshot_2022-05-07-01-42-11-559_com termux

Saikatsaha1996 commented 2 years ago

@Pyogenics any solution found please ? πŸ€—

Pyogenics commented 2 years ago

Sorry, had a look but it took me longer than I wanted. Will take me some time :'(

Saikatsaha1996 commented 2 years ago

Sorry, had a look but it took me longer than I wanted. Will take me some time :'(

@Pyogenics it ok.. no problem .. I am waiting.. thank you for your response, help, suggestions.. !..

Saikatsaha1996 commented 2 years ago

Sorry, had a look but it took me longer than I wanted. Will take me some time :'(

@Pyogenics any solution found sir ? 🀠☺️

Saikatsaha1996 commented 2 years ago

Sorry, had a look but it took me longer than I wanted. Will take me some time :'(

@Pyogenics any solution found sir ? 🀠☺️

@Pyogenics hello sir!.. after completing with gcc last error solved.. but getting undefined reference to `pthread_cancel'

Screenshot_2022-05-24-03-18-42-315_com termux

Saikatsaha1996 commented 2 years ago

@Pyogenics ultimately cgminer building done .. Sgminer can't build because of getting undefined reference to pthread-cancel

But sir without your help i can't.. thank you for your help cgminer working fine.. clang did not compile.. i build with gcc..

and also edited some code.. #include bthread.h && #include athread.h

include

include

define SIG_CANCEL_SIGNAL SIGUSR1

define PTHREAD_CANCEL_ENABLE 1

define PTHREAD_CANCEL_DISABLE 0

static int pthread_setcancelstate(int state, int *oldstate) { sigset_t new, old; int ret; sigemptyset (&new); sigaddset (&new, SIG_CANCEL_SIGNAL);

ret = pthread_sigmask(state == PTHREAD_CANCEL_ENABLE ? SIG_BLOCK : SIG_UNBLOCK, &new , &old);
if(oldstate != NULL)
{
    *oldstate =sigismember(&old,SIG_CANCEL_SIGNAL) == 0 ? PTHREAD_CANCEL_DISABLE : PTHREAD_CANCEL_ENABLE;
}
return ret;

}

static inline int pthread_cancel(pthread_t thread) {

pthread_kill(thread, SIG_CANCEL_SIGNAL);

}

After that build completed.. 🀠🀠❀️❀️❀️ thank you so much @Pyogenics Screenshot_2022-05-24-05-54-45-554_com termux

Saikatsaha1996 commented 2 years ago

@Pyogenics Sir My mistake i am a big idiot...πŸ₯² All problem solved with just need to install libbthread and add -lbthread flag

Now all build done sgminer also ..

Thank you .. Build done without a single error 😊 Thank you sooooo much for your big help.. ❀️❀️❀️ And thank you too libbthread @tux-mind ..

Screenshot_2022-05-25-16-09-55-618_com termux