472,977 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 software developers and data experts.

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 7334
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get...
20
by: William | last post by:
Original question: "Give a one-line C expression to test whether a number is a power of 2. " Answer: if (x && !(x & (x-1)) == 0) My question: Why does this expression work?
6
by: Rich | last post by:
Hello, I have to create a table in an Access mdb (remotely) on the fly. Create Table tbl1(fld1 Integer, fld2 varchar(10), fld3...) Then I have to insert data: Insert Into tbl1 Values(" &...
11
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
42
by: coder_lol | last post by:
Thanks everyone again for contributing to helping me clear C++ confusions. I did some serious reading on copy constructors and assignments and I think I've got a good handle on the memory stuff. ...
23
by: Hallvard B Furuseth | last post by:
As far as I can tell, (x & -1) is nonzero if the integer x is negative zero. So for signed types, x == 0 does not guarantee (x & foo) == 0. Is that right? (Not that I expect to ever encounter a...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.