<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
I am just getting started with llvm.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
Here's code I am trying to compile:</p><pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.804800033569336px;background:rgb(238,238,238)">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit;background-image:initial;background-repeat:initial"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,128,128);background:transparent">#include</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent"><stdio.h></span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,128,128);background:transparent">#include</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent">"llvm/IR/LLVMContext.h"</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,128,128);background:transparent">#include</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent">"llvm/IR/Module.h"</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,128,128);background:transparent">#include</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent">"llvm/IR/IRBuilder.h"</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">int</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> main</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">()</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">{</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">::</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">LLVMContext</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">&</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> context </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">::</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">getGlobalContext</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">();</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">::</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">Module</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">*</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> module </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,139);background:transparent">new</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">::</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">Module</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent">"top"</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">,</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> context</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">);</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">::</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">IRBuilder</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"><></span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> builder</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">context</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">);</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
module</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-></span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">dump</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">);</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">}</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
when i compile with :</p><pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.804800033569336px;background:rgb(238,238,238)">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit;background-image:initial;background-repeat:initial"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">g</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">++</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,139);background:transparent">try</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">cpp </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">D__STDC_CONSTANT_MACROS </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">D__STDC_LIMIT_MACROS </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">`</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">config </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">--</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">cxxflags </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">--</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">ldflags </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">--</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">libs</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">`</span></code></pre>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
I get the a.out file. No worries.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
But, I am interested in getting the LLVM IR file.So, I compiled with</p><pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.804800033569336px;background:rgb(238,238,238)">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit;background-image:initial;background-repeat:initial"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">g</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">++</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,139);background:transparent">try</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">cpp </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">D__STDC_CONSTANT_MACROS </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">D__STDC_LIMIT_MACROS </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">S </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">emit</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">llvm
lli </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,139);background:transparent">try</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">s</span></code></pre>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
I get an error saying</p><pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.804800033569336px;background:rgb(238,238,238)">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit;background-image:initial;background-repeat:initial"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">LLVM ERROR</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">:</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">Program</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> used external function </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent">'_ZN4llvm16getGlobalContextEv'</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> which could not be resolved</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">!</span></code></pre>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
The command :</p><pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.804800033569336px;background:rgb(238,238,238)">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit;background-image:initial;background-repeat:initial"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">g</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">++</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,139);background:transparent">try</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">cpp </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">D__STDC_CONSTANT_MACROS </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">D__STDC_LIMIT_MACROS </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">`</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">llvm</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">config </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">--</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">cxxflags </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">--</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">ldflags </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">--</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">libs</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">`</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">S </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">emit</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">llvm</span></code></pre>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
leaves me with several warnings and when i execute the resultant .s file with lli , I get the same error as before.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
Thanks a lot for your help</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
<br></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
Thank you,</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">
Prakash Premkumar</p></div>