Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm-none-gnueabi-gcc does not support threading #58

Open
amikhail48 opened this issue Dec 12, 2024 · 1 comment
Open

arm-none-gnueabi-gcc does not support threading #58

amikhail48 opened this issue Dec 12, 2024 · 1 comment

Comments

@amikhail48
Copy link

amikhail48 commented Dec 12, 2024

Example program:

#include "pthread.h" 
#include "stdio.h"
#include "stdlib.h"

void *worker_thread(void *arg) 
{ 
    printf("This is worker_thread()\n"); 
    pthread_exit(NULL); 
} 

int main() 
{ 
    pthread_t my_thread; 
    int ret; 
    printf("In main: creating thread\n"); 
    ret = pthread_create(&my_thread, NULL, &worker_thread, NULL); 
    if(ret != 0) 
    {
        printf("Error: pthread_create() failed\n"); 
        exit(EXIT_FAILURE); 
    } 
    pthread_exit(NULL); 
}

Compilation error:

pthread.c: In function 'void* worker_thread(void*)':

pthread.c:8:18: error: 'pthread_exit' was not declared in this scope
pthread_exit(NULL);
                  ^
pthread.c: In function 'int main()':
pthread.c:15:1: error: 'pthread_t' was not declared in this scope
 pthread_t my_thread;
 ^
pthread.c:15:11: error: expected ';' before 'my_thread'
 pthread_t my_thread;
           ^
pthread.c:18:23: error: 'my_thread' was not declared in this scope
 ret = pthread_create(&my_thread, NULL, &worker_thread, NULL);
                       ^
pthread.c:18:60: error: 'pthread_create' was not declared in this scope
 ret = pthread_create(&my_thread, NULL, &worker_thread, NULL);
                                                            ^
pthread.c:24:21: error: 'pthread_exit' was not declared in this scope
  } pthread_exit(NULL);
@hexdae
Copy link
Owner

hexdae commented Dec 17, 2024

Hey @amikhail48, I think the phtread libraries are not available for embedded implementations of libc. You might need to link a platform specific implementation for this to work, similar to the dynamic memory allocation options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants