compilation question...

Hi all,

I have a simple program as following:

#include <stdio.h>
#include
using namespace std;

int main()
{
try {
throw 1;
} catch (exception &e) {
printf(“catch exception 1 %s\n”, e.what());
return 0;
} catch (int) {
printf(“catch exception 2\n”);
return 0;
} catch (…) {
printf(“catch exception 3\n”);
return 0;
}
printf(“catch no exception\n”);
return 0;
}

When I compile the code with “qcc -gstabs+ test.cpp -o test”, it works as
expected.
However, when I compile the code first with “qcc -gstabs+ -c test.cpp -o
test.o” and
then “qcc -o test test.o -lcpp”, I keep getting core dump. I have puzzled my
brain all
day. Can someone tell me the reason?

Thanks a lot.
kc

try QCC instead of qcc for c++ sources?

kc <kc@netnobound.com> wrote:

Hi all,

I have a simple program as following:

#include <stdio.h
#include <exception
using namespace std;

int main()
{
try {
throw 1;
} catch (exception &e) {
printf(“catch exception 1 %s\n”, e.what());
return 0;
} catch (int) {
printf(“catch exception 2\n”);
return 0;
} catch (…) {
printf(“catch exception 3\n”);
return 0;
}
printf(“catch no exception\n”);
return 0;
}

When I compile the code with “qcc -gstabs+ test.cpp -o test”, it works as
expected.
However, when I compile the code first with “qcc -gstabs+ -c test.cpp -o
test.o” and
then “qcc -o test test.o -lcpp”, I keep getting core dump. I have puzzled my
brain all
day. Can someone tell me the reason?

Thanks a lot.
kc

fliu@bb.vipstage.com wrote:

try QCC instead of qcc for c++ sources?

More specifically for the link stage. It has to know that
you are using C++ in your object files.

so link with qcc -lang-c++ or QCC

kc <> kc@netnobound.com> > wrote:
Hi all,

I have a simple program as following:

#include <stdio.h
#include <exception
using namespace std;

int main()
{
try {
throw 1;
} catch (exception &e) {
printf(“catch exception 1 %s\n”, e.what());
return 0;
} catch (int) {
printf(“catch exception 2\n”);
return 0;
} catch (…) {
printf(“catch exception 3\n”);
return 0;
}
printf(“catch no exception\n”);
return 0;
}

When I compile the code with “qcc -gstabs+ test.cpp -o test”, it works as
expected.
However, when I compile the code first with “qcc -gstabs+ -c test.cpp -o
test.o” and
then “qcc -o test test.o -lcpp”, I keep getting core dump. I have puzzled my
brain all
day. Can someone tell me the reason?

Thanks a lot.
kc


cburgess@qnx.com

Hmm…
If I have mix c++ and c sources, I should always use
QCC or -lang-c++. Right?

Thanks
kc

“Colin Burgess” <cburgess@qnx.com> wrote in message
news:acht1s$hj8$2@nntp.qnx.com

fliu@bb.vipstage.com > wrote:
try QCC instead of qcc for c++ sources?

More specifically for the link stage. It has to know that
you are using C++ in your object files.

so link with qcc -lang-c++ or QCC

kc <> kc@netnobound.com> > wrote:
Hi all,

I have a simple program as following:

#include <stdio.h
#include <exception
using namespace std;

int main()
{
try {
throw 1;
} catch (exception &e) {
printf(“catch exception 1 %s\n”, e.what());
return 0;
} catch (int) {
printf(“catch exception 2\n”);
return 0;
} catch (…) {
printf(“catch exception 3\n”);
return 0;
}
printf(“catch no exception\n”);
return 0;
}

When I compile the code with “qcc -gstabs+ test.cpp -o test”, it works
as
expected.
However, when I compile the code first with “qcc -gstabs+ -c
test.cpp -o
test.o” and
then “qcc -o test test.o -lcpp”, I keep getting core dump. I have
puzzled my
brain all
day. Can someone tell me the reason?

Thanks a lot.
kc



\

cburgess@qnx.com

kc <kc@netnobound.com> wrote:

Hmm…
If I have mix c++ and c sources, I should always use
QCC or -lang-c++. Right?

Right.

\

cburgess@qnx.com