Pelles C forum
C language => Windows questions => Topic started by: Tino on March 22, 2013, 04:36:34 AM
-
Hello Forum :)
I m trying to import a DLL from MingW wich export s a class using a C interface and virtual function pointers.
( based on this http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL )
I added some Linux switches and changed the header so that it works with Pelles C,
but the problem is i fail to import the import-lib in Pelles C.
I tried the original .a and used polib to generate a .lib
but the linker completely refuse.
Any help would be appreciated :)
/Project attached
-
You can try create that xstd.dll with ld option --kill-at
After that create DEF-file like thisLIBRARY xstd.dll
EXPORTS
_GetXyz@0
_XyzFoo@8
_XyzRelease@4
__ZN4CXyz3FooEi
and then create import-library with polibpolib.exe /MACHINE:x86 /DEF:xstd.def /OUT:xstd.lib
Here are something to read: http://wyw.dcweb.cn/stdcall.htm
EDIT: x64 testg++ XyzLibrary1.cpp -shared -I%gccdir%\include\w32api -DXYZLIBRARY_EXPORTS -o XyzLibrary64.dll -Wl,--output-def,XyzLibrary64.def,--out-implib,libXyzLibrary64.a -s
LIBRARY XyzLibrary64
EXPORTS
GetXyz @1
XyzFoo @2
XyzRelease @3
_ZN4CXyz3FooEi @4
-
Thanks a lot Timo :)
I will try and post result here.
Thank you very much again :)
-
Hello Forum :)
This is more complicated it seems ><
When i changed the DLL - C worked but C++ was limited :\
Considering i wanted to embedd an option for 64bit too i ran into some more troubles..
I checked some projects like Scintilla and Squlite but they go their own ways too
( This "Amalgamation" seemed the most interesting way but didnt solve my attempt to make universal DLL Template )
Maybe anyone knows a good project wich creates a DLL and supports:
- Exporting classes the C++ and C way for Linux and Windows wich works for 32 and 64 bit ?
Any help appreciated this is really getting hard for me ><
When i change 1 setting for 1 plattform it seems to produce more problems with other ><
-
Hi Tino.
I don't have a codeproject.com account and I can't download the source code.
I believe you'll get more help if you post your code, the command line and your goal. It's hard to guess what you're doing when you say When i change 1 setting for 1 plattform it seems to produce more problems with other'.
-
Hello CLR :)
I attached my current project wich contains a Codeblocks DLL, a Codeblocks Demo and a PellesC Demo.
I dont know if its really helpfull because i didnt get it to run yet.
I changed the --kill-at switch wich success (for C) but then the common C++ access for the class was broken.
Without that switch the C++ access works but C doesnt.
The fastcall for 64 bit isnt implemented yet.
I was searching for something like a template wich solves all 3 needs.
Its hard to belive that something like a DLL project doesnt exist wich support:
C and C++ interface for C++ classes for 32 and 64 bit targetting linux and windows.
Well maybe i should give up on universal template and just create multiple makefiles or so this is really getting a bit hard.
Thank you :)
Edit:
Just saw timo added more files,
i will try them and post results tyvm =)
-
Hi Tino.
The attachment contains scripts for building the DLL & demo programs on windows & linux.
I can't help with CodeBlocks templates. :(
-
Thanks you very much CLR ! :)
I m still trying to find out why it looks "so easy" but that really helped much.
If anyone is interested i will post the CodeBlocks project once i tried the 64 bit version,
cause atm i fight a bit to setup 64 bit guest vm on 32 bit host.
Thank you so much that really helped me :)