Cel*_*tas 3 c windows pthreads codeblocks
在尝试编译包含pthreads的代码时,我遇到了诸如下面提到的错误
warning: return type defaults to 'int' [-Wreturn-type]|
|In function 'print_message_function':|
warning: control reaches end of non-void function [-Wreturn-type]|
| undefined reference to `_imp__pthread_create'|
| undefined reference to `_imp__pthread_create'|
| undefined reference to `_imp__pthread_join'|
| undefined reference to `_imp__pthread_join'|
Run Code Online (Sandbox Code Playgroud)
我在Windows 7上运行GCC,但我安装了mingw.我正在使用IDE Code :: Blocks并选择"编译当前文件".这是链接器设置的屏幕截图,我在这里不知所措

更新:我添加-pthread到"其他链接器选项",它更好地工作.还有问题.当我编译它说
|In function 'print_message_function':|
warning: control reaches end of non-void function [-Wreturn-type]|
Run Code Online (Sandbox Code Playgroud)
当我去运行CodeBlocks说"看起来程序尚未构建",当我点击"build"时,我显示此错误
mingw32-g++.exe -o "SimpleExample.exe" "SimpleExample.o" -static-libgcc -static-libstdc++ -pthread
mingw32-g++.exe: error: unrecognized option '-pthread'
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 1 warnings (0 minutes, 0 seconds)
Run Code Online (Sandbox Code Playgroud)
我该如何解决?我想在Windows上构建/测试,但程序在Unix环境下运行.在IDE中编译和构建有什么区别?
小智 7
这个答案来得晚,但......它对我有用,所以我决定分享它.
希望这可以提供帮助.
| 归档时间: |
|
| 查看次数: |
15581 次 |
| 最近记录: |