pthread-win32 issue , cmake, -1073741515 (0xC0000135)

293 Views Asked by At

I am trying to use pthread win-32 on windows, I created a sample application to test the pthread library but the program is working not properly, it is exciting with a minus error code. I am using MSVC for compiling, and cmake for building the project.

Error that I am getting: Process finished with exit code -1073741515 (0xC0000135)

program code :

#include <stdio.h>
#include <stdlib.h>

#include <windows.h>
#define HAVE_STRUCT_TIMESPEC
#include <pthread.h>

void *myThreadFun(void *vargp)
{
    Sleep(1);
    printf("Printing GeeksQuiz from Thread \n");
    return NULL;
}

int main()
{
    pthread_t thread_id;
    printf("Before Thread\n");
    pthread_create(&thread_id, NULL, myThreadFun, NULL);
    pthread_join(thread_id, NULL);
    printf("After Thread\n");
    exit(0);


}

cmakeList :

cmake_minimum_required(VERSION 3.17)
project(untitled6)

set(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_FLAGS -pthread)
set(THREADS_PREFER_PTHREAD_FLAG ON)
include_directories("C:/Users/Tharindu/Downloads/pthrad/Pre-built.2/include")

add_executable(untitled6 main.cpp)
target_link_libraries(untitled6 C:/Users/Tharindu/Downloads/pthrad/Pre-built.2/lib/pthreadVC2.lib)

C:/Users/Tharindu/Downloads/pthrad/Pre-built.2/include directory inclides the pthread.h , sched.h and semaphore.h

Can someone help me to fix this issue?

Thank you

0

There are 0 best solutions below