Unable to use libcurl with cffi on Windows 10 - windows

I am playing with the CFFI tutorial on Windows 10 and have installed the libcurl-devel package using msys2. I found a file libcurl.dll.a in the directory c:\msys2\usr\lib\ and added this directory to *foreign-library-directories* using:
(pushnew #P"c:/msys64/usr/lib/" *foreign-library-directories*
:test #'equal)
But if I try (use-foreign-library libcurl) I get the following error:
Unable to load foreign library (LIBCURL).
Error opening shared object "libcurl.dll"
What am I missing? I tried to point to libcurl.dll.a directly but the error stays the same:
(define-foreign-library libcurl
(:darwin (:or "libcurl.3.dylib" "libcurl.dylib"))
(:unix (:or "libcurl.so.3" "libcurl.so"))
(t "libcurl.dll.a"))
Here is the complete code as given in the tutorial:
(asdf:load-system :cffi)
;;; Nothing special about the "CFFI-USER" package. We're just
;;; using it as a substitute for your own CL package.
(defpackage :cffi-user
(:use :common-lisp :cffi))
(in-package :cffi-user)
(pushnew #P"c:/msys64/usr/lib/" *foreign-library-directories*
:test #'equal)
(define-foreign-library libcurl
(:darwin (:or "libcurl.3.dylib" "libcurl.dylib"))
(:unix (:or "libcurl.so.3" "libcurl.so"))
(t (:default "libcurl")))
(use-foreign-library libcurl)
EDIT
I am using SBCL 1.4.16 from the portacle package.
EDIT 2
Just for the sake of completeness. If I change define-foreign-library to
(define-foreign-library libcurl
(:darwin (:or "libcurl.3.dylib" "libcurl.dylib"))
(:unix (:or "libcurl.so.3" "libcurl.so"))
(t "libcurl.dll.a"))
the errors changes:
Unable to load foreign library (LIBCURL).
Error opening shared object "c:\\msys64\\usr\\lib\\libcurl.dll.a":
%1 ist keine zulässige Win32-Anwendung.
As far as I understand at least the file is found but seems not to be in the right format. I didn't find any further information about the difference between dynamic (.dll) and static (.dll.a) files with respect to cffi and don't have the resources at the moment to further investigate this.

Instead of using use-foreign-library, try loading load-foreign-library. It is lower level code, but it will allow you to experiment with files and paths.
Also use cygcheck to figure out what libcurl.dll depends on. Then make sure you have the components installed, and that they are in PATH.
Finally, check where libcurl.dll lives in your MSYS2. On my system it is in /c/msys64/mingw64/bin/libcurl-4.dll

Related

How do I install shared data on Windows with CPack?

I'm trying to install some data which would be shared between a few different programs we make. The signs seem to point to C:\ProgramData\${CompanyName}, which is fine, but of course CPack objects to absolute paths.
In this case, I'm targeting the WIX installer.
I can't seem to find any documentation which says what I ought to be using.
INSTALL (FILES ../config/netstat_protocol.xml DESTINATION ${INSTALL_OCU_DIR} )
If I want INSTALL_OCU_DIR to resolve to something like C:\ProgramData\MyCompanyName\ocu, what's the right way?
Here are the lines I last tried:
set(INSTALL_OCU_DIR "%PROGRAMDATA%/CyPhy/ocu")
INSTALL(DIRECTORY DESTINATION ${INSTALL_OCU_DIR} DIRECTORY_PERMISSIONS WORLD_READ WORLD_WRITE WORLD_EXECUTE)
INSTALL (FILES ../config/netstat_protocol.xml DESTINATION ${INSTALL_OCU_DIR} )
This results in the error: Executing op:
SetTargetFolder(Folder=C:\Program Files\cyocu 2.0.0\%PROGRAMDATA%\CyPhy\ocu\)

Glib-GIO-ERROR when opening an file chooser dialog

I use GTK3 , codeblcks IDE, glade3 in windows 7...
In my application i have a button which when clicked should open a gtk_file_chooser_dialog...
But gives the fillowing error..
Glib-GIO-ERROR**:No GSettings schemas are installed on the system
static void on_save_clicked(GtkWidget *widget,gpointer data)
{
GtkWidget *dialog;
//dialog=gtk_file_chooser_dialog_new("Save it",GTK_WINDOW(gtk_builder_get_object(builder,"mainwindow")),GTK_FILE_CHOOSER_ACTION_SAVE,GTK_STOCK_OK,GTK_RESPONSE_OK,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL);
//dialog=GTK_FILE_CHOOSER_DIALOG(gtk_builder_get_object(builder,"filechooserdialog"));
gtk_widget_show_all(dialog);
gint resp=gtk_dialog_run(GTK_DIALOG(dialog));
if(resp==GTK_RESPONSE_OK)
g_print("%s\n",gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
}
I use g_signal_connect(...) to call this function when the button is clicked...
I cannot understand the problem...
I got the very same error when trying to open a FileChooserDialog.
(lancer_ihm.py:1047004): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup: assertion 'source != NULL' failed
(lancer_ihm.py:1047004): GLib-GIO-ERROR **: No GSettings schemas are installed on the system
Trace/breakpoint trap (core dumped)
I 'm running a Gtk3 interface with python3 on Linux.
Gtk3 and all its dependencies were installed from the sources.
I found the solution on this forum http://forum.tinycorelinux.net/index.php?topic=13699.0
I just set XDG_DATA_DIRS variable with the path to where the gtk schema files are located and it works.
$ ls /home/user1/ctcils/dusserm/applications/gtk/3.12.1/share/glib-2.0/schemas/
gschemas.compiled org.gtk.exampleapp.gschema.xml org.gtk.Settings.FileChooser.gschema.xml
org.gtk.Demo.gschema.xml org.gtk.Settings.ColorChooser.gschema.xml
$ export XDG_DATA_DIRS=/Produits/publics/x86_64.Linux.RH6/glib/2.40.0/share/:/home/user1/ctcils/dusserm/applications/gtk/3.12.1/share/
There are probably few errors in there.
If you commented both, the dialog.show_all () will produce error because, it hasn't been instantiate yet you asked to be shown.
If you use the first one, object Gtk.FileChooserDialog param has to end with NULL (in c), read the doc
If you use the second one, check your glade signal property in your glade window
Check your gtk installation
Quoting from this StackOverflow answer,
Seems you're not the one having this problem, and it also happens on Windows on MinGW. Luckily, that person gave a solution:
The thing, as it seems as I was running the test-widget example (that I
built with gtksourceview-3.0.0 using MSVC), was that I need to compile the
org.gtk.Settings.FileChooser.gschema.xml file (from GTK+-3.x, under
$(srcroot)/gtk) with the glib-compile-schemas utility that is from GLib,
which will generate gschemas.compiled in the same folder.
After that, place that gschemas.compiled file in the this folder:
$(parent_folder_of_the_gtk3_dll)\share\glib-2.0\schemas
and one will be set to use the gtkfilechooser without the puzzling
[GLib-GIO-ERROR **: Settings schema 'org.gtk.Settings.FileChooser'
is not installed] error.
I will add to my GLib project files to compile the glib-compile-schemas
utility and add to my GTK+-3.x project files to compile the
the org.gtk.Settings.FileChooser.gschema.xml shortly.

F# Microsoft.ParallelArrays not defined

So I downloaded and installed Microsoft Accelerator v2 to use ParallelArrays. I have referenced it in my project but when I try and execute the code from the module in a script file I get:
"The namespace 'ParallelArrays' is not defined
I have followed the instructions on this post:
Microsoft Accelerator library with Visual Studio F#
I've added a reference to the managed version "Microsoft.Accelerator.dll" to my F# project and then added the native "Accelerator.dll" as an item in my solution and set it's 'Copy To Output Directory' to Copy Always.
Still getting the FSI error and inline error in my script file on the '#load ...' line, however the solution builds fine, and no error in the module file.
Any ideas on what I'm missing? I'm sure it's something stupid.
Thanks,
Justin
UPDATE
I tried mydogisbox's advice, which got rid of the error above, but now when I run the code in the .fsx file I get this error instead:
--> Referenced 'F:\Work\GitHub\qf-sharp\qf-sharp\bin\Debug\Microsoft.Accelerator.dll' (file may be locked by F# Interactive process)
[Loading F:\Work\GitHub\qf-sharp\qf-sharp\MonteCarloGPU.fs]
error FS0192: internal error: F:\Work\GitHub\qf-sharp\qf-sharp\Accelerator.dll: bad cli header, rva 0
UPDATE 2
So the bad header error has dissapeared, but now I get this instead:
Microsoft.ParallelArrays.AcceleratorException: Failure to create a DirectX 9 device.
at Microsoft.ParallelArrays.ParallelArrays.ThrowNativeAcceleratorException()
at Microsoft.ParallelArrays.DX9Target..ctor()
at <StartupCode$FSI_0002>.$FSI_0002_MonteCarloGPU.main#() in F:\Work\GitHub\qf- sharp\qf-sharp\MonteCarloGPU.fs:line 14
Stopped due to error
I found this thread on MSDN however the answers proposed as fixes on that thread barely even relate to the question.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/98600646-0345-4f62-a6c5-f03ac9c77179/ms-accelerator?forum=csharpgeneral
My Direct X version is 11, and I imagine that will suffice, however I tried installing DX9 however, it tells me that a newer version is detected therefore cant install.
There are special directives for referencing dlls from fsi. The #load directive loads the .fs file only. You need to use the #r directive to reference the file. You can either use the full path of the file or you can use #I to include the path to the file. More details here. Keep in mind that fsi is completely independent of your project, so all references in your project must be duplicated in fsi for it to access the same types.

erlang debug_info option - inside module or during compilation?

After overcoming some troubles with installation I tried to use erlang debugger on simple module:
I included -compile([debug_info]). option in source file and compiled with:
1> c(test_module).
This did not work as expected: After running
2> debugger:start().
the monitor window appeared, then I clicked
Module->Interpret...->test_module.erl
and got error
"Error when interpreting: test_module.erl: No debug_info in BEAM file".
Deleting -compile([debug_info]). line and changing
1> c(test_module).
to
1> c(test_module, [debug_info]).
solved the problem.
What is the difference between these two ways of setting compilation option, why one works and the other does not?
According to the docs, the two ways should be equivalent:
Note that all the options except the include path ({i,Dir}) can also
be given in the file with a -compile([Option,...]). attribute.
(From Erlang -- compile doc)
Check this question for more info.

Resurrecting old PLT-Scheme project (pre-1999)

I'm trying to resurrect an old (1999 or earlier) project written in Scheme (PLT-Scheme, using the mzscheme interpreter (?) commandline tool). To make the matters worse, I don't know Scheme, or Lisp (in fact, I want to learn, but that's another story).
I have the source code of the project at:
github.com/akavel/sherman
Now, when running the code, it bails out with an error message like below:
Sherman runtime version 0.5
Hosted on MzScheme version 52, Copyright (c) 1995-98 PLT (Matthew Flatt)
reference to undefined identifier: list->block
(I've tried PLT-Scheme versions 52, 53, 103, 103p1. Earlier versions don't allow mzscheme -L option, which is referenced in the sherman.bat script used in the project. Later versions also have some more serious problems with the code or options.)
The difficulty is, that from what I see, list->block actually is defined - see: collects/sherman/BLOCK.SS line 48. So, what is wrong?
To run the code, I perform the following steps:
Download PLT-Scheme v. 103p1 (from the old versions download page - first closing the "PLT Scheme is now Racket" banner) - for Windows, use: mz-103p1-bin-i386-win32.zip.
Unzip (e.g. to directory c:\PLT).
Copy c:\sherman\collects\sherman directory with contents to: c:\PLT\collects\sherman (where c:\sherman contains the contents of the github repository).
Run cmd.exe, then cd c:\sherman.
set PATH=c:\PLT;%PATH%
sherman.bat run trivial.s
this command is in fact, from what I understand, equivalent to:
(require-library "runtime.ss" "sherman")
(parameterize ((current-namespace sherman-namespace)) (load "trivial.s"))
(current-namespace sherman-namespace)
After that, I get the error as described above (MzScheme version would be reported as 103p1 or whatever).
Could you help me solve the problem?
EDIT 2: SOLVED!
To whom it may concern, I've added a fully fledged "How to use this project" instruction on the project page, detailing the solution to the problem thanks to soegaard's help.
In short:
copy trivial.s trivial.rs
rem (the above is workaround for problems with 'r2s.exe < trivial.r > trivial.rs')
sherman.bat compile trivial.rs
sherman.bat run trivial.zo
rem (or: sherman.bat run trivial.ss)
Not an answer, but a few notes too big for a comment.
1. Sanity Check
The error message says list->block is undefined.
Make sure that the code in block.ss is run, by
inserting (display "block.ss is loaded!") in block.ss
just to make sure, the code is run.
2. Random Thoughts
The file blocks.ss begins with:
(require-library "functios.ss")
(require-library "synrule.ss")
(require-library "stream.ss" "sherman")
The file "sherman/stream.ss" is in the repository,
but where is "synrule.ss" and "functios.ss" ?
Ah... This code is old! Here is a description of
how require-library worked. It lists functios.ss
and synrule.ss as part of MzLib.
http://www.informatik.uni-kiel.de/~scheme/doc/mzscheme/node158.htm
Let's check out how require-library worked:
When require-library is used to load a file, the library name and the
resulting value(s) are recored in a table associated with the current
namespace. If require-library is evaluated for a library that is
already registered in the current namespace's load table, then the
library is not loaded again; the result(s) recorded in the load table
is returned, instead.
So when the code in block.ss is run, the names are stored in a namespace. If the current namespace is the wrong one, when the code in block.ss is evaluated, it would explain you error message of list->block being undefined.

Resources