Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Perfect, thank you!

I ended up with doing some extra magic in BEGIN, to automate those compile steps (.cpp and .h files in same directory):

#!/usr/bin/env perl use v5.38; use strict; use warnings; use Carp; use Cwd; use Array::Contains; my $dir; my $verbose; BEGIN { $dir = getcwd; print "Working directory: $dir\n"; $verbose = 0; if(contains('-v', \@ARGV)) { $verbose = 1; } # ---- Poor mans Makefile --- if(contains('--clean', \@ARGV)) { print "Cleaning up\n"; my $cmd = 'rm -rf _Inline xkcd.o libxkcd.a'; print "$cmd\n" if($verbose); `$cmd`; exit(0); } print "Compiling library...\n"; foreach my $cmd ('g++ -c xkcd.cpp', 'ar -rc libxkcd.a xkcd.o') { print "$cmd\n" if $verbose; `$cmd`; } # ---- Poor mans Makefile --- }; use Inline 'CPP'; use Inline CPP => Config => BUILD_NOISY => $verbose, INC => '-I' . $dir, LIBS => '-L' . $dir . ' -lxkcd', ; for(1..3) { print "XKCD Dice roll: ", cast_die(), "\n"; } __END__ __CPP__ #include "xkcd.h" int cast_die() { int rolled = xkcd_dice_roll(); return rolled; }

Hmm, i also tested without the empty lines at the bottom of the files and it worked fine. But i dimly remember having the same (or similar) issue to yours on another project.

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP

In reply to Re^2: External (extra) files when using Inline::CPP by cavac
in thread External (extra) files when using Inline::CPP by cavac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-06-16 21:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.