NO

Author Topic: Build DLL on command line.  (Read 2515 times)

berossm

  • Guest
Build DLL on command line.
« on: February 17, 2018, 12:17:28 AM »
I'm trying to make a very low level C dll to be used in Python.
Code works fine in GCC on Linux to build the .so and I'm looking at this as a solution for building the .dll

I got it to build no problem as a project but for continuous integration I would prefer to build from the command line.  Is there an easy way to get the full option list from the IDE for the build target? 

Or is there an example for how to build and link a super simple dll from the command line.
Only includes are stdlib & string

So far my attempts have all been a mess of linking errors.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Build DLL on command line.
« Reply #1 on: February 17, 2018, 12:15:33 PM »
Project options Verbose build show commandlines.

A small example:
Code: [Select]
//test.c
//__declspec(dllexport) int __stdcall sum(int a, int b) {
__declspec(dllexport) int __cdecl sum(int a, int b) {
    return a + b;
}

Code: [Select]
SET PellesCDir="C:\Program Files\PellesC"
SET Path=%PellesCDir%\bin
SET INCLUDE=%PellesCDir%\include
SET LIB=%PellesCDir%\lib;%PellesCDir%\lib\Win
pocc -Gd -Ze test.c
polink -dll test.obj
pause
-Gd create __cdecl exports
-Gz create __stdcall exports and with -Gn undecorated __stdcall functions

Python test.py
Code: [Select]
#test.py
import ctypes
#mydll = ctypes.WinDLL("test") # load the dll __stdcall
mydll = ctypes.CDLL("test") # load the dll __cdecl
mydll.sum.argtypes = (ctypes.c_int, ctypes.c_int)
print(mydll.sum(5, 3))
May the source be with you