473,387 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 7362
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.