Help: Write makefile in QNX 6.2

I am used to program with Watcom C++ 10.6 under QNX 4, and I am going to
migrating the program to QNX 6 now. But I don’t know how to write the
file “makefile” for my program if the main file includes some other
classe files. The file “makefile” in QNX 4.2 is:

test:test.o sfile1.o sfile2.o sfile3.o
cc -T1 test.o sfile1.o sfile2.o sfile3.o -o test

test.o: test.cpp
cc -c test.cpp

sfile1.0: sfile1.cpp
cc -c sfile1.cpp

sfile2.o: sfile2.cpp
cc -c sfile2.cpp

Lily wrote:

I am used to program with Watcom C++ 10.6 under QNX 4, and I am going to
migrating the program to QNX 6 now. But I don’t know how to write the
file “makefile” for my program if the main file includes some other
classe files. The file “makefile” in QNX 4.2 is:

test:test.o sfile1.o sfile2.o sfile3.o
cc -T1 test.o sfile1.o sfile2.o sfile3.o -o test

I would use something like the following. Note that ‘make’ knows how to
turn C files into o files so you don’t need a rule for each source file

  • ‘make’ will use CFLAGS as the compile options for that. Replace
    path/to/files with your include path. Note that the -g option might
    provoke some extra warnings if you have been compiling without it in the
    past. You should aim for no warnings I think :slight_smile:

all: test
SRCS = test.cpp sfile1.cpp sfile2.cpp sfile3.cpp
OBJS = $(SRCS:.cpp=.o)
INCLUDE = -Ipath/to/files
CFLAGS = -Wall -g $(INCLUDE)

test: $(OBJS)
$(CC) -o $@ $(OBJS)


You might also add a ‘clean’ target to remove unwanted files:

clean:
-$(RM) *.o *~ $(OBJS) $(TARGETS) a.out *.bak *.BAK *core

Regards
William Morris

William Morris wrote:

path/to/files with your include path. Note that the -g option might
provoke some extra warnings if you have been compiling without it in the
past. You should aim for no warnings I think > :slight_smile:

Sorry, I meant the -Wall option. -g is for placing debugger
symbols in the objects
William

If you’re writing in C++, invoking the compiler
is non-trivial.

You can’t use “gcc -g” under QNX 6.20NC, it’s broken.
See the previous thread about linker hangs. New style
debugger symbols ("-gstabs") seem to work better.
Also, “gcc” doesn’t turn on C++ exception handling
by default.

“QCC -Vgcc_ntox86 -gstabs -Wall” seems to work.

You have to link with QCC, too. “gcc” and “ld”
don’t know where some of the C++ libraries are.

But you can’t use QCC to build dependencies for a
makefile; “-M” isn’t supported. For that, you have
to use “gcc”.

The “warnings as errors” option isn’t available
under QCC, incidentally.

So you have to work around these known bugs.

John Nagle
Animats

William Morris wrote:


path/to/files with your include path. Note that the -g option might
provoke some extra warnings if you have been compiling without it in the
past. You should aim for no warnings I think > :slight_smile:


Sorry, I meant the -Wall option. -g is for placing debugger
symbols in the objects
William

The “warnings as errors” option isn’t available
under QCC, incidentally.

Sure it is. We use it all the time.

QCC -Wc,-Werror …

Rob Rutherford

You can use a comma between command line arguments to QCC?
That’s not documented. See

http://www.qnx.com/developer/docs/qnx_6.1_docs/neutrino/utilities/q/qcc.html

Using the compiler shouldn’t require so much oral tradition.
Could we have an update of the QCC manual page?

John Nagle
Animats

Robert Rutherford wrote:

The “warnings as errors” option isn’t available
under QCC, incidentally.


Sure it is. We use it all the time.

QCC -Wc,-Werror …

Rob Rutherford

The -Wc,-Werror is not two arguments. It is one argument.

The leading -W says “pass the following argument to”
The ‘c’ in -Wc says “to the compiler”
The argument to pass to the compiler is seperated by a comma
and that arguemnt is -Werror.


John Nagle <nagle@downside.com> wrote:

You can use a comma between command line arguments to QCC?
That’s not documented. See

http://www.qnx.com/developer/docs/qnx_6.1_docs/neutrino/utilities/q/qcc.html

Using the compiler shouldn’t require so much oral tradition.
Could we have an update of the QCC manual page?

John Nagle
Animats

Robert Rutherford wrote:
The “warnings as errors” option isn’t available
under QCC, incidentally.


Sure it is. We use it all the time.

QCC -Wc,-Werror …

Rob Rutherford

Bill Caroselli <qtps@earthlink.net> wrote:

The -Wc,-Werror is not two arguments. It is one argument.

The leading -W says “pass the following argument to”
The ‘c’ in -Wc says “to the compiler”
The argument to pass to the compiler is seperated by a comma
and that arguemnt is -Werror.

I came here for an argument!
Sorry, this is “Getting hit over the head” lessons.

:slight_smile:

Cheers,
-RK

John Nagle <> nagle@downside.com> > wrote:
You can use a comma between command line arguments to QCC?
That’s not documented. See

http://www.qnx.com/developer/docs/qnx_6.1_docs/neutrino/utilities/q/qcc.html

Using the compiler shouldn’t require so much oral tradition.
Could we have an update of the QCC manual page?

John Nagle
Animats

Robert Rutherford wrote:
The “warnings as errors” option isn’t available
under QCC, incidentally.


Sure it is. We use it all the time.

QCC -Wc,-Werror …

Rob Rutherford


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training, Consulting and Software Products at www.parse.com.