Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-05-2009, 04:52 AM   #1
LQ Newbie
Registered: Jan 2009
Posts: 24

Rep: Reputation: 15
Linker error while using g++4.1.2 in RHEL5

Linker error while using g++4.1.2 in RHEL5

I have a cpp code, which we have been using in RHEL4 compiled using g++ version 3.4.6.We are now trying to port our application to RHEL5. For this, as the first step, i copied our code to a RHEL5 box and tried to compile the code.

I get "Undefined Reference To" linker error. Kindly note that i have verified all the normal causes for linker errors. Its all fine.
Linking fails for few functions in say file rypt.cpp. Those functions are actually declared in the header file which is already included.
The shared library containing the fucntion implementations is available at the linked path. Library path & name given in the linking command -L path and -llibname are all proper.Hence these are not the cause for the error.

undefined reference to `h::setKeyFile(char const*)'
rypt.cpp.text+0x211): undefined reference to `h::readPassword()'
rypt.cpp.text+0x229): undefined reference to `h::string2CString(ACE_String_Base<char> const&)'
rypt.cpp.text+0x233): undefined reference to `h::decrypt(char const*)'
rypt.cpp.text+0x473): undefined reference to `h::readPassword()'
rypt.cpp.text+0x47e): undefined reference to `h::string2CString(ACE_String_Base<char> const&)'
rypt.cpp.text+0x488): undefined reference to `h::encrypt(char const*)'
collect2: ld returned 1 exit status

I have doubts in following:
1.Compiler version is changed.It is g++ v4.1.2 that is used in RHEL5. Can that cause problem

2.Compiler configurations look different for the current g++ 4.1.2 and the one we were already using g++v3.4.6.Please find below the compiler versions/configurations.

Can some one let me know if g++4.1.2 is expected have some linker errors ? What could be causing such errors, could there be any linker /compiler settings that is needed which i am missing ?

Any pointers would be highly appreciated.

G++ v4.1.2
root@imgw-test39 objdir]# g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/4.1.2/specs
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj- --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)

G++ v3.4.6
bash-3.00$ g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
Old 05-06-2009, 02:10 PM   #2
Senior Member
Registered: Jan 2006
Posts: 4,362

Rep: Reputation: 172Reputation: 172
The answer is the same today as it was yesterday in your other thread. If you do not have a paid subscription you cannot access RH's repo. If you do not want to pay for the subscription use Centos instead. Centos is RHEL with the logos removed (made from the same source). It is free to download/update(unlike RHEL).
Old 05-07-2009, 01:20 AM   #3
LQ Newbie
Registered: Jan 2009
Posts: 24

Original Poster
Rep: Reputation: 15
Thank you Lazlow for your response. My server is remotely placed and I was not sure about the subscriptions. So I am checking that. Anyways, my machine is not registered with RHN, so i could not download that package.
Old 05-07-2009, 01:52 AM   #4
Senior Member
Registered: Jan 2006
Posts: 4,362

Rep: Reputation: 172Reputation: 172
If you are not registered(and are not going to register) you should switch to Centos. You can find the Centos package here:

It will work on your RHEL machine, it is made from the same source as the RHEL package.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linker error while using g++4.1.2 in RHEL5 kk2202 Red Hat 16 05-22-2009 06:01 AM
linker error pavan Programming 2 10-06-2005 01:58 AM
ld linker error Ankit mittal Programming 2 09-30-2005 07:40 AM
Linker error eddydw Linux - General 0 09-20-2004 01:21 PM
Linker Error dim79 Programming 2 06-28-2003 09:53 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:14 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration