Hi Alvaro,<br><br>First, before making BH work on a particular platform, doublecheck that Gambit works on it in itself. As you're aware, this is a pre-requirement.<br><br>Does Gambit work on Android, for you? If so, what configuration did you use?<br>



<br>What's your current goal, to get a complete environment with compilation and all running on the Android, or solely to make your Linux machine produce binaries runnable on the Android (including a REPL with interpreter)?<br>



<br><br>For resolving any compilation-related issues, you want Gambit to be verbose to you about exactly what C compiler and linker invocations it does, including all parameters passed.<br><br>Gambit invokes the C compiler and linker from the gambc-cc shellscript, and this script is verbose - outputs any C compiler and linker calls to the console - if it's run with the environment variable GAMBC_CC_VERBOSE set.<br>



<br>Thus, when starting the gsc you'll use for producing Android binaries, run it like this from bash: GAMBC_CC_VERBOSE=yes gsc<br><br><br>Now zooming in a bit on BH:<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>I'm generating all 5 files like BH usually does.</div>


<div>These 4 files are the part of Blackhole I understand least, but they are all needed for the module to be defined in C. According to Per:</div><div><br></div><div><div>"When compiling modules for use in development (as opposed to "bh exe"), Black Hole works internally by compiling every module into <b>4</b> Gambit modules (c files if you will):</div>






<div><br></div><div>1) runtime code</div><div>2) compiletime code (this is essentially the same code as the runtime code, but does not use the global namespace and is thus slower but it's required to be able to create an unbound number of instances of the same module at any given time)</div>






<div>3) visit-time code (these are the macros)</div><div>4) module metadata (this is pretty much a compiled a-list)</div><div><br></div><div>If you want to retain the development information, you will need 4 .c files per Black Hole module. If you want to strip development information, you will only need one (the runtime code)."</div>






</div><div><br></div><div>I'm trying both with the 4 files and the only one option. </div></blockquote><div><br>This is a good time to clarify, what's your goal within the following scope:<br><br>Basically, for code execution, only the runtime code C file is needed. (view this as the 'executable code' file.)<br>



<br>The total set of four files is needed to get a complete BH dev environment running. The reason for more than one file, is because BH needs to have several instances of each module "at hand", in order to get the macro expansion spinning the right way. The syntactic tower version of BH implements (exactly that;) the syntactic tower, appropriately and correctly, and this requires more than one instance of the module to be done the right way.<br>



<br>Thus, if your objective is to generate code that should be executable on the target environment and that's it, go with one file, otherwise go with all four.<br><br>Which of these two - exec only or complete dev environment - is your current usecase?<br>



<br><br><br>Now into details about your issue:<br><br> (A)</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>The multiple definition of symbols happens in both situations, but </div>



</blockquote><div>(B) <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>an undefined reference happens for each one of the 3 files (I think that is due to the link file referencing them, I could take care of that). But the core of the problem is with the multiple definition of ___G_list, ___S_list, ___G_void and ___S_void</div>






<div>How can this happen?</div></blockquote><div><br>Is your point that (A) happens for either of the four files, while for the last three files (B) happens as well?<br><br>Producing and compiling with link files is indeed a bit tricky. To the best of my knowledge, the procedure to follow is something like this:<br>


<br>Make BH output C code:<br><br>(module-compile! 'yourmod to-c: t)<br><br>Now, for each of the C files you want to compile:<br><br>(<span>link</span>-flat '("<span>yourmod.exact-c-file-filename</span>") output: "<span>yourmod.exact-c-file-filename</span>.o1.c")<br>


<br>Then compile:<br><br>(include the other arguments your gsc passes to gcc, as per the advice at the top)<br>gcc <span>yourmod.exact-c-file-filename </span><span>yourmod.exact-c-file-filename.o1.c -o "</span><span>yourmod.exact-c-file-filename.o1"<br>


<br></span>you could give a shot with:<br><br>g++    -Wall -W -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -O1 
-fno-math-errno -fschedule-insns2 -fno-trapping-math 
-fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common 
-mieee-fp -rdynamic -shared -I"/usr/include/"  -D___DYNAMIC <span>yourmod.exact-c-file-filename</span> <span>yourmod.exact-c-file-filename</span>.o1.c -o "<span>yourmod.exact-c-file-filename</span><span class="il"></span>.o1"<br>

