473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
4 2002
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bram Stolk | last post by:
Hi there, I just built and installed Python-2.4.1 on my Irix machine. My compiler, the MipsPro compiler, chokes on the Python.h include file, as demonstrated here: $ CC -v MIPSpro...
6
by: Evan David Light | last post by:
After agonizing over this problem for a few days, I've decided to seek help. No, not the variety that involes a jacket that zips up the back but this august body of intrepid individuals. I've...
0
by: r5 | last post by:
I'm using the MIPSpro Compiler and having trouble defining a function template (involving array size specifiers as template arguments) inside a class. The same definition compiles fine outside...
3
by: H. S. | last post by:
Hi, I am trying to compile these set of C++ files and trying out class inheritence and function pointers. Can anybody shed some light why my compiler is not compiling them and where I am going...
0
by: Norm Wong | last post by:
If anyone is interested in using db2uext2 with Cygwin gcc compiler on Windows, I've modified the IBM provided sample with the attached file. There are two main modifications. The mkdir command...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
2
by: Justin Naidl | last post by:
A group of friends and I are doing a RPG (role-playing game) maker for a school project. It occured to us, however, that if you want the user to be able to have almost complete control over the...
2
by: renagade629 | last post by:
Can anybody help me understand what i'm doing wrong or what I'm missing? Is there anyother good and commendable C++ program I can use (free) from the internet like Dev C++? I'm having trouble doing...
10
by: Tomás Ó hÉilidhe | last post by:
I'd post this on a gcc newsgroup but I'd be more productive talking to the wall. Anyway, let's say someone throws some source code at you for a particular program and says, "Just compile it, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.