[关闭]
@zhongdao 2020-08-14T16:40:52.000000Z 字数 4523 阅读 1481

gcc程序在windows上的编译

未分类


目标

在windows2016 64bit, window2008 64bit, windows7 32,64bit上分别运行ctorrent程序和ctapi,ctcs 让Java的TMS可以正常调用p2p的传输功能。

makifile 基本说明

使用Makefile控制编译
https://tutorial.linux.doc.embedfire.com/zh_CN/latest/linux_app/makefile.html
简单谈谈Makefile和交叉编译工具链
https://blog.csdn.net/czg13548930186/article/details/73029468

make程序会根据Makefile中描述的目标与依赖关系,执行达成目标需要的shell命令。简单来说,Makefile就是用来指导make程序如何干某些事情的清单。

预处理(preprocessing)->编译(compilation)->汇编(assembly)->连接(linking)
编译:.c->.s 汇编:.s->.o 连接:多个.o合并成一个可执行文件。
在平常通过将上述四步统称为“编译”

Makefile中跟目标相关的语法:
要特别注意命令的开头要用“Tab”键,不能 使用空格代替

  1. #Makefile格式
  2. #目标:依赖
  3. #Tab 命令1
  4. #Tab 命令2
  5. [目标1]:[依赖]
  6. [命令1]
  7. [命令2]
  8. [目标2]:[依赖]
  9. [命令1]
  10. [命令2]

交叉编译

linux平台交叉编译Windows 程序
https://blog.csdn.net/zuihaobushi/article/details/90167362

  1. i686-w64-mingw32-gcc -o hello.exe hello.c
  2. i686-w64-mingw32-gcc -o hello.exe hello.c -m64

windows下的gcc编译器

GCC编译器,适用于Windows。

https://jmeubank.github.io/tdm-gcc/articles/2020-03/9.2.0-release

vscode 如何设置c++编译

mingGW-w64

image_1efeaghke8j913mupq9vlb14ih13.png-63.6kB

cygwin

Download Cygwin1.dll for Windows 10, 8.1, 8, 7, Vista and XP (32 Bit and 64 Bit)
http://www.dlldownloader.com/cygwin1-dll/

https://cygwin.com/install.html

按照category选择安装。
image_1efea2f12g02hp81mpp8jv1i71m.png-191.2kB

如何使Linux命令和脚本在Cygwin上运行?

Let me clarify terminology first.

Linux = operating system kernel
Linux distribution = Linux kernel + user-space utilities (bash, ifconfig etc.)
Windows = NT kernel + user-space utilities
Cygwin = user-space utilities
Because of fundamental differences between NT and Linux kernels you cannot count with your scripts working unmodified on Windows. Some things, which are less specific for OS kernel, work mostly the same way, and Bash is one of them. On the other hand, ifconfig is quite OS-specific and is a part of net-tools project, which hasn't been updated since 2001 and is deprecated since 2004. I believe, there is a cygwin version of ifconfig, and even though it most likely would not work to update configuration, it should work fine to print it. Bryan C. has pointed out how to make sure it is installed.

As for your second question, extension doesn't matter as long as you start your scripts from Bash (it relies on execute permission and shebang line). However, if you want to start them from outside Bash, you'd better make them end with .sh (see this answer for details).

安装apt-cyg
https://blog.csdn.net/lee244868149/article/details/52830968/

Cygwin64 Terminal 类linux开发环境打造之packages安装
https://www.cnblogs.com/hnhycnlc888/p/13026307.html

在Windows上的Cygwin64下构建linux交叉编译工具链

https://developer.moe/linux-cross-compile-toolchain-on-cygwin

Run Cygwin script on shutdown or startup

https://stackoverrun.com/cn/q/10580184

windows server 自启动

windows server 添加开启自启动 不用登录用户自启设置步骤
https://www.cnblogs.com/m0488/p/12083361.html

  1. mintty -e bash --login -c 'PATH=/usr/bin:${PATH}; nohup ~/soft/bftgroup.exe &; nohup ~/soft/ctcs2run.sh 11875 12500 >/dev/null 2>&1 &'
  1. mintty -e bash --login -c 'PATH=/usr/bin:${PATH}; source /etc/rc.local'

下面测试通过:

  1. mintty.exe -D -h always /bin/bash --login -c "source /etc/profile; /usr/bin/nohup /home/junli/soft/ctapi.pl & /usr/bin/nohup /home/junli/soft/ctcs2run.sh 11875 12500 >/dev/null 2>&1 & ~/soft/bftgroup.exe & /usr/bin/procps -ef; "
  1. mintty.exe -D -h always /bin/bash --login -c "source /etc/profile; /usr/bin/nohup ~/soft/ctapi.pl & /usr/bin/nohup ~/soft/ctcs2run.sh 11875 12500 >/dev/null 2>&1 & ~/soft/bftgroup.exe & /usr/bin/procps -ef; "

测试通过:
startup.bat

  1. @echo off
  2. d:
  3. chdir d:\cygwin64\bin
  4. mintty.exe -h always /bin/bash --login -c "source /etc/profile; /usr/bin/nohup ~/soft/ctapi.pl & /usr/bin/nohup ~/soft/ctcs2run.sh 11875 12500 >/dev/null 2>&1 & ~/soft/bftgroup.exe & /usr/bin/procps -ef; " -

测试通过: (必须 /home/junli/ )

  1. @echo off
  2. d:
  3. chdir d:\cygwin64\bin
  4. mintty.exe -e /bin/bash --login -c "source /etc/profile; /usr/bin/nohup /home/junli/soft/ctapi.pl & /usr/bin/nohup /home/junli/soft/ctcs2run.sh 11875 12500 >/dev/null 2>&1 & /home/junli/soft/bftgroup.exe & /usr/bin/procps -ef; bash -i"

最终机器启动测试通过的脚本:
startup.bat

  1. @echo off
  2. d:
  3. chdir d:\cygwin64\bin
  4. mintty.exe -e /bin/bash --login -c "source /etc/profile; nohup /home/junli/soft/ctapi.pl >/dev/null 2>&1 & nohup /home/junli/soft/ctcs2run.sh 11875 12500 >/dev/null 2>&1 & /home/junli/soft/bftgroup.exe & /usr/bin/procps -ef; bash -i"

windows休眠对程序影响

https://zhuanlan.zhihu.com/p/47006051

Windows 电脑的四种运行状态 ==
这四种运行状态(或称电源状态)是:

工作状态 (Working), S0
睡眠状态 (Sleep), S1 或 S3
休眠状态 (Hibernate), S4
关机状态 (Shutdown), S5

Windows 10 无视电源设置自动进入睡眠
https://answers.microsoft.com/zh-hans/windows/forum/all/windows-10/428670ca-f494-48fa-8c1e-609580cc4789

wsl on windows

https://docs.microsoft.com/en-us/windows/wsl/install-win10

sudo cpan JSON

widows常用命令与开发知识

查找所有运行端口。
netstat -ano

netstat -aon|findstr "8081"

查看指定 PID 的进程
tasklist|findstr "2780"
结束进程
taskkill /T /F /PID 9088

替换为其他兼容windows的bittorent客户端。

本机测试记录

image_1efdq1ej71ol7119d1hdhv5gc3h9.png-173.8kB

cygwin里 ctorrent的下载速度

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注