0

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

Ðаn
  • 10,934
  • 11
  • 59
  • 95
  • 1
    Some dll is not found – JCWasmx86 Apr 01 '21 at 11:20
  • Can you tell me how to connect dll CMake , I tired this , `target_link_libraries(FlexibleComputerLanguage1 C:/Users/Tharindu/Downloads/pthrad/Pre-built.2/lib/pthreadVC2.dll) ` but it gives me some errors , `target_link_libraries(FlexibleComputerLanguage1 C:/Users/Tharindu/Downloads/pthrad/Pre-built.2/lib/pthreadVC2.dll) ` – Tharindu Balasuriya Apr 01 '21 at 12:43
  • 2
    You need to copy the dll next to the executable before starting it. – Corristo Apr 01 '21 at 17:28
  • @Corristo That depends if you are building a shared build or static build of course :) – Melroy van den Berg Dec 26 '21 at 22:44

0 Answers0