<br><span></span><br> <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div></div><div>
I attach the generated files. In order to try it, you can just use:</div>
<div><font face="arial, sans-serif" color="#222222">g++ test.o1.c test-ct.c test-rt.c test-vt.c test-mi.c -lm -lutil -ldl -lgambc -o test.o</font></div>


<div><font face="arial, sans-serif" color="#222222">...and you'll get an (expected) undefined reference to main and all the multiple definitions I talk about.</font></div></blockquote><div><br>Check with the suggested g++ use above, any improvement?<br>

<br> <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>Best regards</div></blockquote><div><br>Mikael<br> <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div><br></div><div><br>

</div><br><div class="gmail_quote">On Sun, Jan 8, 2012 at 8:00 PM, Mikael <span dir="ltr"><<a href="mailto:mikael.rcv@gmail.com" target="_blank">mikael.rcv@gmail.com</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As to make BH compile to C rather than object files, pass to-c: #t to module-compile! .<br><br>What's the first 4 of the 5 files you mention below? (Format, content, when needed / scope of use, and so on)<br>







<br>The link file is produced by BH at some point (presuming by link file you mean link file as per Gambit's definition). To make a C link file out of Gambit, I don't remember, either there's a special BH procedure for it, or you do it the general way it's done in Gambit, please let the ml know what you got to, and if it's not obvious please query again.<br>









<br>Mikael<br><br><div class="gmail_quote">2012/1/8 Įlvaro Castro-Castilla <span dir="ltr"><<a href="mailto:alvaro.castro.castilla@gmail.com" target="_blank">alvaro.castro.castilla@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">







<div><div>

Hi!<div><br></div><div>I'm trying (again) to make Blackhole work with Android. For that purpose I need to make it compile to C, instead of its normal *.o files. BH needs to compile 5 files for each module:</div><div>








- a compile-time file</div>


<div>- a real-time file</div><div>- a visit-time file</div><div>- a module metadata file</div><div>- the link file</div><div><br></div><div>Based on <a href="https://github.com/seoushi/gambit-android-example" target="_blank">https://github.com/seoushi/gambit-android-example</a> but using the newer "Native Activity" I'm trying to compile an example. First, I'm trying to compile an example with just one file, importing no modules.</div>











<div><br></div><div>I'm getting:</div><div><div>     [exec] ./jni/ext/libgambc.a(_gambc.o):(.data+0x4854c): multiple definition of `___G_list'</div><div>     [exec] ./obj/local/armeabi/objs/native-activity/main.o1.o:(.data+0x3c): first defined here</div>











<div>     [exec] ./jni/ext/libgambc.a(_gambc.o):(.data.rel+0x13708): multiple definition of `___S_list'</div><div>     [exec] ./obj/local/armeabi/objs/native-activity/main.o1.o:(.data.rel+0xb0): first defined here</div>











<div>     [exec] ./jni/ext/libgambc.a(_gambc.o):(.data+0x5ae40): multiple definition of `___G_void'</div><div>     [exec] ./obj/local/armeabi/objs/native-activity/main.o1.o:(.data+0x54): first defined here</div><div>










     [exec] ./jni/ext/libgambc.a(_gambc.o):(.data.rel+0x19138): multiple definition of `___S_void'</div>
<div>     [exec] ./obj/local/armeabi/objs/native-activity/main.o1.o:(.data.rel+0xe0): first defined here</div></div><div><br></div><div>I would like to know if any of you had similar experiences, and why I'm getting this multiple definitions? The link file (called main.o1.c) seems to redefine these symbols, but they are also defined in libgambc.a (which is compiled for ARM architecture)</div>











<div>Why could this be happening?</div><div><br></div><div>I'd appreciate any pointers. Thanks a lot for your help,</div><span><font color="#888888"><div><br></div><div>Įlvaro Castro-Castilla</div>
</font></span><br></div></div>_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br></blockquote></div><br>
</blockquote></div><br>
</div></div></blockquote></div><br>