468,457 Members | 1,654 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,457 developers. It's quick & easy.

make & nmake, cl & gcc

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
Nov 30 '07 #1
7 7034
Khookie wrote:
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.

--
Ian Collins.
Nov 30 '07 #2

"Khookie" <ch********@gmail.comwrote in message
news:48**********************************@s12g2000 prg.googlegroups.com...
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...).

....

Thanks in advance

Chris

Nov 30 '07 #3
Khookie wrote:
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.
Nov 30 '07 #4
Hello,

Tim Prince wrote:
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.

--
Spiro R. Trikaliotis http://opencbm.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/
Dec 1 '07 #5
On Thu, 29 Nov 2007 22:41:38 -0800 (PST), Khookie
<ch********@gmail.comwrote:
>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
Dec 2 '07 #6
On Thu, 29 Nov 2007 22:41:38 -0800 (PST), Khookie wrote:
>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.
Try a tool for cross-platform builds, e.g.

http://www.cmake.org/HTML/Index.html
http://bitwiserlabs.com/cppmake/
http://www.bakefile.org/index.html
http://www.robertnz.net/genmake.htm
--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
Dec 2 '07 #7
On Dec 2, 10:36 pm, rpbg...@yahoo.com (Roland Pibinger) wrote:
On Thu, 29 Nov 2007 22:41:38 -0800 (PST), Khookie wrote:
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.

Try a tool for cross-platform builds, e.g.

http://www.cmake.org/HTML/Index.html...et/genmake.htm

--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
Thanks everyone - nmake does seem ALOT different from the GNU make.

I've decided to move the code to mingw for the time being.

Chris
Dec 5 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

27 posts views Thread by Daniel Vallstrom | last post: by
20 posts views Thread by William | last post: by
11 posts views Thread by Jeremy | last post: by
23 posts views Thread by Hallvard B Furuseth | last post: by
1 post views Thread by subhajit12345 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.