Highlighted
acherro Absent Member.
Absent Member.
441 views

ou=abrnhlls,ou=us_est,ou=na,

I'm new to using gcc and am trying to compile the search.c sample file and
I get messages like this:

search.c:(.text+0xc0): undefined reference to `ldap_set_option'

I'm really not familiar with the tools, though I have been using the Java
libraries on Windows for several years. I'm switching to SUSE for several
projects and would like to start using C/C++ to do more of my work. The
command I used and all of it's output are below. The machine is just a
standard SUSE 10 install with the development tools added. Any help would
be greatly appreciated.

-ac.

ac2:/opt/novell-cldap-devel-2007.02.16-1linux # gcc
-I/opt/novell-cldap-devel-2007.02.16-1linux/include
-L/opt/novell-cldap-devel-2007.02.16-1linux/lib search.c
/tmp/ccK3WWXH.o: In function `main':
search.c:(.text+0xc0): undefined reference to `ldap_set_option'
search.c:(.text+0xdb): undefined reference to `ldap_set_option'
search.c:(.text+0xed): undefined reference to `ldap_init'
search.c:(.text+0x133): undefined reference to `ldap_simple_bind_s'
search.c:(.text+0x147): undefined reference to `ldap_err2string'
search.c:(.text+0x162): undefined reference to `ldap_unbind_s'
search.c:(.text+0x1d2): undefined reference to `ldap_search_ext_s'
search.c:(.text+0x1e6): undefined reference to `ldap_err2string'
search.c:(.text+0x201): undefined reference to `ldap_msgfree'
search.c:(.text+0x20c): undefined reference to `ldap_unbind_s'
search.c:(.text+0x239): undefined reference to `ldap_sort_entries'
search.c:(.text+0x24b): undefined reference to `ldap_first_entry'
search.c:(.text+0x265): undefined reference to `ldap_get_dn'
search.c:(.text+0x28c): undefined reference to `ldap_memfree'
search.c:(.text+0x2a5): undefined reference to `ldap_first_attribute'
search.c:(.text+0x2c6): undefined reference to `ldap_get_values'
search.c:(.text+0x318): undefined reference to `ldap_value_free'
search.c:(.text+0x323): undefined reference to `ldap_memfree'
search.c:(.text+0x33c): undefined reference to `ldap_next_attribute'
search.c:(.text+0x35c): undefined reference to `ber_free'
search.c:(.text+0x36e): undefined reference to `ldap_next_entry'
search.c:(.text+0x38d): undefined reference to `ldap_count_entries'
search.c:(.text+0x3ae): undefined reference to `ldap_msgfree'
search.c:(.text+0x3b9): undefined reference to `ldap_unbind_s'
collect2: ld returned 1 exit status

Labels (1)
0 Likes
1 Reply
acherro Absent Member.
Absent Member.

ou=abrnhlls,ou=us_est,ou=na,

> I'm new to using gcc and am trying to compile the search.c sample file and
> I get messages like this:
>
> search.c:(.text+0xc0): undefined reference to `ldap_set_option'
>
> I'm really not familiar with the tools, though I have been using the Java
> libraries on Windows for several years. I'm switching to SUSE for several
> projects and would like to start using C/C++ to do more of my work. The
> command I used and all of it's output are below. The machine is just a
> standard SUSE 10 install with the development tools added. Any help would
> be greatly appreciated.
>
> -ac.
>
> ac2:/opt/novell-cldap-devel-2007.02.16-1linux # gcc
> -I/opt/novell-cldap-devel-2007.02.16-1linux/include
> -L/opt/novell-cldap-devel-2007.02.16-1linux/lib search.c
> /tmp/ccK3WWXH.o: In function `main':
> search.c:(.text+0xc0): undefined reference to `ldap_set_option'
> search.c:(.text+0xdb): undefined reference to `ldap_set_option'
> search.c:(.text+0xed): undefined reference to `ldap_init'
> search.c:(.text+0x133): undefined reference to `ldap_simple_bind_s'
> search.c:(.text+0x147): undefined reference to `ldap_err2string'
> search.c:(.text+0x162): undefined reference to `ldap_unbind_s'
> search.c:(.text+0x1d2): undefined reference to `ldap_search_ext_s'
> search.c:(.text+0x1e6): undefined reference to `ldap_err2string'
> search.c:(.text+0x201): undefined reference to `ldap_msgfree'
> search.c:(.text+0x20c): undefined reference to `ldap_unbind_s'
> search.c:(.text+0x239): undefined reference to `ldap_sort_entries'
> search.c:(.text+0x24b): undefined reference to `ldap_first_entry'
> search.c:(.text+0x265): undefined reference to `ldap_get_dn'
> search.c:(.text+0x28c): undefined reference to `ldap_memfree'
> search.c:(.text+0x2a5): undefined reference to `ldap_first_attribute'
> search.c:(.text+0x2c6): undefined reference to `ldap_get_values'
> search.c:(.text+0x318): undefined reference to `ldap_value_free'
> search.c:(.text+0x323): undefined reference to `ldap_memfree'
> search.c:(.text+0x33c): undefined reference to `ldap_next_attribute'
> search.c:(.text+0x35c): undefined reference to `ber_free'
> search.c:(.text+0x36e): undefined reference to `ldap_next_entry'
> search.c:(.text+0x38d): undefined reference to `ldap_count_entries'
> search.c:(.text+0x3ae): undefined reference to `ldap_msgfree'
> search.c:(.text+0x3b9): undefined reference to `ldap_unbind_s'
> collect2: ld returned 1 exit status
>



I changed the command to this:

gcc -I/opt/novell-cldap-devel-2007.02.16-1linux/include -lldap search.c

and I got a file called a.out that I was able to run and connect to my
server; however, I don't understand why that works. In addition, how cna I
be sure that the compiler is using the Novell headers and libraries and not
the files that were included in the OS for OpenLDAP?

BTW - Sorry about the name of the thread. Poor proof-reading skills.

-ac.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.