public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* Building libffi with MSVC
@ 2012-12-05 18:38 John Emmas
  2012-12-05 23:13 ` Peter Rosin
  0 siblings, 1 reply; 11+ messages in thread
From: John Emmas @ 2012-12-05 18:38 UTC (permalink / raw)
  To: libffi-discuss

Not sure if I need to subscribe to this list before posting (if so, I couldn't find out where I need to subscribe).  Anyway...

I'm currently building libglib (using MSVC) for which I first need to build libffi.  However, from various things I've read, this doesn't seem to be possible without first installing cygwin.  Cygwin (apparently) is only needed for running the 'configure' utility.  Have I understood this correctly or is it possible to build libffi using MSVC but without needing Cygwin?

John Emmas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-05 18:38 Building libffi with MSVC John Emmas
@ 2012-12-05 23:13 ` Peter Rosin
  2012-12-06  4:59   ` John Emmas
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Rosin @ 2012-12-05 23:13 UTC (permalink / raw)
  To: John Emmas; +Cc: libffi-discuss

On 2012-12-05 19:38, John Emmas wrote:
> Not sure if I need to subscribe to this list before posting (if so, I couldn't find out where I need to subscribe).  Anyway...
> 
> I'm currently building libglib (using MSVC) for which I first need to build libffi.  However, from various things I've read, this doesn't seem to be possible without first installing cygwin.  Cygwin (apparently) is only needed for running the 'configure' utility.  Have I understood this correctly or is it possible to build libffi using MSVC but without needing Cygwin?

I made some notes in:
http://sourceware.org/ml/libffi-discuss/2012/msg00144.html

Cheers,
Peter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-05 23:13 ` Peter Rosin
@ 2012-12-06  4:59   ` John Emmas
  2012-12-06  7:22     ` Nathan Rajlich
  2012-12-06 12:10     ` Peter Rosin
  0 siblings, 2 replies; 11+ messages in thread
From: John Emmas @ 2012-12-06  4:59 UTC (permalink / raw)
  To: libffi-discuss


On 5 Dec 2012, at 23:13, Peter Rosin wrote:

> 
> I made some notes in:
> http://sourceware.org/ml/libffi-discuss/2012/msg00144.html
> 

Thanks Peter,

That all looks 'do-able' - given enough time.  In the meantime though, is there anywhere where I can obtain a 'dev' version for MSVC?  i.e. the usual import lib, DLL and header files?  I tried the 'cheap & dirty' approach of downloading the standard (MinGW?) dev version and simply renaming libffi.dll.a and calling it libffi.lib.  Often that does work (well, at least enough to get me started) but it didn't work in this case (the various symbols weren't recognised by MSVC's linker).

I do have some experience with Cygwin as well as TDM-GCC (a version of MinGW, I'm led to believe) but I haven't yet encountered MSYS.

I'm sure this'll sound like a dumb question - but since the 'configure' shell gets provided by MSYS, why is there any need to involve Cygwin in the process?  Surely MSYS and TDM-GCC would suffice?

John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-06  4:59   ` John Emmas
@ 2012-12-06  7:22     ` Nathan Rajlich
  2012-12-06  8:26       ` John Emmas
  2012-12-06 12:10     ` Peter Rosin
  1 sibling, 1 reply; 11+ messages in thread
From: Nathan Rajlich @ 2012-12-06  7:22 UTC (permalink / raw)
  To: John Emmas; +Cc: libffi-discuss

Hey John,

I maintain node-ffi, a node.js wrapper for libffi. For that we use the
GYP build system, which produces MSVS project files. It may be able to
suit your needs without getting Cygwin or MSYS involved. The GYP file
is here: https://github.com/rbranson/node-ffi/blob/master/deps/libffi/libffi.gyp

Cheers!

On Wed, Dec 5, 2012 at 8:58 PM, John Emmas <johne53@tiscali.co.uk> wrote:
>
> On 5 Dec 2012, at 23:13, Peter Rosin wrote:
>
>>
>> I made some notes in:
>> http://sourceware.org/ml/libffi-discuss/2012/msg00144.html
>>
>
> Thanks Peter,
>
> That all looks 'do-able' - given enough time.  In the meantime though, is there anywhere where I can obtain a 'dev' version for MSVC?  i.e. the usual import lib, DLL and header files?  I tried the 'cheap & dirty' approach of downloading the standard (MinGW?) dev version and simply renaming libffi.dll.a and calling it libffi.lib.  Often that does work (well, at least enough to get me started) but it didn't work in this case (the various symbols weren't recognised by MSVC's linker).
>
> I do have some experience with Cygwin as well as TDM-GCC (a version of MinGW, I'm led to believe) but I haven't yet encountered MSYS.
>
> I'm sure this'll sound like a dumb question - but since the 'configure' shell gets provided by MSYS, why is there any need to involve Cygwin in the process?  Surely MSYS and TDM-GCC would suffice?
>
> John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-06  7:22     ` Nathan Rajlich
@ 2012-12-06  8:26       ` John Emmas
  2012-12-09 19:00         ` Nathan Rajlich
  0 siblings, 1 reply; 11+ messages in thread
