Hi, after the recent discussion here about Inline C, I decided to try one of the examples from the cookbook: how to access an so lib. But for some reason, I'm getting unresolved symbols, even though it builds properly. The example below is taken almost verbatim from the cookbook.

#!/usr/bin/perl
print get('http://localhost');

use Inline C => Config =>
LIBS => '-lghttp',
INC => '-I/opt/gnome/include/';
use Inline C => <<'END_OF_C_CODE';

#include <ghttp.h> 

char *get(SV* uri) {
SV* buffer;
ghttp_request* request;

buffer = NEWSV(0,0);
request = ghttp_request_new();
ghttp_set_uri(request, SvPV(uri, PL_na));

ghttp_set_header(request, http_hdr_Connection, "close");

ghttp_prepare(request);
ghttp_process(request);

sv_catpv(buffer, ghttp_get_body(request));

ghttp_request_destroy(request);

return SvPV(buffer, PL_na);
}

END_OF_C_CODE

#################################################################### 
#When I run it, it compiles fine, but I get this error when running: 
Had problems bootstrapping Inline module 'gethttp_bce4'

Can't load '_Inline/lib/auto/gethttp_bce4/gethttp_bce4.so' 
for module gethttp_bce4: _Inline/lib/auto/gethttp_bce4/gethttp_bce4.so: 
undefined symbol: http_hdr_Connection at /DynaLoader.pm line 229. 
at /usr/lib/perl5/site_perl/5.8.0/Inline.pm line 432 
##################################################################### 
 
OK, so now I go to the gethttp_bce4.so and do an nm on it: 
Here is the relevant section of the output: 
nm gethttp_bce4.so -> 
 
00000d00 t frame_dummy 
000015b0 T get 
U ghttp_get_body 
U ghttp_prepare 
U ghttp_process 
U ghttp_request_destroy 
U ghttp_request_new 
U ghttp_set_header 
U ghttp_set_uri 
U http_hdr_Connection 
00002874 d p.0 
U pthread_getspecific 
 
Well all the subroutines needed are undefined. Why?? 
If I do an nm on libghttp.so.1, they are defined : 
nm libghttp.so.1 -> 
 
00003170 T ghttp_get_body 
000031c0 T ghttp_get_body_len 
000030b0 T ghttp_get_error 
00003030 T ghttp_get_header 
00003070 T ghttp_get_header_names 
00003150 T ghttp_get_socket 
00002e40 T ghttp_get_status 
000030e0 T ghttp_parse_date 
00002ab0 T ghttp_prepare 
00002c80 T ghttp_process 
00003130 T ghttp_reason_phrase 
000025f0 T ghttp_request_destroy 
00002570 T ghttp_request_new 
00003210 T ghttp_set_authinfo 
00002a00 T ghttp_set_body 
00002fd0 T ghttp_set_chunksize 
00002ff0 T ghttp_set_header 
000028a0 T ghttp_set_proxy 
00003450 T ghttp_set_proxy_authinfo 
00002a70 T ghttp_set_sync 
000028f0 T ghttp_set_type 
000027a0 T ghttp_set_uri 
00003110 T ghttp_status_code 
00002760 T ghttp_uri_validate 
00006430 T http_base64_encode 
00003690 T http_date_to_time 
000067a3 R http_hdr_Accept 
000067aa R http_hdr_Accept_Charset 
000067b9 R http_hdr_Accept_Encoding 
000067c9 R http_hdr_Accept_Language 
0000687c R http_hdr_Accept_Ranges 
0000688a R http_hdr_Age 
000066d4 R http_hdr_Allow 
000067d9 R http_hdr_Authorization 
00006759 R http_hdr_Cache_Control 
00006767 R http_hdr_Connection 
 
########################################################### 
 
So, what am I missing to cause those subroutines to get 
linked in? 
 

In reply to Inline C, accessing an so lib by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.