System image building in Julia - compilation

I'm trying to compile a custom system image of Julia to speed up the loading of some libraries, specially Gadfly. I tried the docs tutorial but Julia complains about undefined paths (it makes me require every single library) and after linking all of them about undefined variables STDOUT and STDERR. If I don't use a userimg.jl file the compilation works perfectly.
I first tried a userimg.jl file with only
include("/home/clavero/.julia/v0.4/Gadfly/src/Gadfly.jl")
but it complained about libraries not in path, with error messages like
Base.ArgumentError(msg="Codecs not found in path")
so I started including about 30 libraries in the correct order only to arrive at the errors about STDERR and STDOUT.
I'm running Julia as root to have write permission in the needed files, and runing in the root REPL homedir() gives me /root, so I suspect is a path problem.
How can I generate a custom image with Gadfly in it? Did I follow the guide wrong?

Because julia 0.4 supports package precompilation, for me loading Gadfly (with using Gadfly) is not too bad, certainly not as big of a problem as the JIT-delay in generating the first plot. So simply building in Gadfly via userimg.jl won't help much.
However, you could add precompile statements to eliminate the delay. The following may be helpful:
https://github.com/timholy/SnoopCompile.jl
https://github.com/dcjones/Gadfly.jl/pull/673
http://julia-programming-language.2336112.n4.nabble.com/Precompilation-and-functions-with-keyword-arguments-td32038.html

Related

How can I use a Common Lisp (Clozure CL) Library?

I'm learning Common Lisp (Clozure CL) on the Mac and would like to create a simple GUI. I have downloaded the "ltk" library from CLiki and put it into the project directory at the root level (I assumed I had to do this as I couldn't find instructions for a beginner).
Page 4 of the "LTK - a Lisp binding to the Tk toolkit" documentation says that the library should be compiled using (compile-file "ltk") before loading the library using (load "ltk"). However, I get this error message:
Error: File #P"/Users/myName/Desktop/lisp_experiments/GUI_EXAMPLE/ltk" not found
While executing: CCL::FCOMP-FIND-FILE, in process Listener(4).
Type cmd-. to abort, cmd-\ for a list of available restarts.
Type :? for other options.
I also used the full file pathname and got the same error.
What am I doing wrong?
Thanks for your help.
Marc
ps - there are almost no noob tutorials about this sort of thing online that takes the user through the process step by step.
I have downloaded the "ltk" library from CLiki and put it into the project directory at the root level.
Nowadays, this is a step that is seldom required, because libraries are easily accessible using Quicklisp (see also this gif).
Basically, you should be able to install Quicklisp and run the following:
(ql:quickload "ltk")
The above downloads, compiles and install Lisp libraries, but not necessarily the required C libraries, which you might need to install separately. If the above works without problem, then the following should work too:
(ltk:ltktest)
Quicklisp relies on Lisp systems being described with ASDF (Another System Definition Facility). The best practices document is also interesting to read.
In the case of LTK, you can see that ltk.asd only specifies one component, ltk.lisp. When you install the system named "LTK", quicklisp will do all the necessary work to install its dependencies, then compile and load ltk.lisp, as described in the manual.
What is unclear is why your explicit compile-file failed.
I found the ltk.lisp file on my machine; its pathname looks like:
#P"/home/user/quicklisp/dists/quicklisp/software/ltk-20150113-http/ltk.lisp"
Sure enough, calling compile-file with that pathname works and returns another pathname which ends in .fasl (the object format). Loading the returned pathname loads the library. Please provide more information about the error so that we can help you debug this problem.

Python/C API: Statically-Linked Extensions?

I've been writing a Python extension use the Python/C API to read data out of a .ROOT file and store it in a list of custom objects. The extension itself works just fine, however when I tried to use it on a different machine I ran into some problems.
The code depends upon several libraries written for the ROOT data manipulation program. The compiler is linking these libraries dynamically, which means I cannot use my extension on a machine that does not have ROOT installed.
Is there a set of flags that I can add to my compilation commands to make these libraries statically linked? Obviously this would make the file size much larger but that isn't much of an issue providing that the code runs at the same speed.
I did think about collating all of the ROOT libraries that I need into an 'archive' file. I'm not too familiar with this so I don't know if that's a good idea or not.
Any advice would be great, I've never really dealt with the static/dynamic library issue before.
Thanks, Sean.

CMake not finding SDL - Windows