From: John Emmas @ 2012-12-06  8:26 UTC (permalink / raw)
  To: Nathan Rajlich; +Cc: libffi-discuss

On 6 Dec 2012, at 07:21, Nathan Rajlich wrote:

> 
> I maintain node-ffi, a node.js wrapper for libffi. For that we use the
> GYP build system, which produces MSVS project files. It may be able to
> suit your needs without getting Cygwin or MSYS involved.
> 

Thanks Nathan.  I'm not averse to trying MSYS but if possible, I'd prefer to keep Cygwin out of the equation.  I tried Cygwin a few years ago and to be fair, I found it pretty good.  However, the main support developer was extraordinarily unhelpful and I ended up kicking Cygwin into the long grass.  To be absolutely honest, I'd prefer it to stay there!

How do I install GYP?  It looks like the kind of thing that should be available in binary form - but all I could find were the source files.

John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-06  4:59   ` John Emmas
  2012-12-06  7:22     ` Nathan Rajlich
@ 2012-12-06 12:10     ` Peter Rosin
  2012-12-07  5:50       ` John Emmas
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Rosin @ 2012-12-06 12:10 UTC (permalink / raw)
  To: John Emmas; +Cc: libffi-discuss

On 2012-12-06 05:58, John Emmas wrote:
> 
> On 5 Dec 2012, at 23:13, Peter Rosin wrote:
> 
>>
>> I made some notes in:
>> http://sourceware.org/ml/libffi-discuss/2012/msg00144.html
>>
> 
> Thanks Peter,
> 
> That all looks 'do-able' - given enough time.  In the meantime though, is
> there anywhere where I can obtain a 'dev' version for MSVC?  i.e. the usual
> import lib, DLL and header files?  I tried the 'cheap & dirty' approach of
> downloading the standard (MinGW?) dev version and simply renaming
> libffi.dll.a and calling it libffi.lib.  Often that does work (well, at
> least enough to get me started) but it didn't work in this case (the various
> symbols weren't recognised by MSVC's linker).

I will not recommend that in this case even if you did get it to link.
GCC has incompatible calling convention in some corner cases.

