Problems with Standard Make Tutorial

I’m running Momentics on a Windows platform. Here is my makefile:

all: test

INCLUDES = -IC:\QNX630\target\qnx6\usr\include\cpp

clean:

-rm main.o test.exe test

test: main.o

QCC $(INCLUDES) -g -o test main.o

main.o: main.cpp

QCC $(INCLUDES) -c -g main.cpp



Here is my source file:

#include

#include

int main()

{

string yourName;


cout << "Enter your name: ";

cin >> yourName;

cout << "Hello " + yourName << endl;


return 0;

}

I also have the include path added via the Project Properties page.
However, when I attempt to build the project, the IDE cannot find the
include files. I get the following response:

make all

MAKE Version 5.0 Copyright (c) 1987, 1997 Borland International

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp

main.cpp: In function `int main()’:

main.cpp:6: `string’ undeclared (first use this function)

main.cpp:6: (Each undeclared identifier is reported only once

main.cpp:6: for each function it appears in.)

main.cpp:6: parse error before `;’

main.cpp:8: `cout’ undeclared (first use this function)

main.cpp:9: `cin’ undeclared (first use this function)

main.cpp:9: `yourName’ undeclared (first use this function)

main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus caught
signal 33

** error 1 ** deleting main.o

Any suggestions as to how I’m supposed to get the IDE to be able to find the
required header files?



Thanks,

Don

Don,

It looks as though your Borland “make” executable is higher in your PATH
environment variable than the QNX one. Make sure that $QNX_HOST/usr/bin
is before wherever the Borland version is.

-Jay.

Don Tucker wrote:

I’m running Momentics on a Windows platform. Here is my makefile:

all: test

INCLUDES = -IC:\QNX630\target\qnx6\usr\include\cpp

clean:

-rm main.o test.exe test

test: main.o

QCC $(INCLUDES) -g -o test main.o

main.o: main.cpp

QCC $(INCLUDES) -c -g main.cpp



Here is my source file:

#include <iostream

#include <string

int main()

{

string yourName;


cout << "Enter your name: ";

cin >> yourName;

cout << "Hello " + yourName << endl;


return 0;

}

I also have the include path added via the Project Properties page.
However, when I attempt to build the project, the IDE cannot find the
include files. I get the following response:

make all

MAKE Version 5.0 Copyright (c) 1987, 1997 Borland International

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp

main.cpp: In function `int main()’:

main.cpp:6: `string’ undeclared (first use this function)

main.cpp:6: (Each undeclared identifier is reported only once

main.cpp:6: for each function it appears in.)

main.cpp:6: parse error before `;’

main.cpp:8: `cout’ undeclared (first use this function)

main.cpp:9: `cin’ undeclared (first use this function)

main.cpp:9: `yourName’ undeclared (first use this function)

main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus caught
signal 33

** error 1 ** deleting main.o

Any suggestions as to how I’m supposed to get the IDE to be able to find the
required header files?



Thanks,

Don

Thanks, Jay. I changed the path order, but the IDE still can’t find the
includes. Here is what I get now:

make clean all

rm main.o test.exe test

main.o: No such file or directory

test.exe: No such file or directory

test: No such file or directory

make: [clean] Error 1 (ignored)

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp

main.cpp: In function `int main()’:

main.cpp:6: `string’ undeclared (first use this function)

main.cpp:6: (Each undeclared identifier is reported only once

main.cpp:6: for each function it appears in.)

main.cpp:6: parse error before `;’

main.cpp:8: `cout’ undeclared (first use this function)

main.cpp:9: `cin’ undeclared (first use this function)

main.cpp:9: `yourName’ undeclared (first use this function)

main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus caught
signal 33

make: *** [main.o] Error 1


Any suggestions?

Don

“Jay Greig” <greig@qnx.com> wrote in message
news:dldkju$i0b$1@inn.qnx.com

Don,

It looks as though your Borland “make” executable is higher in your PATH
environment variable than the QNX one. Make sure that $QNX_HOST/usr/bin
is before wherever the Borland version is.

-Jay.

Don Tucker wrote:
I’m running Momentics on a Windows platform. Here is my makefile:

all: test

