This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Linux C++ Help
- From: "Jayanta Narayan Choudhuri" <sss at cal dot vsnl dot net dot in>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Fri, 6 Dec 2002 15:21:31 +0530
- Subject: Linux C++ Help
Title: Message
I am seeking your help ONLY after exhausting
myself!
If you can help me get "g++
-o x.exe gplus.cpp"
to link & work then rest will hopefully
follow.
I assumed that it will be easy to port STL C++
programs from Win32 to Linux.
However after
spending 36 hours I am stuck only in the last stage -
linking.
1. gcc or g++
automatically sense the include directories to search and libraries to
link(perhaps) depending on extension *.cpp or *.c
2. If you write a
pure K&R C program or a pure C++ program(not using old C stuff) there is no
problem.
3. The problem is
with C++ programs that also call stdio & strings & ctype stuff.
Compilation goes through fine but linking(collect2) fails. Also pure C++ STL
programs call C malloc & free and even if I get rid of all K&R C stuff
the linking fails.
4. I read all the
internet HOW TO files and FAQs etc. but am in square one.
5. There must be
something VERY silly I have missed.
I am attaching a
few files that you can easily use to replicate my
problem.
1. gcc -o x.exe
jnc.c
# WORKS
2. gcc -o x.exe
jnc.cpp
# FAILS even though jnc.c & jnc.cpp are
identical
3. g++ -o x.exe
jnc.cpp
# also FAILS
4. g++ -o x.exe
gplus.cpp
# also fails though I used the recommended headers of
C++
5. g++ -x c -o x.exe
jnc.cpp #
WORKS
I edited out all the K&R C stuff like
fprintf/sprintf/toupper etc. from my main STL project. As usual compilation is
perfect but collect2 still fails and cannot link
pthread_mutex_lock, pthread_mutex_unlock, malloc and
free. I wrote a few NON STL C++ programs, which if bereft of C
calls, work fine. STL must be calling the above traditional stuff to allocate
memory and be thread safe and possible that is why it fails.
jnc_linux.txt which has the main
diagnostic output is also attached.
You can imagine my
frustration. Everything compiling perfectly - this itself took quite a bit of
effort. Yet I am stuck because I do not know how to link. If you can help me get
"g++ -o x.exe gplus.cpp" to work then the rest will hopefully
follow.
Looking forward to
good news ....
Regards & Best
Wishes
-jnc
Jayanta Narayan
Choudhuri
Flat 302, 395 Jodhpur Park
Kolkata 700 068
India
Tel:
91(33)2473-1891
mailto:sss@cal.vsnl.net.in
url: http://www.geocities.com/ojnc
Attachment:
gplus.cpp
Description: Text document
Attachment:
jnc.c
Description: Text document
Attachment:
jnc.cpp
Description: Text document
Attachment:
jnc_linux.txt
Description: Text document