> I do have some experience with Cygwin as well as TDM-GCC (a version of
> MinGW, I'm led to believe) but I haven't yet encountered MSYS.

MSYS is a fork (an old one) of Cygwin, designed to support native (MinGW)
apps better.

> I'm sure this'll sound like a dumb question - but since the 'configure'
> shell gets provided by MSYS, why is there any need to involve Cygwin in
> the process?  Surely MSYS and TDM-GCC would suffice?

'configure' is not "provided by MSYS". 'configure' is provided by whomever
runs autoconf. That might be you in an MSYS shell, but that's not at all
necessary, and indeed, if you are using a released libffi tarball, the
'configure' script is provided for you. What MSYS will do is provide all
the tools needed when you actually run the 'configure' script (bash, gawk,
sed, etc). However, MSYS lacks some of the more complex tools needed
by the libffi testsuite, and I went for the hybrid Cygwin/MSYS setup
described in the referenced post when I satisfied those dependencies.

I think you can skip Cygwin if you don't want to run the testsuite.

<rant>
I sympathize with the Cygwin project leads when it comes to helping
persons that refuse to help themselves and expect everything to be
provided for them (which is generally what they frown upon). I don't
know the specifics of your experience, but you are begging for more
even if you have been given a fairly detailed description of how to
help yourself. In other words, I will not build the libraries for
you. Heck, I don't even know what version of MSVC you are using, or
what runtime you wish to use, so how could I? If you expect all
possible combinations to just magically appear you need to think
again. This is open *source*.
</rant>

Cheers,
Peter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-06 12:10     ` Peter Rosin
@ 2012-12-07  5:50       ` John Emmas
  0 siblings, 0 replies; 11+ messages in thread
From: John Emmas @ 2012-12-07  5:50 UTC (permalink / raw)
  To: libffi-discuss

Peter, I think you were reading too much into my emails.  I never asked you to build anything for me.  I simply asked if there were any 'dev' libraries available for MSVC.  It's hardly an unreasonable question.  Many open source projects provide pre-built dev libraries.  It's quite common in my experience.

Anyway, the good news is that with only a little perseverance, it's possible to build libffi-5.dll using only MSVC and no outside tools.  After creating the VS project, it's pretty obvious which modules need to get added to it.  The only tricky bit was figuring out what to do with win32.S - but even that isn't massively tricky.  Also (for anyone building as a DLL) you'll need to create a module definition file (.def file).  Unlike MinGW, Visual Studio doesn't generate def files automatically.  I found that the easiest way was to use "dumpbin /EXPORTS" on a pre-built version of the DLL and simply edit the resulting file..  There are only a few dozen exported functions so it only takes a minute or so.

I haven't had an opportunity yet to test my DLL so I might move onto the test suite next week.

Thanks for all the suggestions.

John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-06  8:26       ` John Emmas
@ 2012-12-09 19:00         ` Nathan Rajlich
       [not found]           ` <9D1BB499-2031-4155-9570-771B5929D56C@tiscali.co.uk>
  0 siblings, 1 reply; 11+ messages in thread
From: Nathan Rajlich @ 2012-12-09 19:00 UTC (permalink / raw)
  To: John Emmas; +Cc: libffi-discuss

Hey John,

Read again, gyp generates MS Visual Studio (MSVS) project files. I was
specifying how the resulting project files *would not* need Cygwin or
MSYS, which is what it sounded like you wanted.

As for how to install gyp, it's a Python project from Google. You need
Python 2.6 or 2.7 (not 3 though) and just check out the svn repo.

It sounds like you got things figured out though doing it manually so,
good stuff. Cheers!

On Thu, Dec 6, 2012 at 12:26 AM, John Emmas <johne53@tiscali.co.uk> wrote:
> On 6 Dec 2012, at 07:21, Nathan Rajlich wrote:
>
>>
>> I maintain node-ffi, a node.js wrapper for libffi. For that we use the
>> GYP build system, which produces MSVS project files. It may be able to
>> suit your needs without getting Cygwin or MSYS involved.
>>
>
> Thanks Nathan.  I'm not averse to trying MSYS but if possible, I'd prefer to keep Cygwin out of the equation.  I tried Cygwin a few years ago and to be fair, I found it pretty good.  However, the main support developer was extraordinarily unhelpful and I ended up kicking Cygwin into the long grass.  To be absolutely honest, I'd prefer it to stay there!
>
> How do I install GYP?  It looks like the kind of thing that should be available in binary form - but all I could find were the source files.
>
> John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
       [not found]           ` <9D1BB499-2031-4155-9570-771B5929D56C@tiscali.co.uk>
@ 2012-12-10 19:48             ` Nathan Rajlich
  2012-12-11 17:34               ` John Emmas
  0 siblings, 1 reply; 11+ messages in thread
From: Nathan Rajlich @ 2012-12-10 19:48 UTC (permalink / raw)
  To: John Emmas; +Cc: libffi-discuss

Yes those instructions at the top are for a Unix system. For Windows,
try something like this:

  $ svn co http://gyp.googlecode.com/svn/trunk gyp
  $ gyp\gyp.bat -f msvs -G msvs_version=2010 --depth=. libffi.gyp
  $ msbuild libffi.sln
  $ Debug\test.exe

Cheers!

On Sun, Dec 9, 2012 at 11:35 PM, John Emmas <johne53@tiscali.co.uk> wrote:
> On 9 Dec 2012, at 19:00, Nathan Rajlich wrote:
>
> Hey John,
>
> Read again, gyp generates MS Visual Studio (MSVS) project files. I was
> specifying how the resulting project files *would not* need Cygwin or
> MSYS, which is what it sounded like you wanted.
>
> As for how to install gyp, it's a Python project from Google. You need
> Python 2.6 or 2.7 (not 3 though) and just check out the svn repo.
>
>
> Hi Nathan.  You're right...  I must have mis-read "MSYS" instead of MSVS".
> Time to get some new reading glasses!
>
> At the moment I'm running both Python 2.7 and Python 3.1 (in separate
> folders) and I already have SVN installed, so it should be pretty trivial to
> install and try gyp.  I'm only confused about these instructions in
> libffi.gyp:-
>
> # To build try this:
> #   svn co http://gyp.googlecode.com/svn/trunk gyp
> #   ./gyp/gyp -f make --depth=`pwd` libffi.gyp
> #   make
> #   ./out/Debug/test
>
>
> They look like *nix commands and there still seems to be a dependency on
> 'make' and also a reference to Cygwin (further down the file).  So how do
> you use libffi.gyp, Nathan?  Are you running it entirely on Windows or are
> you running it on Linux and then transferring the finished VCPROJ file to a
> Windows system?
>
> John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-10 19:48             ` Nathan Rajlich
@ 2012-12-11 17:34               ` John Emmas
  2012-12-11 18:33                 ` Nathan Rajlich
  0 siblings, 1 reply; 11+ messages in thread
From: John Emmas @ 2012-12-11 17:34 UTC (permalink / raw)
  To: libffi-discuss

On 10 Dec 2012, at 19:47, Nathan Rajlich wrote:

> Yes those instructions at the top are for a Unix system. For Windows,
> try something like this:
> 
>  $ svn co http://gyp.googlecode.com/svn/trunk gyp
>  $ gyp\gyp.bat -f msvs -G msvs_version=2010 --depth=. libffi.gyp
> 

Thanks Nathan,

I installed gyp from subversion (as above), checked that I was using Python 2.7 and placed libffi.gyp into my main 'ffi' folder (in my particular case, F:\+GTK-SOURCES\gnu-win32\src\libffi).  I then ran the 2nd of the above lines (gyp.bat etc) and I received this error:-

gyp: name 'target_arch' is not defined while evaluating condition 'target_arch== "ia32"'
in libffi.gyp while trying to load libffi.gyp

Does that indicate any obvious problem?

John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Building libffi with MSVC
  2012-12-11 17:34               ` John Emmas
@ 2012-12-11 18:33                 ` Nathan Rajlich
  0 siblings, 0 replies; 11+ messages in thread
From: Nathan Rajlich @ 2012-12-11 18:33 UTC (permalink / raw)
  To: John Emmas; +Cc: libffi-discuss

Ohh good catch John! Looks like I didn't define the default
"target_arch" variable in the correct place. I've updated the gyp file
in the GitHub repo. Alternatively you can define the variable on the
command line doing:

  $ gyp\gyp.bat -f msvs -G msvs_version=2010 -Dtarget_arch=ia32
--depth=. libffi.gyp

On Tue, Dec 11, 2012 at 9:33 AM, John Emmas <johne53@tiscali.co.uk> wrote:
> On 10 Dec 2012, at 19:47, Nathan Rajlich wrote:
>
>> Yes those instructions at the top are for a Unix system. For Windows,
>> try something like this:
>>
>>  $ svn co http://gyp.googlecode.com/svn/trunk gyp
>>  $ gyp\gyp.bat -f msvs -G msvs_version=2010 --depth=. libffi.gyp
>>
>
> Thanks Nathan,
>
> I installed gyp from subversion (as above), checked that I was using Python 2.7 and placed libffi.gyp into my main 'ffi' folder (in my particular case, F:\+GTK-SOURCES\gnu-win32\src\libffi).  I then ran the 2nd of the above lines (gyp.bat etc) and I received this error:-
>
> gyp: name 'target_arch' is not defined while evaluating condition 'target_arch== "ia32"'
> in libffi.gyp while trying to load libffi.gyp
>
> Does that indicate any obvious problem?
>
> John

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-12-11 18:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-05 18:38 Building libffi with MSVC John Emmas
2012-12-05 23:13 ` Peter Rosin
2012-12-06  4:59   ` John Emmas
2012-12-06  7:22     ` Nathan Rajlich
2012-12-06  8:26       ` John Emmas
2012-12-09 19:00         ` Nathan Rajlich
     [not found]           ` <9D1BB499-2031-4155-9570-771B5929D56C@tiscali.co.uk>
2012-12-10 19:48             ` Nathan Rajlich
2012-12-11 17:34               ` John Emmas
2012-12-11 18:33                 ` Nathan Rajlich
2012-12-06 12:10     ` Peter Rosin
2012-12-07  5:50       ` John Emmas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).