INCLUDES = -IC:\QNX630\target\qnx6\usr\include\cpp

clean:

-rm main.o test.exe test

test: main.o

QCC $(INCLUDES) -g -o test main.o

main.o: main.cpp

QCC $(INCLUDES) -c -g main.cpp



Here is my source file:

#include <iostream

#include <string

int main()

{

string yourName;


cout << "Enter your name: ";

cin >> yourName;

cout << "Hello " + yourName << endl;


return 0;

}

I also have the include path added via the Project Properties page.
However, when I attempt to build the project, the IDE cannot find the
include files. I get the following response:

make all

MAKE Version 5.0 Copyright (c) 1987, 1997 Borland International

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp

main.cpp: In function `int main()’:

main.cpp:6: `string’ undeclared (first use this function)

main.cpp:6: (Each undeclared identifier is reported only once

main.cpp:6: for each function it appears in.)

main.cpp:6: parse error before `;’

main.cpp:8: `cout’ undeclared (first use this function)

main.cpp:9: `cin’ undeclared (first use this function)

main.cpp:9: `yourName’ undeclared (first use this function)

main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus caught
signal 33

** error 1 ** deleting main.o

Any suggestions as to how I’m supposed to get the IDE to be able to find
the required header files?



Thanks,

Don

Why isn’t the compiler complaining about not being able to find the
headers? I looks almost as though your code were missing the #include
lines…

Don Tucker wrote:

Thanks, Jay. I changed the path order, but the IDE still can’t find the
includes. Here is what I get now:

make clean all

rm main.o test.exe test

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp
main.cpp: In function int main()': main.cpp:6: string’ undeclared (first use this function)
main.cpp:6: (Each undeclared identifier is reported only once
main.cpp:6: for each function it appears in.)
main.cpp:6: parse error before ;' main.cpp:8: cout’ undeclared (first use this function)
main.cpp:9: cin' undeclared (first use this function) main.cpp:9: yourName’ undeclared (first use this function)
main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus caught
signal 33

make: *** [main.o] Error 1


Any suggestions?

Add “using namespace std;” before main.

Rodney


Wojtek Lerch wrote:

Why isn’t the compiler complaining about not being able to find the
headers? I looks almost as though your code were missing the #include
lines…

Don Tucker wrote:

Thanks, Jay. I changed the path order, but the IDE still can’t find
the includes. Here is what I get now:

make clean all

rm main.o test.exe test

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp
main.cpp: In function int main()': main.cpp:6: string’ undeclared (first use this function)
main.cpp:6: (Each undeclared identifier is reported only once
main.cpp:6: for each function it appears in.)
main.cpp:6: parse error before ;' main.cpp:8: cout’ undeclared (first use this function)
main.cpp:9: cin' undeclared (first use this function) main.cpp:9: yourName’ undeclared (first use this function)
main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus
caught signal 33

make: *** [main.o] Error 1


Any suggestions?

They are there. See previous post for the source file. It is essentially
the little file used in the Standard Make tutorial for Momentics. Maybe my
include path is wrong. I used:

INCLUDES = -IC:\QNX630\target\qnx6\usr\include\cpp

which has both string and iostream in it, but there is also

C:\QNX630\target\qnx6\usr\include\c++\3.3.5 or
C:\QNX630\target\qnx6\usr\include\g+±3

I’m not sure which one I’m supposed to use.

Don

“Wojtek Lerch” <Wojtek_L@yahoo.ca> wrote in message
news:dlfko8$st6$1@inn.qnx.com

Why isn’t the compiler complaining about not being able to find the
headers? I looks almost as though your code were missing the #include
lines…

Don Tucker wrote:
Thanks, Jay. I changed the path order, but the IDE still can’t find the
includes. Here is what I get now:

make clean all

rm main.o test.exe test

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp
main.cpp: In function int main()': main.cpp:6: string’ undeclared (first use this function)
main.cpp:6: (Each undeclared identifier is reported only once
main.cpp:6: for each function it appears in.)
main.cpp:6: parse error before ;' main.cpp:8: cout’ undeclared (first use this function)
main.cpp:9: cin' undeclared (first use this function) main.cpp:9: yourName’ undeclared (first use this function)
main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus caught
signal 33

