Windows/UNIX compatibility problem with C++ via CGI

D

Der Andere

I need to run a C++ program via the CGI. I write and test the programs on a
Windows machine, but as the server runs on Sun OS I cannot compile the files
on my machine. Compiling on the server does work only in very simple cases.
Most gcc compiler errors (there are quite a lot) start with "undefined
reference". How can I supply the necessary libraries (as this seems to be
the problem)?
In order to compile I used gcc -o executable sourcefile.cpp
I have the following includes in my program:

#include <iostream>
#include <cmath>
#include <limits>
#include <cassert>
#include <iomanip>
#include <string>
#include <fstream>
#include <queue>

#include <cstdio>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>

using namespace std;

#include "dijkstra.h"
#include "cgi.inc"

Thanks,
Matthias
 
A

Alan Johnson

Der said:
I need to run a C++ program via the CGI. I write and test the programs on a
Windows machine, but as the server runs on Sun OS I cannot compile the files
on my machine. Compiling on the server does work only in very simple cases.
Most gcc compiler errors (there are quite a lot) start with "undefined

You mention gcc, which makes me wonder if you are refering to gcc as the
collection of compilers, or if you are specifically using "gcc" the C
compiler. If the latter is true, use "g++" instead.
reference". How can I supply the necessary libraries (as this seems to be
the problem)?
In order to compile I used gcc -o executable sourcefile.cpp
I have the following includes in my program:

#include <iostream>
#include <cmath>

I seem to remember something about g++ not linking math libraries by
default in some versions, or something like that. I may be making this
up. Perhaps look into this after you've tried everything else.
#include <limits>
#include <cassert>
#include <iomanip>
#include <string>
#include <fstream>
#include <queue>

#include <cstdio>
#include <cstring>
#include <string.h>

string.h is redundant with cstring, and is likely to cause errors in
some implementations.
#include <stdlib.h>

Use said:
#include <malloc.h>

This isn't in the standard. std::malloc is declared in said:
using namespace std;

#include "dijkstra.h"
#include "cgi.inc"

Make sure that the accompanying source defining anything that is
declared in here is also getting compiled and linked.
Thanks,
Matthias

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top