make & nmake, cl & gcc

Discussion in 'C Programming' started by Khookie, Nov 30, 2007.

  1. Khookie

    Khookie Guest

    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
    Khookie, Nov 30, 2007
    #1
    1. Advertising

  2. Khookie

    Ian Collins Guest

    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.
    Ian Collins, Nov 30, 2007
    #2
    1. Advertising

  3. Khookie

    cr88192 Guest

    "Khookie" <> wrote in message
    news:...
    > 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
    cr88192, Nov 30, 2007
    #3
  4. Khookie

    Tim Prince Guest

    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.
    Tim Prince, Nov 30, 2007
    #4
  5. 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/
    Spiro Trikaliotis, Dec 1, 2007
    #5
  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.
    >
    >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
    Barry Schwarz, Dec 2, 2007
    #6
  7. 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
    Roland Pibinger, Dec 2, 2007
    #7
  8. Khookie

    Khookie Guest

    On Dec 2, 10:36 pm, (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.htm...index.htmlhttp://www.robertnz.net/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
    Khookie, Dec 5, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bagsmode

    nmake--installing modules

    bagsmode, Jul 25, 2003, in forum: Perl
    Replies:
    2
    Views:
    3,752
    bagsmode
    Jul 27, 2003
  2. Rick

    nmake question ...

    Rick, May 3, 2004, in forum: C++
    Replies:
    3
    Views:
    548
    Thomas Matthews
    May 4, 2004
  3. bauerwo
    Replies:
    0
    Views:
    320
    bauerwo
    Jul 13, 2004
  4. NMAKE FATAL ERROR U1073

    , Feb 14, 2006, in forum: C Programming
    Replies:
    3
    Views:
    725
    Tim Prince
    Feb 14, 2006
  5. Replies:
    1
    Views:
    1,430
    Ian Collins
    Jun 20, 2007
Loading...

Share This Page