Created
October 28, 2023 07:26
-
-
Save patham9/d8615121e1b5c1f18a7c66be34ab5b23 to your computer and use it in GitHub Desktop.
Simple dll usage (never use dlopen if your program just needs to load the library at startup!!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* add.c */ | |
#include <stdio.h> | |
float add(float a, float b) { return a + b; } | |
//gcc -shared -o libadd.so add.c -fPIC | |
/* main.c */ | |
#include <stdio.h> | |
extern float add(float a, float b); | |
int main() { printf("Result: %f\n", add(3.0, 4.0)); return 0; } | |
//gcc main.c -L. -ladd | |
//./a.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment