我在Windows上使用Code :: Blocks IDE和GCC/MinGW,我正在尝试构建一个wxWidgets应用程序,其中包含ca. 20k线和40个源模块.它构建非常慢.
编译C++模块持续2-5秒,链接持续2-3分钟.
它是一个可移植的代码,这段代码在Linux上编译速度非常快.我无法按照构建消息窗口...整个过程持续不到20秒.
我尝试了常见的调整(例如,预编译头,关闭优化等),但没有任何效果.
为什么这么慢?
我在教程上看到他们--fork用作mongod的参数.但是,当我尝试这样做时,它表示未知选项--fork.那么如何--fork在Windows上进行mongodb?
我一直在关注Beej Networking指南,在服务器部分,有一部分代码叫做函数fork().
if (!fork()) { // this is the child process
close(sockfd); // child doesn't need the listener
if (send(new_fd, "Hello, world!", 13, 0) == -1)
perror("send");
close(new_fd);
exit(0);
Run Code Online (Sandbox Code Playgroud)
我在Windows机器上,不能让那部分工作.我能做些什么来解决这个问题?我的代码如下.
/* Server */
#define _WIN32_WINNT 0x501
#include <iostream>
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <sys/types.h>
using namespace std;
const int winsockVersion = 2;
#define BACKLOG 10
#define PORT "3000"
int main(void){
WSADATA wsadata;
if (WSAStartup(MAKEWORD(winsockVersion,0),&wsadata) == 0){
cout<<"-WSAStartup initialized..." << endl;
int status;
int sockfd, …Run Code Online (Sandbox Code Playgroud) 当我在Windows操作系统中的Code :: Blocks中运行代码时.我曾经得到一个名为对fork()的未定义引用的错误.我确实设置/选择GCC编译器作为我的默认编译器.
#include<stdio.h>
#include<unistd.h>
void main()
{
int x;
x = 0;
fork();
x = 1;
...
....
}
Run Code Online (Sandbox Code Playgroud)
请帮帮我告诉我,我可以在Windows环境下的Code :: Blocks中使用unix/linux程序吗?
我写了另一个程序,
main()
{
int x = 0;
if(x == 0)
{
printf("X = %d", x);
sleep(1000);//used delay also
x = 1;
printf("Now X = %d", x);;
}
}
Run Code Online (Sandbox Code Playgroud)
在这里它给eroor提供了对sleep()和/*延迟的未定义引用*/.
请帮我.
在Unix for Windows Porting Dictionary for HPC page for fork()中写了
Unix fork()或vfork()没有等效的Windows API.基于Unix的应用程序的Microsoft子系统(SUA或Interix)是一个正确实现fork()和vfork()的Unix环境.
在页面上还有一些示例源代码,它使用...标准的Win32 API CreateProcess函数.
我糊涂了.
该示例是否应该使用fork()来说明由SUA/Interix实现的fork()语句?
如果fork()真正实现了它所居住的头文件和lib文件?
这是我的第一次,我想使用Windows CreateProcess函数进行并行处理.根据MSDN上的示例,我创建了一个LPTSTR"(非常量)TCHAR字符串" 命令行参数,如下所示
LPTSTR szCmdline[] = _tcsdup(TEXT("\C:\\MyProgram_linux_1.1\\MyProgram.exe") );
Run Code Online (Sandbox Code Playgroud)
这里讨论 LPTSTR和其他char和字符串类型
命令行参数传递给CreateProcess这样
if (!CreateProcess(NULL, szCmdline, /*...*/) ) cout << "ERROR: cannot start CreateProcess" << endl;
Run Code Online (Sandbox Code Playgroud)
并且这些标题存在
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <strsafe.h>
#include <direct.h>
Run Code Online (Sandbox Code Playgroud)
在编译时这是错误:
error C3861: '_tcsdup': identifier not found
Run Code Online (Sandbox Code Playgroud)
搜索此错误发现相同的错误,但解决方案特定于使用.NET框架而不是解释error C3861: '_tcsdup'
不知道是否有关,但也有一个error C2059: syntax error : ')'上if (!CreateProcess(NULL, szCmdline, /*...*/) ) cout << "ERROR: cannot start CreateProcess" << endl;
这个错误是如何修复的?而且,这是怎么回事?
此外,我正在使用CreateProcess学习Linux …
根据手册,chdir ,如果可能的话,将工作目录更改为EXPR.
从cmd.exe执行时,此脚本:
my $path = 'C:\\some\\path\\';
print "$path\n";
chdir("$path") or die "fail $!";
Run Code Online (Sandbox Code Playgroud)
结果输出:
C:\some\path\
Run Code Online (Sandbox Code Playgroud)
但是当我返回命令提示符时 - 我仍然在原始目录中.我误解了chdir的目的吗?