Can embedded static-linked python still import dll extensions?
Marc Battyani
Marc_Battyani at csi.com
Tue Mar 14 16:07:47 EST 2000
Warren Postma <embed at geocities.com> wrote in message
news:cItz4.33201$Jz3.306758 at nnrp1.uunet.ca...
> I recompiled the Python sources for Windows with config.h and put this
line
> in:
>
> #define MS_NO_COREDLL 1 // build a static library not a DLL!
>
>
> Now it statically links fine, but it doesn't allow me to import .pyd files
> (Python extension DLLs). Do you have to use the external Python DLL to
allow
> importing modules from DLLs, or can you statically link python but still
> allow external DLL add ons somehow?
>
> I want my embedded python deeply embedded but I still want to produce .PYD
> style add ons for the system once it's in the field. Am I stuck?
No. Nothing prevents you to exports functions from an exe.
Here is a small C program
#include <stdio.h>
__declspec( dllexport ) void foo(){printf("Foo\n");};
__declspec( dllexport ) void bar(){printf("Bar\n");};
main()
{
foo();
bar();
}
Let's compile it:
D:\temp>cl export.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
export.c
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:export.exe
export.obj
Creating library export.lib and object export.exp
****** You can see it creates a .lib and a .exp **********
D:\temp>dumpbin /exports export.exe
Microsoft (R) COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file export.exe
File Type: EXECUTABLE IMAGE
Section contains the following exports for export.exe
0 characteristics
38CEA936 time date stamp Tue Mar 14 22:03:50 2000
0.00 version
1 ordinal base
2 number of functions
2 number of names
ordinal hint RVA name
1 0 00001012 bar
2 1 00001000 foo
******* Here you can see the exported functions are... exported. **********
Good luck
Tell us informed.
Marc Battyani
More information about the Python-list
mailing list