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

Hi Lily,

You will need to replace ‘cc’ with ‘qcc’ and remove the ‘-T1’ option. In you
code you will have to use the “ThreadCtl(_NTO_TCTL_IO, 0)” function to get
IO privity rather then using a compiler option like ‘-T1’. See “ThreadCtl”
in the docs for more information.

http://www.qnx.com/developer/docs/momentics621_docs/neutrino/lib_ref/t/threa
dctl.html

Regards,

Joe

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
\

One more thing. You do realize that “test” is a poor name for a test
program because it is also a special word to the shell. I.E. if at the
shell prompt you typed:

test
The shell will not execute your program. I do believe you can type:
./test
but I would just choose a different name for my program. I usually

use t1, t2 etc.


Hardware Support <hw@qnx.com> wrote:

Hi Lily,

You will need to replace ‘cc’ with ‘qcc’ and remove the ‘-T1’ option. In you
code you will have to use the “ThreadCtl(_NTO_TCTL_IO, 0)” function to get
IO privity rather then using a compiler option like ‘-T1’. See “ThreadCtl”
in the docs for more information.

http://www.qnx.com/developer/docs/momentics621_docs/neutrino/lib_ref/t/threa
dctl.html

Regards,

Joe

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

\


Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

I wrote the makefile as

CC = gcc
CPP = g++
CFLAGS = -Wall -fno-builtin
CPPFLAGS = -Wall -fno-builtin

OBJS = myprog.o sfile.o
myprog: myprog.o sfile.o
$(CC) $(OBJS) -o $@

…c.o:
$(CC) $(CFLAGS) -c $<
…cpp.o:
$(CPP) $(CPPFLAGS) -c $<

and type “make myprog” at command line, then iostream.h file can not be
found and the compilation is stoped. With another pogram using socket, I
added -l socket and the socket file can not be found either. Can you
please tell how to fix the missed header file problem? I added -I
/usr/include/g+±3 to find the <iostream.h>, I included too many header
files to put them after -I one by one. They can be found automatilcally
under QNX4. Where are they now?

I am using QNX6.20NC.

Thankx.

Lily

Bill Caroselli wrote:

One more thing. You do realize that “test” is a poor name for a test
program because it is also a special word to the shell. I.E. if at the
shell prompt you typed:

test
The shell will not execute your program. I do believe you can type:
./test
but I would just choose a different name for my program. I usually
use t1, t2 etc.


Hardware Support <> hw@qnx.com> > wrote:

Hi Lily,


You will need to replace ‘cc’ with ‘qcc’ and remove the ‘-T1’ option. In you
code you will have to use the “ThreadCtl(_NTO_TCTL_IO, 0)” function to get
IO privity rather then using a compiler option like ‘-T1’. See “ThreadCtl”
in the docs for more information.


http://www.qnx.com/developer/docs/momentics621_docs/neutrino/lib_ref/t/threa
dctl.html


Regards,


Joe


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 <fanxm0712@yahoo.ca> wrote:

I wrote the makefile as

CC = gcc
CPP = g++
CFLAGS = -Wall -fno-builtin
CPPFLAGS = -Wall -fno-builtin

OBJS = myprog.o sfile.o
myprog: myprog.o sfile.o
$(CC) $(OBJS) -o $@

.c.o:
$(CC) $(CFLAGS) -c $
.cpp.o:
$(CPP) $(CPPFLAGS) -c $

and type “make myprog” at command line, then iostream.h file can not be
found and the compilation is stoped. With another pogram using socket, I
added -l socket and the socket file can not be found either. Can you
please tell how to fix the missed header file problem? I added -I
/usr/include/g+±3 to find the <iostream.h>, I included too many header
files to put them after -I one by one. They can be found automatilcally
under QNX4. Where are they now?

I am using QNX6.20NC.

Thankx.

Lily

Two thoughts:

  1. try qcc instead of gcc & g++
  2. what extension are you using for your C++ files?

In all of my makefiles it just somehow knows where to find the C++
include files. I’m doing nothing to tell it where to find them.

Good luck.

Bill Caroselli wrote:

Lily <> fanxm0712@yahoo.ca> > wrote:

I wrote the makefile as


CC = gcc
CPP = g++
CFLAGS = -Wall -fno-builtin
CPPFLAGS = -Wall -fno-builtin


OBJS = myprog.o sfile.o
myprog: myprog.o sfile.o
$(CC) $(OBJS) -o $@


.c.o:
$(CC) $(CFLAGS) -c $
.cpp.o:
$(CPP) $(CPPFLAGS) -c $


and type “make myprog” at command line, then iostream.h file can not be
found and the compilation is stoped. With another pogram using socket, I
added -l socket and the socket file can not be found either. Can you
please tell how to fix the missed header file problem? I added -I
/usr/include/g+±3 to find the <iostream.h>, I included too many header
files to put them after -I one by one. They can be found automatilcally
under QNX4. Where are they now?


I am using QNX6.20NC.


Thankx.


Lily


Two thoughts:

  1. try qcc instead of gcc & g++
  2. what extension are you using for your C++ files?

In all of my makefiles it just somehow knows where to find the C++
include files. I’m doing nothing to tell it where to find them.

Good luck.

My C++ files extension are *.cpp. I tried with QCC and it is OK. But
with gcc, the include library can not be found. Can you please tell me
how to fix it? Thnkx.

Lily <fanxm0712@yahoo.ca> wrote:

Bill Caroselli wrote:

Two thoughts:

  1. try qcc instead of gcc & g++
  2. what extension are you using for your C++ files?

In all of my makefiles it just somehow knows where to find the C++
include files. I’m doing nothing to tell it where to find them.

Good luck.

My C++ files extension are *.cpp. I tried with QCC and it is OK. But
with gcc, the include library can not be found. Can you please tell me
how to fix it? Thnkx.

LOL

This is a trick question, right?
Why not just use QCC in your makefile?

My understanding is that QCC sets up a lot of things for you for the
QNX environment. Why not take advantage of it?

If you want I assume that you can pass all of the correct options
to qcc. Just run QCC (which you say works) and look at the line that
it generates. But really, why bother? If in the future QNX changes
things they will undoubtedly give us a new qcc (for a nominal fee).
If you pass all of those options yourself, then you’ll have to change
all of your own makefiles.