public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Sam Habiel <sam.habiel@gmail.com>
To: cygwin@cygwin.com
Subject: Problem with dlsym against libicu
Date: Sat, 23 Jan 2016 14:35:00 -0000	[thread overview]
Message-ID: <CABHT963DoTimY9woRrF_kcBSEeUhN2ONhrnnPFL-9CAmDt5geA@mail.gmail.com> (raw)

Hello all.

I am porting GT.M
(https://www.fisglobal.com/Solutions/Services/Database-Engine) to run
on Cygwin x86. My changes are here:
https://github.com/shabiel/fis-gtm/. GT.M is used in healthcare and
banking; I happen to work in the former field.

The problem I am having is that GT.M opens libicuio via dlopen, and
then loads the function pointers into a data structure via function
name using dlsym. For the curious, the code is in gtm_icu_init() in
gtc_icu.c

I took me a while, but I eventually figured out that dlls that are
opened via dlopen need to be in the PATH in Cygwin. I saw this in an
earlier Cygwin mailing list message.

However, no matter what I do, I can't seem to get a non-null reference
to a named symbol in libicuio via dlsym. Here's what I tried:

0. nm shows the symbols in the file I want to open; strace shows me
opening it (it's /usr/lib/cygicuio56.dll).
1. Compiled libicu from source with a flag for Cygwin:
http://site.icu-project.org/
2. Used underscores in front of the symbol
3. Tried creating an import library using the instructions at
https://cygwin.com/cygwin-ug-net/dll.html#dll-build at the bottom and
then add the archive to the gcc compile command as a source file.
(These instructions need to be improved! I had no idea what to do with
a .a file after I got it).

Here's a test program that I have written. Note that dlsym returns the
obscure error message "no such process", which doesn't make any sense
to me, as I am not looking for a "process" but a symbol.

sam@horus ~/fis-gtm-cygwin
$ cat test.c
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>


int main (int arg, char **argv)
{
    void *ptr = dlopen("cygicuio.dll", RTLD_LAZY);
    if (ptr != NULL)
    {
        printf("%p\n",ptr);
    }
    else
    {
        printf("%s",dlerror());
        exit(1);
    }

    void *ptr2 = dlsym(ptr,"uset_open");

    if (ptr2 != NULL)
    {
        printf("%p\n",ptr2);
    }
    else
    {
        printf("%s",dlerror());
        exit(1);
    }

    return 0;
}

sam@horus ~/fis-gtm-cygwin
$ gcc -Wall -otest.o test.c

sam@horus ~/fis-gtm-cygwin
$ ./test.o
No such file or directory
sam@horus ~/fis-gtm-cygwin
$ PATH=/usr/lib:/usr/bin:/usr/local/bin:. ./test.o
0x6aa40000
No such process
sam@horus ~/fis-gtm-cygwin

-- 
Sam Habiel, Pharm.D.
VISTA Expertise Network

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

             reply	other threads:[~2016-01-23  3:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-23 14:35 Sam Habiel [this message]
2016-01-23 19:09 ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABHT963DoTimY9woRrF_kcBSEeUhN2ONhrnnPFL-9CAmDt5geA@mail.gmail.com \
    --to=sam.habiel@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).