use Cwd qw( realpath ); use File::Basename qw( dirname ); my $lib_path = dirname(realpath($0)); $lib_path =~ s{\\}{/}g; # Needed? And what about spaces? use Inline C => Config => LIBS => "-L$lib_path -lfmodex";