简体   繁体   中英

Premature end of script headers: CGI + C++

I can't even get a simple test program working with CGI. Here's my code. It works when I run it in the console, but gives the error when I try to run from Apache:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

int main() {
    printf("Content-type: text/html\n\n");
    printf("TEST");
    return 0;
}

MakeFile:

build: source/main.cpp
    C:/MinGW/bin/g++.exe -o build/e2.exe source/main.cpp

Error:

[Thu Mar 22 19:14:23 2012] [error] [client 127.0.0.1] Premature end of script headers: e2.exe

Run in command prompt:

C:\Users\Stephen>C:\wamp\www\e2.exe
Content-type: text/html

TEST

Any help would be greatly appreciated! Thanks!

Solved: Makefile:

build: source/main.cpp
    C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp

Solved: Makefile:

build: source/main.cpp
    C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp

GCC not G++

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM