make & nmake, cl & gcc

K

Khookie

I'm required to write an app that can compile on both Windows (cl/
nmake) & Linux (gcc/make) targets, so I was wondering whether anyone
has any guidelines on how to do it properly.

Even pointing me to existing projects on the net would be very
helpful.

Thanks in advance

Chris
 
I

Ian Collins

Khookie said:
I'm required to write an app that can compile on both Windows (cl/
nmake) & Linux (gcc/make) targets, so I was wondering whether anyone
has any guidelines on how to do it properly.

Even pointing me to existing projects on the net would be very
helpful.
The stock advice is to stick to standard C where possible and isolate
any platform dependent code it its own modules. Where you have to
interface with the OS, look for a cross platform library if you can.
 
C

cr88192

Khookie said:
I'm required to write an app that can compile on both Windows (cl/
nmake) & Linux (gcc/make) targets, so I was wondering whether anyone
has any guidelines on how to do it properly.

Even pointing me to existing projects on the net would be very
helpful.

beyond separating code into OS dependent and independent parts, be sure to
make Makefile's for the respective targets.

ideally, one makes the OS independent bits as general as possible, with the
OS dependent parts following a hopefully uniform interface. my personal
advice is to avoid relying too heavily on libraries, as many libraries will
tend to exist on one arch but not on others, ...


I will recommend staying well clear of the autoconf/configure horror so
popular on linux.

cmake may be useful here (I have heard some good things about this at least,
but have not used it personally...).

....
 
T

Tim Prince

Khookie said:
I'm required to write an app that can compile on both Windows (cl/
nmake) & Linux (gcc/make) targets, so I was wondering whether anyone
has any guidelines on how to do it properly.

I'd continue the traditional way, just supply a (gnu) Makefile for each
compiler. nmake is pointless, as support for it was cut way back on
current Windows systems. A Makefile I set up yesterday starts out
CCIFLAGS = -O3 -Qrestrict -Qopenmp -Qopenmp-lib:compat -Qansi_alias -QxW
CCMFLAGS = /Ox /EHsc /GL- /Drestrict= /favor:EM64T /openmp
CXXM = cl
CXXI = icl
CCM = cl
CCI = icl
FC = ifort
..SUFFIXES: .obj
...

If you don't need to support 2 brands of C in the same Makefile, or you
have a smarter method, it can be a lot cleaner.
By the way, the gcc/g++/gfortran Makefile works for all of Windows-32
and linux32/64.
 
S

Spiro Trikaliotis

Hello,

Tim said:
nmake is pointless, as support for it was cut way back on
current Windows systems.

While OT, this is not (completely) true. If you are writing device
drivers, the only supported way is to use the DDK (WDK) compiler and
build system. The build system uses build.exe, which is built around
nmake.exe.

But, as already said, this is OT here.

Regards,
Spiro.
 
B

Barry Schwarz

I'm required to write an app that can compile on both Windows (cl/
nmake) & Linux (gcc/make) targets, so I was wondering whether anyone
has any guidelines on how to do it properly.

Even pointing me to existing projects on the net would be very
helpful.

Use only standard features of the language. Assume nothing about the
underlying structure (such as little- or big-endian, sizeof(int) etc).
Invoke the compilers in their "no extension" or "strictly conforming"
modes.


Remove del for email
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top