Free Downloads, Community Forum,
FAQs and Developer Resources

Make /Tools Your Home | Link to us

Today's posts | Posts since last visit | Most Active Topics

All Forums Register Login Search Subscriptions My Profile Inbox
Tool Warehouse FAQs Resources Help Member List Address Book Logout

POSIX source to dll

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum >> POSIX source to dll Page: [1]
Message << Older Topic   Newer Topic >>
POSIX source to dll - Oct. 2, '06, 6:51:53 AM   


Posts: 5
Joined: Oct. 2, '06,
Status: offline

I developed shared library for Linux. This shared library contains functions that are in POSIX compatible and are used by Java (through JNI) on linux. Now I decided port that library to Win32. I looked around and find that simplest is that I use Interix environment to build that library for windows. Same makefiles what are written for Linux building systems can build .so file successfully.
What I must to do next, when I want to use this library by Java on Windows machine? Maybe C#.Net is also useful.
About my experience I can say that I have made before some C# and Java projects. Those projects use dll-s for accessing my own APIs and they work correctly. My question is, how can I write wrapper for POSIX functionalities and put those wrapper functions inside dll?

And a bit code:
 It's not JNI compatible yet! But what about C#?

extern "C" {
int Number(int nr);

#include "Test.h"

int Number(int nr)
 return nr;


all: compile linking striping dll sharp

        g++ -fPIC -c Test.cpp -o Test.o

        g++ -shared -Wl,-soname, Test.o -o


        #Is it correct? Is Interix .so in dll format?
        cp Test.dll

        #Copy dll in to charpdevelop project binary directory
        cp Test.dll ./InterixTest/bin/Debug

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection.Emit;
using System.Runtime.InteropServices;

namespace InterixTest
        public class Test
                public Test(){}

                [DllImport("Test.dll")] protected static extern 
                int Number(int nr);
                public int CallNumber(int nr)
                        return Number(nr);

And error what .Net executing give:
Exception System.EntryPointNotFoundException was thrown in debuggee:
Unable to find an entry point named 'Number' in DLL 'Test.dll'.
Post #: 1
RE: POSIX source to dll - Oct. 2, '06, 7:02:40 AM   


Posts: 5
Joined: Oct. 2, '06,
Status: offline
Maybe also:
1) BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
2) #define DLL_EXPORT __declspec(dllexport)
must be added some how?

(in reply to Krabi)
Post #: 2
RE: POSIX source to dll - Oct. 2, '06, 9:31:55 AM   


Posts: 669
Joined: Mar. 31, '03,
Status: offline
You cannot use the default Interix tools to build Win32 objects.
The gcc that ships with Interix is set up to build Interix objects, not Win32.
Any .so's created in Interix can only be used in the Interix environment.
Think of Interix as another version of UNIX.

You could either build your library using Win32 development tools (cygwin, mingw, MKS)
or you could try "mixed mode" build tools available in SUA on Vista or Windows Server 2003 R2.
(SUA = subsystem for UNIX applications).
This "mixed mode" allows you to use Interix functionality in a Win32 application.
But there are several caveats and restrictions. (eg. you have to avoid conflicts between
the Interix and Win32 libraries)

(in reply to Krabi)
Post #: 3
RE: POSIX source to dll - Oct. 3, '06, 4:24:19 AM   


Posts: 5
Joined: Oct. 2, '06,
Status: offline
I used cygwin today and with a few changes in my code and all fine. I tried it only with C#! I am going to try with JNI now.
But what about future? Will Interix do work to resolve this like problems in future?

(in reply to markfunk)
Post #: 4
Page:   [1]
All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum >> POSIX source to dll Page: [1]
Jump to:

New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts

Search All Forums -

Advanced search


Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI