Skip to content

Instantly share code, notes, and snippets.

@mingwandroid
Created January 25, 2016 01:21
Show Gist options
  • Save mingwandroid/7bba87e614f6c954f604 to your computer and use it in GitHub Desktop.
Save mingwandroid/7bba87e614f6c954f604 to your computer and use it in GitHub Desktop.
$ cat test.c
#include "E:/python34/include/python.h"
int DLLMain()
{
PyObject * test = Py_None;
return 0;
}
$ PATH=/mingw64/bin:$PATH gcc -shared -L/e/Python34/libs/ -lpython34 -c test.c -o test.dll
$ nm test.dll
0000000000000000 b .bss
0000000000000000 d .data
0000000000000000 p .pdata
0000000000000000 r .rdata$zzz
0000000000000000 t .text
0000000000000000 r .xdata
U __imp__Py_NoneStruct
0000000000000000 T DLLMain
@carlkl
Copy link

carlkl commented Jan 26, 2016

tried the following: (used #include <python.h> an got the correct the path to the include files)

gcc -shared test.c -I../Include  libpython34.dll.a -o test.dll
strip --strip-unneeded test.dll

and now nm output it looks like

nm test.dll

000000006ec49310 I __IAT_end__
000000006ec491b0 I __IAT_start__
000000006ec49278 I __imp___dllonexit
000000006ec49280 I __imp___iob_func
000000006ec49288 I __imp__amsg_exit
000000006ec49290 I __imp__fpreset
000000006ec49298 I __imp__initterm
000000006ec492a0 I __imp__lock
000000006ec492a8 I __imp__onexit
000000006ec491b0 I __imp__Py_NoneStruct
000000006ec492b0 I __imp__unlock
000000006ec492b8 I __imp_abort
000000006ec492c0 I __imp_calloc
000000006ec491c0 I __imp_DeleteCriticalSection
000000006ec491c8 I __imp_EnterCriticalSection
000000006ec492c8 I __imp_free
000000006ec492d0 I __imp_fwrite
000000006ec491d0 I __imp_GetCurrentProcess
000000006ec491d8 I __imp_GetCurrentProcessId
000000006ec491e0 I __imp_GetCurrentThreadId
000000006ec491e8 I __imp_GetLastError
000000006ec491f0 I __imp_GetSystemTimeAsFileTime
000000006ec491f8 I __imp_GetTickCount
000000006ec49200 I __imp_InitializeCriticalSection
000000006ec49208 I __imp_LeaveCriticalSection
000000006ec492d8 I __imp_malloc
000000006ec492e0 I __imp_memcpy
000000006ec49210 I __imp_QueryPerformanceCounter
000000006ec49218 I __imp_RtlAddFunctionTable
000000006ec49220 I __imp_RtlCaptureContext
000000006ec49228 I __imp_RtlLookupFunctionEntry
000000006ec49230 I __imp_RtlVirtualUnwind
000000006ec49238 I __imp_SetUnhandledExceptionFilter
000000006ec492e8 I __imp_signal
000000006ec49240 I __imp_Sleep
000000006ec492f0 I __imp_strlen
000000006ec492f8 I __imp_strncmp
000000006ec49248 I __imp_TerminateProcess
000000006ec49250 I __imp_TlsGetValue
000000006ec49258 I __imp_UnhandledExceptionFilter
000000006ec49300 I __imp_vfprintf
000000006ec49260 I __imp_VirtualProtect
000000006ec49268 I __imp_VirtualQuery
000000006ec49624 I __lib64_libkernel32_a_iname
000000006ec4967c I __lib64_libmsvcr100_a_iname
000000006ec495bc I __libpython34_dll_a_iname
000000006ec49014 I _head_lib64_libkernel32_a
000000006ec49028 I _head_lib64_libmsvcr100_a
000000006ec49000 I _head_libpython34_dll_a

Nevertheless, linking aginst the MS import library doesn't work as it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment