NO

Author Topic: How is it done? 2 dll with same function name.  (Read 4347 times)

Seltsamuel

  • Guest
How is it done? 2 dll with same function name.
« on: January 04, 2009, 05:48:36 PM »
Hi,

after long time i have another important problem.
I have 2 .dll both have a function void apiinit(void) i MUST static link so dynamic loading is no option.

for 1 dll no problem:

#ifndef DLLIMPORT
#define DLLIMPORT __declspec(dllimport)
#endif

#pragma comment(lib, "dll1.lib")

DLLIMPORT void apiinit(void);

how can i use ALIAS in pellesC ? i cannot get it working. how can i give 2 names so the linker nows if i want dll1 or dll2 ?
I created .def files by hand and used one of vortex tools "def2lib" to create the .lib file
here is the .def(its working)

LIBRARY dll1
EXPORTS
 "_apiinit@0" @1


Any help is apreciated and im sure others are interested too, it cannot be a so uncommon problem.


Greetings

Seltsamuel

severach

  • Guest
Re: How is it done? 2 dll with same function name.
« Reply #1 on: January 04, 2009, 07:12:32 PM »
Borland and DMC support aliasing with the IMPORTS section of the Module Definition File. IMPORTS fell out of favor so other compilers have either phased out IMPORTS or never implemented it. Pelles MDF has no IMPORTS section at all.

EXE's support aliasing just fine so I first hacked my EXE to make unique names for the ambiguous references. I got tired of that and switched to LoadLibrary/GetProcAddress.

Seltsamuel

  • Guest
Re: How is it done? 2 dll with same function name.
« Reply #2 on: January 04, 2009, 08:28:14 PM »
Hi,

thanks for your answer, i hoped there is a solution because loadlibrary is none (it crashes under w98se to neverland) maybe this is a sort of protection from the .dll under XP and Vista it works ok. Maybe this is a Bug in PellesC ? I cannot understand that there is no alias or pragma working for similar names from different .dll files. There are many dll files with simple names like apiinit ^^ it can not be a solution to not use the dlls and write own functionality that is already there.

EDIT:
how can i static link dls using ordinals only ? this might be a solution.


Greetings

Seltsamuel
« Last Edit: January 04, 2009, 08:32:12 PM by Seltsamuel »

Seltsamuel

  • Guest
Re: How is it done? 2 dll with same function name.
« Reply #3 on: January 05, 2009, 02:37:38 AM »
Hi,

i found a solution using ordinals.
In case of interest i will post my solution these days.
When there is no Interest case is closed ;-)

Greetings

Seltsamuel