Skip to content

Instantly share code, notes, and snippets.

@zmughal
Last active August 29, 2015 14:05
Show Gist options
  • Save zmughal/05649d63917fbf84e99a to your computer and use it in GitHub Desktop.
Save zmughal/05649d63917fbf84e99a to your computer and use it in GitHub Desktop.
all: libtowel.so
perl towel.pl
-@#LD_PRELOAD="`pwd`/libtowel.so" perl towel.pl
libtowel.so: towel.c
$(CC) -shared -fPIC -o $@ $<
clean:
rm -Rf _Inline/ libtowel.so
all: libtowel.dll
perl towel.pl
libtowel.dll: towel.o
-$(CC) -shared -Wl,--out-implib,libtowel.a -o libtowel.dll $<
-REM $(CC) -shared -o $@ $<
towel.o: towel.c
$(CC) -c $< -o $@
clean:
-$(RM) libtowel.dll libtowel.a towel.o
-del /Q /S _Inline
#include "towel.h"
int h2g2() {
return 42;
}
#ifndef _HELLO_H
#define _HELLO_H
extern int h2g2();
#endif /* _HELLO_H */
#!/usr/bin/env perl
use strict;
use warnings;
use v5.16;
use File::chdir;
use Inline C => Config =>
FORCE_BUILD => 1,
CLEAN_AFTER_BUILD => 0,
INC => "-I$CWD",
LIBS => "-L$CWD -ltowel",
ENABLE => AUTOWRAP =>;
use Inline C => 'DATA';
say h2g2();
__END__
__C__
extern int h2g2();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment