Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Here's one way that works for me:
Firstly compile the cpp file into xkcd.o:
g++ -c xkcd.cpp
Then create a static library (named, say, libxkcd.a) from the generated xkcd.o:
ar -rc libxkcd.a xkcd.o
Then before the "use Inline CPP;" line in test.pl I inserted:
use Inline CPP => Config => BUILD_NOISY => 1, INC => '-ID:/w/xkcd', LIBS => '-LD:/w/xkcd -lxkcd', ;
The "BUILD_NOISY" directive just allows you to see the compilation during the initial run.
The 'INC' and 'LIBS' directives allow xkcd.h and libxkcd.a to be located, as needed during the build.
Obviously, for me both of those files were located in the D:/w/xkcd directory. For me, the script then outputs:
Perfect random number: 4 Perfect random number: 4 Perfect random number: 4
I think it might be important that there's an empty line or 2 at the bottom of all three test.pl, xkcd.h and xkcd.cpp files.

Cheers,
Rob

In reply to Re: External (extra) files when using Inline::CPP by syphilis
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 avoiding work at the Monastery: (3)
As of 2024-06-18 06:54 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.