By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,890 Members | 1,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,890 IT Pros & Developers. It's quick & easy.

Compiling MIPSpro C program using MIPSpro C++ compiler on SGI system

P: n/a
Hello,

Can I run the subject line program using CC instead of cc? I attempted
to use the "-c" option and it told me things were undefined. Isn't this
CC option the same as the cc -c option?

Thank you,
Christopher Lusardi
Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Christopher M. Lusardi wrote:
Can I run the subject line program using CC instead of cc? I attempted
to use the "-c" option and it told me things were undefined. Isn't this
CC option the same as the cc -c option?


No. In general, the meanings of flags depend on your compiler; neither
"cc" nor "CC" is mentioned in the C++ standard; these are
platform-specific compilers. In general, CC is a c++ compiler, cc is a
C compiler, and the -c option tells the compiler to create an object
file, rather than a stand-alone executable.
Jul 22 '05 #2

P: n/a
Jeff Schwab <je******@comcast.net> wrote in message news:<RI********************@comcast.com>...
Christopher M. Lusardi wrote:
Can I run the subject line program using CC instead of cc? I attempted
to use the "-c" option and it told me things were undefined. Isn't this
CC option the same as the cc -c option?


No. In general, the meanings of flags depend on your compiler; neither
"cc" nor "CC" is mentioned in the C++ standard; these are
platform-specific compilers. In general, CC is a c++ compiler, cc is a
C compiler, and the -c option tells the compiler to create an object
file, rather than a stand-alone executable.

Hello again, for clarification purposes, I would like to restate my
question!

When I link a cc compiled file with a CC compiled file, I am told the
c routine is undefined and I do not get a "a.out"! What can/should I
do? Here's an example consisting of two files followed by their
compilation :
/* -------- cut here file ta.c : --------- */
void test (int t);

main ()
{
int my_t;

my_t = 3;
test (my_t);
}

/* -------- cut here file tb.c : --------- */

#include <stdio.h>

void test (int t)
{
printf ("t is %d\n",t);
}

/* -------- cut here compilation : --------- */

%cc -c tb.c
No such feature exists (-5,116)

%CC ta.c tb.o
No such feature exists (-5,116)

ld32: ERROR 33 : Unresolved text symbol "test(int)" -- 1st
referenced by ta.o.
Use linker option -v to see when and which objects, archives
and dsos are loaded.
ld32: INFO 152: Output file removed because of error.
Thank you,
Christopher Lusardi
P.S.: My initial results when I search google is very negative?
Jul 22 '05 #3

P: n/a
Christopher M. Lusardi wrote:
[redacted]

/* -------- cut here file ta.c : --------- */
void test (int t);
extern "C" void test(int); main ()
{
int my_t;

my_t = 3;
test (my_t);
}

/* -------- cut here file tb.c : --------- */

#include <stdio.h>

void test (int t)
{
printf ("t is %d\n",t);
}

/* -------- cut here compilation : --------- */


Jul 22 '05 #4

P: n/a
Christopher M. Lusardi wrote:
Jeff Schwab <je******@comcast.net> wrote in message news:<RI********************@comcast.com>...
Christopher M. Lusardi wrote:

Can I run the subject line program using CC instead of cc? I attempted
to use the "-c" option and it told me things were undefined. Isn't this
CC option the same as the cc -c option?


No. In general, the meanings of flags depend on your compiler; neither
"cc" nor "CC" is mentioned in the C++ standard; these are
platform-specific compilers. In general, CC is a c++ compiler, cc is a
C compiler, and the -c option tells the compiler to create an object
file, rather than a stand-alone executable.


Hello again, for clarification purposes, I would like to restate my
question!

When I link a cc compiled file with a CC compiled file, I am told the
c routine is undefined and I do not get a "a.out"! What can/should I
do? Here's an example consisting of two files followed by their
compilation :
/* -------- cut here file ta.c : --------- */
void test (int t);

main ()
{
int my_t;

my_t = 3;
test (my_t);
}

/* -------- cut here file tb.c : --------- */

#include <stdio.h>

void test (int t)
{
printf ("t is %d\n",t);
}

/* -------- cut here compilation : --------- */

%cc -c tb.c
No such feature exists (-5,116)

%CC ta.c tb.o
No such feature exists (-5,116)

ld32: ERROR 33 : Unresolved text symbol "test(int)" -- 1st
referenced by ta.o.
Use linker option -v to see when and which objects, archives
and dsos are loaded.
ld32: INFO 152: Output file removed because of error.
Thank you,
Christopher Lusardi
P.S.: My initial results when I search google is very negative?


I believe this is a severe case of language mixup.
I compiled your files using GNU C compiler, "gcc" with no errors:

TH009MA@th009ma-shl2-01 /cygdrive/d/temp
$ gcc -c tb.c

TH009MA@th009ma-shl2-01 /cygdrive/d/temp
$ gcc ta.c tb.o

TH009MA@th009ma-shl2-01 /cygdrive/d/temp
$ ls
a.exe ta.c tb.c tb.o

TH009MA@th009ma-shl2-01 /cygdrive/d/temp
$ ./a.exe
t is 3
However, when I use the GNU C++ compiler, "g++" to compile
the ta.c file and link in the tb.o file, I get a similar
error to yours:

TH009MA@th009ma-shl2-01 /cygdrive/d/temp
$ g++ ta.c tb.o
/cygdrive/c/DOCUME~1/TH009MA/LOCALS~1/Temp/ccwOY11k.o(.text+0x2c):ta.c:
undefined reference to `test(int)'
collect2: ld returned 1 exit status
I assume that on your system, "cc" is the C compiler and
"CC" is the C++ compiler.

The issue boils down to "name mangling". This is the art of
naming a function so it includes type information to support
function overloading. Research "name mangling" in the FAQ
and in this newsgroup.

You have two solutions: Stick with one compiler and one
language. Don't mix the two.

Or if you insist on mixing the languages, research and
understand 'extern "C"'. This tells the compiler that the
external reference has "C" language linkage (i.e. no
name mangling). Change file ta.c to:
extern "C"
{
void test (int t);
}

int main (void)
{
int my_t;

my_t = 3;
test (my_t);
}
*********************************************
TH009MA@th009ma-shl2-01 /cygdrive/d/temp
$ cat ta.c
extern "C"
{
void test (int t);
}

main ()
{
int my_t;

my_t = 3;
test (my_t);
}
TH009MA@th009ma-shl2-01 /cygdrive/d/temp
$ g++ ta.c tb.o

TH009MA@th009ma-shl2-01 /cygdrive/d/temp
$ ./a.exe
t is 3

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.