Solved

C program previously compiled on Solaris need to compile on Linux

Posted on 2011-02-22
11
659 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

792 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