I am trying to build a program that requires SDL. I have downloaded SDL for Windows so that I have a folder containing the include and lib suborders.
When I run CMake I get the following error:
Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
This is despite the fact that I have created two environment variables called SDL_LIBRARY and SDL_INCLUDE_DIR, pointing to the lib and include folders respectively.
I have no idea what to do.
In my experience, the best method when find scripts don't work as expected is to check their source code. Often you will identify the problem by just reading through the documentation at the top, but if that still doesn't work out, digging into the source is often the only thing that helps.
From the documentation alone you can see for instance, that CMake does only consider one environment variable SDLDIR for searching. SDL_INCLUDE_DIR and SDL_LIBRARY are the names of the CMake variables to hold the results of the find script. You can set them via the command line (or the cmake-gui), but I would advise against that, as it kind of undermines the purpose of using a find script in the first place.
Instead, verify that your directory structure corresponds to what the find script expects and simply set SDLDIR accordingly.
Please note that the script that currently ships with CMake does not work with the newer SDL2. If you are using SDL2, you will have to write your own script.

WDL-OL: resource not found

i'm trying to build a simple Audio plugin using WDL-OL (a library that helps porting the plugin on various platforms) on OSX. The plugin builds ok on Windows
as soon as it tries to load a resource background file, i got an ASSERT warning that the file isn't found
1 my files are present in the Copy Bundle Resources part
2 i've tried all kind of combinations with/without subfolder, with caps or not
i'm lost there i don't get why it doesn't find the file
if i create a simple test it works, it finds the file knob.png but with my project it doesn't work
also if i point to the file knob.png (that should work), it doesn't work in my new project, so my guess is that it isn't the png files that are wrong. It comes from somewhere else...
here is what i used in the resource.h:
#define BCKG_ID 102
#define BCKG_FN "resources/img/background2.png"
and i call the background using this code :
pGraphics->AttachBackground(BCKG_ID, BCKG_FN);
please help, thanks
Jeff
EDIt1 : okay i found something interesting
in MyProject-OSXAPP-Info.plist, "Bundle Identifier" is set to : com.Khaelis.standalone.${BINARY_NAME}
but if i stop the program at the function LoadImgFromResourceOSX(...) and look at the variable "bundleID", it shows:
"bundleID = com.Khaelis.standalone.test"
even if i entered another BINARY_NAME (in MyProject.xcconfig)
how come ? the compiler doesn't apply the name i put.
the variable "bundleID" should be com.Khaelis.standalone.PerfectEQ not com.Khaelis.standalone.test
is there a file that i should update?
ok found it
if you ever encounter this kind of error (resource not found) check if the Bundle Name (in resource.h) and BINARY_NAME (in Project.xcconfig) are the same
then it should work
Jeff

Issues compiling libf2c w/ latest mingw-get-inst (3.16.11), gcc

I'm trying to port some very old fortran code to windows. I'd like to use mingw and f2c, which has no problem converting the code to usable C on OS X and Ubuntu. I used f2c.exe as distributed by netlib on a fresh install of mingw, and it translated the code fine. I have a "ported" version of libf2c that seems to still contain some unresolved references -- mostly file i/o routines (do_fio, f_open, s_wsfe, e_wsfe) and, peculiarly, one arithmetic routine (pow_dd). To resolve these issues, I tried to build libf2c from source, but ran into an issue during the make process. The make proceeds to dtime_.c, but then fails due to a dependency on sys/times.h, which is no longer a part of the mingw distro. There appears to be a struct defined in times.h that defines the size of a variable in dtime_.c, specifically t and t0 on lines 53 and 54 (error is "storage size of 't' isn't known"; same for t0).
The makefile was modified to use gcc, and make invoked with no other options passed.
Might anyone know of a workaround for this issue? I feel confident that once I have a properly compiled libf2c, I'll be able to link it with gcc and the code will work like it does on linux and os X.
FOLLOW-UP: I was able to build libf2c.a by commenting out the time related files in the makefile (my code does not contain any time related functions, so don't think it will matter). I copied it to a non-POSIX search directory as show in -print-search-dirs, specifically C:\MinGW\lib\gcc\mingw32\3.4.5. That seems to have fixed the issue on the unresolved references, although the need to eliminate the time files does concern me. While my code is now working, the original question stands -- how to handle makefiles that call for sys/times.h in mingw?
Are you sure the MinGW installation went correct? As far as I can tell the sys/times.h header is still there, in the package mingwrt-3.18-mingw32-dev.tar.gz. I'm not familiar with the gui installer, but perhaps you have to tick a box for the mingwrt dev component.

Resources