- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Compilation problem with HP UNIC GCC
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 06:12 AM
тАО11-29-2007 06:12 AM
I have installed GCC-4.2.1 and trying to compile the sample cpp file.
my cpp file ex1.cpp looks as below
#include
int main()
{
cout <<" Hello World "<< endl;
}
if i give gcc ex1.cpp
the following errors are popping up.
ld: Unsatisfied symbol "std::basic_string
ld: Unsatisfied symbol "__gxx_personality_v0" in file /var/tmp//cc3k7lkb.o
ld: Unsatisfied symbol "std::basic_string
ld: Unsatisfied symbol "std::ios_base::Init::~Init()" in file /var/tmp//cc3k7lkb.o
ld: Unsatisfied symbol "std::ios_base::Init::Init()" in file /var/tmp//cc3k7lkb.o
5 errors.
collect2: ld returned 1 exit status
bash-2.04$
Can anybody tell me what is happening here?
thanks and regards
Vikram
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 07:31 AM
тАО11-29-2007 07:31 AM
Solutionget better results when I include one more
statement, and when I use a C++ compiler:
dy # cat ex1a.cpp
#include
using namespace std;
int main()
{
cout <<" Hello World "<< endl;
}
dy # g++ ex1a.cpp
dy # ./a.out
Hello World
For the record:
dy # uname -a
HP-UX dy B.11.11 U 9000/785 2012616114 unlimited-user license
dy # g++ --version
g++ (GCC) 4.2.2
[...]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 01:00 PM
тАО11-29-2007 01:00 PM
Re: Compilation problem with HP UNIC GCC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 01:13 PM
тАО11-29-2007 01:13 PM
Re: Compilation problem with HP UNIC GCC
Now, why didn't I think of that? No, wait.
I did.
On the other hand:
dy # g++ ex1.cpp
ex1.cpp: In function 'int main()':
ex1.cpp:5: error: 'cout' was not declared in this scope
ex1.cpp:5: error: 'endl' was not declared in this scope
which is why I added:
using namespace std;
Sometimes it pays actually to _try_ a
suggestion before offering it.
But thanks for playing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 01:48 PM
тАО11-29-2007 01:48 PM
Re: Compilation problem with HP UNIC GCC
yes it is working with g++, but problem i have to use gcc only. I also tried adding
using namespace std;
but not working!!!!!
Also i want to clearify her, whether both
gcc and g++ are same ? Can a g++ compiler compile complex and big C programs ?
thanks and regards
Vikram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 02:21 PM
тАО11-29-2007 02:21 PM
Re: Compilation problem with HP UNIC GCC
Why? gcc is a C compiler. g++ is a C++
compiler. Both are included in the GCC (the
GNU Compiler Collection).
http://gcc.gnu.org/
> [...] but not working!!!!!
If I can show you exactly what did work, why
can't you show us exactly what didn't work?
> [...] whether both
> gcc and g++ are same ?
Do they do the same things? Obviously not.
> Can a g++ compiler compile complex and big
> C programs ?
Why would I use a C++ compiler on a complex
and big C program? Or any other C program?
I normally use a C compiler on a C program,
and a C++ compiler on a C++ program. It only
_seems_ more complicated that way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 02:47 PM
тАО11-29-2007 02:47 PM
Re: Compilation problem with HP UNIC GCC
You may check google gcc vs g++
Hope this help!!!
BR,
Kapil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 03:19 PM
тАО11-29-2007 03:19 PM
Re: Compilation problem with HP UNIC GCC
This should be obvious. :-) It seems that gcc will compile C++ sources. But it won't link them.
>Why would I use a C++ compiler on a complex and big C program?
Because you want the extra strong type checking? :-)
>I normally use a C compiler on a C program,
and a C++ compiler on a C++ program.
Exactly.
>I get better results when I include one more statement: using namespace std;
If you are using aC++ and going back and forth between -AP and -AA, you should use:
namespace std {} using namespace std;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 03:47 PM
тАО11-29-2007 03:47 PM
Re: Compilation problem with HP UNIC GCC
My Cpp code is as follows
#include
using namespace std;
int main()
{
cout <<" Hello World "<< endl;
}
And the error messages i am getting is as follows.
bash-2.04$ gcc HelloWorld.cpp
ld: Unsatisfied symbol "std::basic_string
ld: Unsatisfied symbol "__gxx_personality_v0" in file /var/tmp//ccZjzzfc.o
ld: Unsatisfied symbol "std::basic_string
ld: Unsatisfied symbol "std::ios_base::Init::~Init()" in file /var/tmp//ccZjzzfc.o
ld: Unsatisfied symbol "std::basic_ostream
ld: Unsatisfied symbol "std::ios_base::Init::Init()" in file /var/tmp//ccZjzzfc.o
ld: Unsatisfied symbol "std::basic_ostream
ld: Unsatisfied symbol "std::basic_ostream
ld: Unsatisfied symbol "std::cout" in file /var/tmp//ccZjzzfc.o
9 errors.
collect2: ld returned 1 exit status
bash-2.04$
I thought gcc and g++ are similar. But, now it seems gcc cannot be used for c++ programs.
The reason i want to use gcc is i want to link to a library file that is generated by gcc (library contains just a function which i want to call from the C++ Program ).
My idea is not to cause any conflicts between the lib file and the code which i want to compile with g++...
Since both are GNU compilers i think there should not be any conflicts?
Please correct me if i am wrong..
thanks and regards
Vikram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2007 04:03 PM
тАО11-29-2007 04:03 PM
Re: Compilation problem with HP UNIC GCC
They are related, but they have different
names for a reason.
> The reason i want to use gcc is i want to
> link to a library file that is generated by
> gcc (library contains just a function which
> i want to call from the C++ Program ).
I would not expect any special problems doing
that. There are some things which you may
need to do with the C function prototypes in
your C++ code, but that's normal.
I would try a making a simple C++ program
which calls one of the functions in your C
library, compile the C code with gcc, compile
the C++ code with g++, and link using g++.
If that fails, come back with the new error
messages.
If you've never seen anything like this:
#ifdef __cplusplus
extern "C" {
#endif
then you'll probably need to do some reading
on how to combine C and C++ programs.