Solved

C program previously compiled on Solaris need to compile on Linux

Posted on 2011-02-22
11
643 Views
Last Modified: 2012-05-11
First let me preface this question and say that I am not a C programmer.  Never have been.  Code PERL, vbscript, & ASP well tho.  Have a situation where we are moving from Solaris to Linux and have a custom shared object that I cannot get to compile on Linux.  I've resolved all of the *.h file dependency error message, etc but now when I type "make" I receive the following and really don't know where to start troubleshooting...  Old system was Solaris 8 64-bit.  New System is ReHat x86_64-bit .  Please see output below.  Am looking for guidance to resolve the errors during compile.  I'm using the mozldap SDK and those functions '`ldap_init', etc should be in there.  I have setup my LD_LIBRARY_PATH and also the PATH variable to include all locations where the sdk files exist.   thanks for your time!

# make
/usr/bin/gcc -DLINUX -D_REENTRANT -I. -c getrpw.cpp
/usr/bin/gcc -DLINUX -D_REENTRANT -G getrpw.o -o libgetrpw.so
gcc: unrecognized option '-G'
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
getrpw.o: In function `getUserContext':
getrpw.cpp:(.text+0x99a): undefined reference to `ldap_init'
getrpw.cpp:(.text+0x9f0): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xa14): undefined reference to `ldap_set_option'
getrpw.cpp:(.text+0xa59): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xa7d): undefined reference to `ldap_set_option'
getrpw.cpp:(.text+0xac2): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xae4): undefined reference to `ldap_simple_bind_s'
getrpw.cpp:(.text+0xaf5): undefined reference to `ldap_err2string'
getrpw.cpp:(.text+0xb46): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xbe7): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xc71): undefined reference to `ldap_search_ext_s'
getrpw.cpp:(.text+0xcc4): undefined reference to `ldap_err2string'
getrpw.cpp:(.text+0xd10): undefined reference to `ldap_msgfree'
getrpw.cpp:(.text+0xd19): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xd35): undefined reference to `ldap_count_entries'
getrpw.cpp:(.text+0xd4f): undefined reference to `ldap_first_entry'
getrpw.cpp:(.text+0xd64): undefined reference to `ldap_first_attribute'
getrpw.cpp:(.text+0xd79): undefined reference to `ldap_get_values'
getrpw.cpp:(.text+0xe1f): undefined reference to `ldap_value_free'
getrpw.cpp:(.text+0xe36): undefined reference to `ldap_ber_free'
getrpw.cpp:(.text+0xe3f): undefined reference to `ldap_memfree'
getrpw.cpp:(.text+0xe51): undefined reference to `ldap_msgfree'
getrpw.cpp:(.text+0xe5a): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xe82): undefined reference to `ldap_value_free'
getrpw.cpp:(.text+0xedb): undefined reference to `ldap_value_free'
getrpw.cpp:(.text+0xef2): undefined reference to `ldap_ber_free'
getrpw.cpp:(.text+0xefb): undefined reference to `ldap_memfree'
getrpw.cpp:(.text+0xf0d): undefined reference to `ldap_msgfree'
getrpw.cpp:(.text+0xf16): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xf33): undefined reference to `ldap_ber_free'
getrpw.cpp:(.text+0xf3c): undefined reference to `ldap_memfree'
getrpw.cpp:(.text+0xf4e): undefined reference to `ldap_msgfree'
getrpw.cpp:(.text+0xf57): undefined reference to `ldap_unbind'
getrpw.cpp:(.text+0xfed): undefined reference to `ldap_msgfree'
getrpw.cpp:(.text+0xff6): undefined reference to `ldap_unbind'
getrpw.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [libgetrpw.so] Error 1
0
Comment
Question by:jdissupport
11 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 84 total points
ID: 34953977
Seems like your missing the LDAP library - try adding '-lldap' to your linker switches.
0
 
LVL 11

Assisted Solution

by:cup
cup earned 83 total points
ID: 34958420
Also change -G to -g
It adds debug symbols.
0
 
LVL 8

Assisted Solution

by:ssnkumar
ssnkumar earned 83 total points
ID: 34968531
Your compilation command is:
/usr/bin/gcc -DLINUX -D_REENTRANT -I. -c getrpw.cpp

From the filename getrpw.cpp, I assume that, you have a C++ code.
So, try to compile using g++ instead of gcc.

And look at this error:
(.text+0x20): undefined reference to `main'
If you are using main() function in right way, you should not get this error.

Also, you should compile with correct library and use -lldap as somebody already pointed out.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 8

Expert Comment

by:ssnkumar
ID: 35704747
Dhaest,

I feel that the, answers given were practical.
So, it will not be fair to just delete the question.
0
 
LVL 8

Expert Comment

by:ssnkumar
ID: 35704759
I added a comment.
Instead of pressing "Submit", I pressed "Object".
I didn't know that "Object" will remove the "Deletion Pending".
I didn't intend to do that and apologies for any problems that might create.
0
 
LVL 8

Expert Comment

by:ssnkumar
ID: 35712312
My recommendation is 3.
Accept http:#34953977, http:#34958420 and http:#34968531 as answers.
0
 

Expert Comment

by:Mod_MarlEE
ID: 35767645
Starting the auto-close procedure on behalf of the Question Author, to implement the recommendations from the participating Expert(s).


-----
Everyt'ing is everyt'ing,

Mod_MarlEE
Community Support Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now