Skip to main content

Creating a DLL and compiling with C

Notes on creating a DLL and compiling C​

Library​

Source file​

// gcd.c
int gcd(int a, int b){
return !b ? a : gcd(b, a % b);
}

Header file​

// gcd.h
#ifndef TEST_H
#define TEST_H

int gcd(int a, int b);

#endif

Program​

#include <stdio.h>
#include "gcd.h"

int main(void){
printf("%d\n", gcd(24, 36));
}

Compilation​

Creating the DLL​

gcc gcd.c -shared -o gcd.dll

Compile​

gcc main.c -lgcd -L.

Comments

Loading...

Post a Comment

★★★★★