如何在Dev-C++中写posix 的thread程序?

chgjszj 2004-11-17 10:36:03
如何在Dev-C++中写posix 的thread程序?
要下什么库,mingv32我已经装了,如何配置,谢谢~~~
...全文
195 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
chgjszj 2004-11-18
  • 打赏
  • 举报
回复
没明白,能不能写个教程?
sharkhuang 2004-11-18
  • 打赏
  • 举报
回复
WinAPI.dev-c++的编译器是for win32的
Jinhao 2004-11-18
  • 打赏
  • 举报
回复
自己把Win API封装成POSIX Thread的同名接口,然后用宏来定义平台,搞定
SimIt-ARM-3.0 给予命令行ARM指令模拟器,短小精悍,是研究ARM处理器的好工具,该模拟器既可以运行用户级别的ELF程序,又可以模拟运行Linux操作系统;提供了简单易用的调试命令,可以逐条跟踪指令的执行。 SimIt-ARM-3.0-gk-20150902.tar.bz2 HowTo 0.what is SimIt-ARM-3.0 SimIt-ARM 3.0 is an instruction-set simulator that runs both system-level and user-level ARM programs, for more about it please read user's guide file. 1.how to build tar jxvf SimIt-ARM-3.0-gk-20150902.tar.bz2 cd SimIt-ARM-3.0-gk ./configure make make install After these steps, the ./build/bindirectory contains the following programs: ema An ARM interpreter. To test the installation was successful type ./build/bin/ema test/wc configure modifiy PATH environment variable: PATH=$PATH:$HOME/SimIt-ARM-3.0-gk/build/bin ; export PATH 2. how to use 2.1 run user-level ARM programs [root@ORA9 SimIt-ARM-3.0-gk]# cd gcc-asm [root@ORA9 gcc-asm]# more hello.c /* * hello.c * Tue Sep 8 10:13:40 CST 2015 */ int main() { printf("hello world\n"); __asm("mov r0,#2\n\t" "swi 0x1\n\t"); // syscall: exit(2); } [root@ORA9 gcc-asm]# arm-linux-gcc -v Reading specs from /usr/local/arm/3.4.1/bin/../lib/gcc/arm-linux/3.4.1/specs Configured with: /opt/crosstool/crosstool-0.28/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2 --with-float=soft --with-headers=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2/arm-linux/include --with-local-prefix=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long Thread model: posix gcc version 3.4.1 [root@ORA9 gcc-asm]# arm-linux-gcc hello.c -o hello -static [root@ORA9 gcc-asm]# ls -l hello* -rwxr-xr-x 1 root root 520775 Sep 8 10:18 hello -rw-r--r-- 1 root root 160 Sep 8 10:15 hello.c [root@ORA9 gcc-asm]# file hello hello: ELF 32-bit LSB executable, ARM, vers
sogou_toolchain.tar.gz 全志R16平台的tinav2.1平台的编译工具链 UNICODE全志tinav2.1的编译工具链的设置.txt 我的编译方法: 1、复制内核工具链到家目录R:\sogou\toolchain rootroot@rootroot-E400:~$ rootroot@rootroot-E400:~$ cd wyb/r16_tinav2.1/ rootroot@rootroot-E400:~/wyb/r16_tinav2.1$ cd prebuilt/gcc/linux-x86/arm/toolchain-sunxi/ rootroot@rootroot-E400:~/wyb/r16_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$ cp toolchain/ ~/sogou/ -r rootroot@rootroot-E400:~/wyb/r16_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$ tar zcvf toolchain.tar.gz toolchain/ rootroot@rootroot-E400:~/wyb/r16_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$ cp toolchain.tar.gz ~/sogou/ rootroot@rootroot-E400:~/wyb/r16_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$ cd ~/sogou/ rootroot@rootroot-E400:~/sogou$ tar zxvf toolchain.tar.gz 2、添加环境变量,在/etc/profile最后一行添加如下一句(需要root权限): export PATH="$PATH:/home/rootroot/sogou/toolchain/bin" export STAGING_DIR="$PATH:/home/rootroot/sogou/toolchain" .bashrc的最后输入: export PATH="$PATH:/home/rootroot/sogou/toolchain/bin" export STAGING_DIR="$PATH:/home/rootroot/sogou/toolchain" 3、输入arm-openwrt-linux-gcc -v检查是否可用(确认环境变量是否配置正确) rootroot@rootroot-E400:~/sogou$ arm-openwrt-linux-gcc -v Reading specs from /home/rootroot/sogou/toolchain/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.2.0/specs COLLECT_GCC=arm-openwrt-linux-muslgnueabi-gcc.bin COLLECT_LTO_WRAPPER=/home/rootroot/sogou/toolchain/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/5.2.0/lto-wrapper Target: arm-openwrt-linux-muslgnueabi Configured with: /home/caiyongheng/tina_test/out/azalea-perf3/compile_dir/toolchain/gcc-5.2.0/configure --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 5.2.0 70-1-1' --prefix=/home/caiyongheng/tina_test/out/azalea-perf3/staging_dir/toolchain --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-openwrt-linux-muslgnueabi --with-gnu-ld --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-multilib --disable-nls --without-isl --without-cloog --with-host-libstdcxx=-lstdc++ --with-gmp=/home/caiyongheng/tina_test/out/host --with-mpfr=/home/caiyongheng/tina_test/out/host --with-mpc=/home/caiyongheng/tina_test/out/host --disable-decimal-float --with-diagnostics-color=auto-if-env --disable-libssp --enable-__cxa_atexit --with-arch=armv7-a --with-float=hard --with-headers=/home/caiyongheng/tina_test/out/azalea-perf3/staging_dir/toolchain/include --disable-libsanitizer --enable-languages=c,c++ --enable-shared --enable-threads --with-slibdir=/home/caiyongheng/tina_test/out/azalea-perf3/staging_dir/toolchain/lib --enable-lto --with-libelf=/home/caiyongheng/tina_test/out/host Thread model: posix gcc version 5.2.0 (OpenWrt GCC 5.2.0 70-1-1) rootroot@rootroot-E400:~/sogou$ 4、创建工程目录record,在其中创建include、obj、lib、doc目录 5、所需的alsa头文件在R:\wyb\r16_tinav2.1\package\allwinner\liballwinner\LIBRARY\EXTERNAL\include\alsa,将其复制到工程目录中的include中 rootroot@rootroot-E400:~$ cd wyb/r16_tinav2.1/ rootroot@rootroot-E400:~/wyb/r16_tinav2.1$ cd package/allwinner/liballwinner/LIBRARY/EXTERNAL/include/ rootroot@rootroot-E400:~/wyb/r16_tinav2.1/package/allwinner/liballwinner/LIBRARY/EXTERNAL/include$ cp alsa/ ~/sogou/record/include/ -r rootroot@rootroot-E400:~/wyb/r16_tinav2.1/package/allwinner/liballwinner/LIBRARY/EXTERNAL/include$ 6、所需的so文件是R:\wyb\r16_tinav2.1\out\astar-parrot\staging_dir\target\usr\lib\libasound.so.2.0.0,将其复制到lib中,并改名为libasound.so 7、编辑record.c和Makefile Makefile文件的内容: CC=arm-openwrt-linux-g++ #CC=g++ DIR_OBJ=./obj DIR_INCLUDE=./include OBJ=record.o record:$(OBJ) $(CC) $(DIR_OBJ)/* -L./lib -lasound -o $@ %.o:%.c $(CC) -c $< -I$(DIR_INCLUDE) -o $(DIR_OBJ)/$@ clean: rm -f record $(DIR_OBJ)/* 8、 make clean make rootroot@rootroot-E400:~/sogou/record$ make clean rm -f record ./obj/* rootroot@rootroot-E400:~/sogou/record$ make arm-openwrt-linux-g++ -c record.c -I./include -o ./obj/record.o In file included from ./include/alsa/asoundlib.h:32:0, from record.c:13: /home/rootroot/sogou/toolchain/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include to [-Wcpp] #warning redirecting incorrect #include to ^ In file included from ./include/alsa/ctl_macros.h:13:0, from ./include/alsa/control.h:54, from ./include/alsa/asoundlib.h:47, from record.c:13: /home/rootroot/sogou/toolchain/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include to [-Wcpp] #warning redirecting incorrect #include to ^ In file included from ./include/alsa/pcm_macros.h:13:0, from ./include/alsa/pcm.h:116, from ./include/alsa/asoundlib.h:48, from record.c:13: /home/rootroot/sogou/toolchain/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include to [-Wcpp] #warning redirecting incorrect #include to ^ In file included from ./include/alsa/hctl_macros.h:13:0, from ./include/alsa/hcontrol.h:36, from ./include/alsa/mixer.h:25, from ./include/alsa/asoundlib.h:49, from record.c:13: /home/rootroot/sogou/toolchain/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include to [-Wcpp] #warning redirecting incorrect #include to ^ In file included from ./include/alsa/mixer_macros.h:13:0, from ./include/alsa/mixer.h:72, from ./include/alsa/asoundlib.h:49, from record.c:13: /home/rootroot/sogou/toolchain/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include to [-Wcpp] #warning redirecting incorrect #include to ^ In file included from record.c:17:0: /home/rootroot/sogou/toolchain/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include to [-Wcpp] #warning redirecting incorrect #include to ^ arm-openwrt-linux-g++ ./obj/* -L./lib -lasound -o record rootroot@rootroot-E400:~/sogou/record$

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