make: *** [main.o] Error 1


Any suggestions?

Adding “using namespace std;” seems to allow the compiler to see the include
files, but then I get a whole host of other errors…

make all

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -g -o test main.o

main.o: In function `std::locale::facet::~facet(void)’:

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x1e): undefined
reference to `std::cout’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x32): undefined
reference to `std::cin’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x66): undefined
reference to `std::cout’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0xf5): undefined
reference to `std::terminate(void)’

main.o: In function `__static_initialization_and_destruction_0’:

C:/QNX630/target/qnx6/usr/include/cpp/iostream:11: undefined reference to
`std::ios_base::Init::Init(void)’

C:/QNX630/target/qnx6/usr/include/cpp/iostream:45: undefined reference to
`std::_Winit::_Winit(void)’

C:/QNX630/target/qnx6/usr/include/cpp/iostream:45: undefined reference to
`std::_Winit::~_Winit(void)’

… (many more)



Does this mean I am using the wrong include files?

Don

“Rodney Dowdall” <rdowdall@qnx.com> wrote in message
news:dlflvo$3m5$1@inn.qnx.com

Add “using namespace std;” before main.

Rodney


Wojtek Lerch wrote:
Why isn’t the compiler complaining about not being able to find the
headers? I looks almost as though your code were missing the #include
lines…

Don Tucker wrote:

Thanks, Jay. I changed the path order, but the IDE still can’t find the
includes. Here is what I get now:

make clean all

rm main.o test.exe test

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp
main.cpp: In function int main()': main.cpp:6: string’ undeclared (first use this function)
main.cpp:6: (Each undeclared identifier is reported only once
main.cpp:6: for each function it appears in.)
main.cpp:6: parse error before ;' main.cpp:8: cout’ undeclared (first use this function)
main.cpp:9: cin' undeclared (first use this function) main.cpp:9: yourName’ undeclared (first use this function)
main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus
caught signal 33

make: *** [main.o] Error 1


Any suggestions?

Don Tucker wrote:

Adding “using namespace std;” seems to allow the compiler to see the include
files, but then I get a whole host of other errors…

Without the “using namespace std;” the compiler saw the include files,
too; it just needed a clue that what your code refers to as “string” is
what the header defines as “std::string”.

main.o: In function `std::locale::facet::~facet(void)’:

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x1e): undefined
reference to `std::cout’

Does this mean I am using the wrong include files?

Or wrong libraries, perhaps?

You need to tell qcc that your objects are C++ objects. Add -lang-c++ to your qcc lines.

You shouldn’t need to add the includes, they are automatically added.

Don Tucker wrote:

Adding “using namespace std;” seems to allow the compiler to see the include
files, but then I get a whole host of other errors…

make all

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -g -o test main.o

main.o: In function `std::locale::facet::~facet(void)’:

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x1e): undefined
reference to `std::cout’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x32): undefined
reference to `std::cin’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x66): undefined
reference to `std::cout’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0xf5): undefined
reference to `std::terminate(void)’

main.o: In function `__static_initialization_and_destruction_0’:

C:/QNX630/target/qnx6/usr/include/cpp/iostream:11: undefined reference to
`std::ios_base::Init::Init(void)’

C:/QNX630/target/qnx6/usr/include/cpp/iostream:45: undefined reference to
`std::_Winit::_Winit(void)’

C:/QNX630/target/qnx6/usr/include/cpp/iostream:45: undefined reference to
`std::_Winit::~_Winit(void)’

… (many more)



Does this mean I am using the wrong include files?

Don

“Rodney Dowdall” <> rdowdall@qnx.com> > wrote in message
news:dlflvo$3m5$> 1@inn.qnx.com> …


Add “using namespace std;” before main.

Rodney


Wojtek Lerch wrote:

Why isn’t the compiler complaining about not being able to find the
headers? I looks almost as though your code were missing the #include
lines…

Don Tucker wrote:


Thanks, Jay. I changed the path order, but the IDE still can’t find the
includes. Here is what I get now:

make clean all

rm main.o test.exe test




QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp
main.cpp: In function int main()': main.cpp:6: string’ undeclared (first use this function)
main.cpp:6: (Each undeclared identifier is reported only once
main.cpp:6: for each function it appears in.)
main.cpp:6: parse error before ;' main.cpp:8: cout’ undeclared (first use this function)
main.cpp:9: cin' undeclared (first use this function) main.cpp:9: yourName’ undeclared (first use this function)
main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus
caught signal 33

make: *** [main.o] Error 1


Any suggestions?
\


cburgess@qnx.com

Colin Burgess wrote:

You need to tell qcc that your objects are C++ objects. Add -lang-c++
to your qcc lines.

Damn, I forgot that QCC is the same as qcc under Windows! :-/

That worked. Thanks for your help!

Don

“Colin Burgess” <cburgess@qnx.com> wrote in message
news:dlfpd0$rt2$1@inn.qnx.com

You need to tell qcc that your objects are C++ objects. Add -lang-c++ to
your qcc lines.

You shouldn’t need to add the includes, they are automatically added.

Don Tucker wrote:
Adding “using namespace std;” seems to allow the compiler to see the
include files, but then I get a whole host of other errors…

make all

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp

QCC -IC:\QNX630\target\qnx6\usr\include\cpp -g -o test main.o

main.o: In function `std::locale::facet::~facet(void)’:

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x1e): undefined
reference to `std::cout’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x32): undefined
reference to `std::cin’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0x66): undefined
reference to `std::cout’

C:/QNX630/target/qnx6/usr/include/cpp/xlocinfo(.text+0xf5): undefined
reference to `std::terminate(void)’

main.o: In function `__static_initialization_and_destruction_0’:

C:/QNX630/target/qnx6/usr/include/cpp/iostream:11: undefined reference to
`std::ios_base::Init::Init(void)’

C:/QNX630/target/qnx6/usr/include/cpp/iostream:45: undefined reference to
`std::_Winit::_Winit(void)’

C:/QNX630/target/qnx6/usr/include/cpp/iostream:45: undefined reference to
`std::_Winit::~_Winit(void)’

… (many more)



Does this mean I am using the wrong include files?

Don

“Rodney Dowdall” <> rdowdall@qnx.com> > wrote in message
news:dlflvo$3m5$> 1@inn.qnx.com> …


Add “using namespace std;” before main.

Rodney


Wojtek Lerch wrote:

Why isn’t the compiler complaining about not being able to find the
headers? I looks almost as though your code were missing the #include
lines…

Don Tucker wrote:


Thanks, Jay. I changed the path order, but the IDE still can’t find
the includes. Here is what I get now:

make clean all

rm main.o test.exe test




QCC -IC:\QNX630\target\qnx6\usr\include\cpp -c -g main.cpp
main.cpp: In function int main()': main.cpp:6: string’ undeclared (first use this function)
main.cpp:6: (Each undeclared identifier is reported only once
main.cpp:6: for each function it appears in.)
main.cpp:6: parse error before ;' main.cpp:8: cout’ undeclared (first use this function)
main.cpp:9: cin' undeclared (first use this function) main.cpp:9: yourName’ undeclared (first use this function)
main.cpp:10: `endl’ undeclared (first use this function)

cc: C:/QNX630/host/win32/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1plus
caught signal 33

make: *** [main.o] Error 1


Any suggestions?



\

cburgess@qnx.com

Don Tucker wrote:

They are there. See previous post for the source file. It is essentially
the little file used in the Standard Make tutorial for Momentics. Maybe my
include path is wrong. I used:

INCLUDES = -IC:\QNX630\target\qnx6\usr\include\cpp

which has both string and iostream in it, but there is also

C:\QNX630\target\qnx6\usr\include\c++\3.3.5 or
C:\QNX630\target\qnx6\usr\include\g+±3

I’m not sure which one I’m supposed to use.

You don’t need to add a -I option for the standard C++ headers, the
compiler knows where to find them… remove that INCLUDES line
completely and it should still work.


Chris Herborth (cherborth@qnx.com) - Senior Zombiologist and Tech Writer
Never send a monster to do the work of an evil scientist.
Monthly QNX newsletter - http://www.qnx.com/news/forms/newsletter.html