#include<iostream>
#include<unistd.h>
#include<pthread.h>
using namespace std;
void *thread(void *ptr){
for(int i=0;i<3;i++){
sleep(1);
cout<<"This is a pthread"<<endl;
}
return 0;
}
int main(){
pthread_t id;
int ret=pthread_create(&id,NULL,thread,NULL);
if(ret){
cout<<"create pthread error"<<endl;
return 1;
}
for(int i=0;i<3;i++){
cout<<"This is main process"<<endl;
sleep(1);
}
pthread_join(id,NULL);
return 0;
}
代码其实也不复杂,编译器给出的错误提示是这样的
makefile:45: recipe for target 'oj' failed
make: *** [oj] Error 1
网上搜索了一下,都是关于makefile文件的解决方法,也看的不是很懂,对于eclipse下自动生成的makefile文件不知道该怎么办,有大神知道是哪里出了问题吗。。。跪求
makefile文件也贴一下好了。。自动生成的可以不用看
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: oj
# Tool invocations
oj: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
g++ -o "oj" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(CPP_DEPS)$(C_DEPS) oj
-@echo ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets
@echo 'Building target: $@' // 编译器提示这一句出错了
2 个解决方案
#1
求助。。。顶一下
#2
已解决。。。。是动态链接库的问题。。。。eclipse
解决方法如下:
Project->Properties->C/C++ Build->Settings->GCC C++ Linker->Libraries
在Libraries(-l)中添加pthread即可
在Libraries search path(-L)中添加crypto即可
解决方法如下:
Project->Properties->C/C++ Build->Settings->GCC C++ Linker->Libraries
在Libraries(-l)中添加pthread即可
在Libraries search path(-L)中添加crypto即可
#1
求助。。。顶一下
#2
已解决。。。。是动态链接库的问题。。。。eclipse
解决方法如下:
Project->Properties->C/C++ Build->Settings->GCC C++ Linker->Libraries
在Libraries(-l)中添加pthread即可
在Libraries search path(-L)中添加crypto即可
解决方法如下:
Project->Properties->C/C++ Build->Settings->GCC C++ Linker->Libraries
在Libraries(-l)中添加pthread即可
在Libraries search path(-L)中添加crypto即可