This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 415757 - C Builds for Windows and Mac OS/X
Summary: C Builds for Windows and Mac OS/X
Status: RESOLVED WONTFIX
Alias: None
Product: Community
Classification: Eclipse Foundation
Component: CI-Jenkins (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: CI Admin Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 372091 (view as bug list)
Depends on: 427908
Blocks:
  Show dependency tree
 
Reported: 2013-08-23 09:05 EDT by Ian Craggs CLA
Modified: 2016-05-19 11:23 EDT (History)
7 users (show)

See Also:


Attachments
log (39.07 KB, application/octet-stream)
2014-06-05 15:41 EDT, Thanh Ha CLA
no flags Details
patch (2.65 KB, patch)
2014-06-06 14:16 EDT, Thanh Ha CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Craggs CLA 2013-08-23 09:05:53 EDT
In the Paho project we now have some C components, and more may be coming in the future.  

I would like to know if there is a plan for cross-platform building of C components (I've not been able to find one).  If I should be asking this question somewhere else (a mailing list/forum?) please tell me.

I work for IBM, and we currently build the components for Windows, Mac and other Unixes on our servers.  We are happy to continue with this approach - but I am wondering if the Eclipse build infrastructure might support any of this now or in the future?

For Linux, we can look to getting our components into Linux distributions.  Basic build and testing can be done on the current Hudson slaves.

There are Hudson slaves for Windows and Mac testing.  Is using them for basic building and testing of C components appropriate?  (For Windows, using Microsoft C/C++ compilers is the norm).

Again, apologies if I'm asking in wrong place.  This does have the advantage of easily referring other people to the answer.

Thanks.

Ian
Comment 1 Thanh Ha CLA 2013-08-26 09:55:58 EDT
I just happened to be looking into cross compiling for a hobby of mine and thought I'd mention this cross compiler project for Windows binaries on Linux called mxe [1]. Might be worth looking into.

[1] http://mxe.cc/
Comment 2 Denis Roy CLA 2013-08-26 13:51:41 EDT
> Again, apologies if I'm asking in wrong place.  This does have the advantage
> of easily referring other people to the answer.

This is exactly the right place, and mostly for the reason you've mentioned.

Cross-compiling would definitely be the best solution.  As we are a vendor-neutral OSS shop, we use only OSS on our infrastructure.  We do employ Windows and Mac on two Hudson slaves for the sole purpose of performing UI testing, which Linux cannot replicate.
Comment 3 Ian Craggs CLA 2013-08-28 05:07:25 EDT
Thanks, that answers the main question :-)

I've used cross-compilers for Linux in the past, using crosstool-ng http://crosstool-ng.org/.  

Thanks for the pointer to MXE.

I'm guessing that as projects at Eclipse contain more non-Java code, this question will become more common.
Comment 4 Thanh Ha CLA 2013-08-28 11:08:23 EDT
Just to add another potential tool to the list. There is also "xchain" for building Mac binaries on Linux. Apparently it's based on what the OpenTTD project uses.

https://github.com/tatsh/xchain
Comment 5 Ian Craggs CLA 2013-10-18 06:45:17 EDT
As well as the existing C client in Paho this will also apply to:

 - the proposed Mosquitto project (C building on Windows/Mac)


 So this question will now also apply to a .Net MQTT
Comment 6 Ian Craggs CLA 2013-10-18 06:52:54 EDT
Wrong key hit while typing my last comment.

As well as the existing C client in Paho the question of proprietary build tools will also apply to:

 - the proposed Mosquitto project (C building on Windows/Mac)
 - a yet to be contributed .Net MQTT client in Paho
 - Objective C MQTT client in Paho (if it gets legal approval)

A discussion between Mike Milinkovich and Wayne Beaton indicates that we should be able to get proprietary build tools in the Eclipse infrastructure, if those tools are ones which an open source developer would use on a proprietary OS. 

These tools would be:

 - Visual Studio for Windows (C and C# components at a minimum)
 - Xcode for Mac

If there's anything I can do to help...
Comment 7 Mike Milinkovich CLA 2013-10-18 15:41:14 EDT
Ian,

So here is what we would like you to do to help us out.

First off, let me say that we do not want to install IDEs on our build servers. So we don't want to install Visual Studio or Xcode. We do, however, want to install the right headless compiler + SDK on the build servers so you can compile your code. 

So could you help us out by telling us exactly what we need to get on Windows and the Mac to get you going?

We have great contacts at Microsoft and Apple, so I'm not worried about getting these things once we know what to ask for. (If I'm wrong, I'll let you know!)

Make sense?
Comment 8 Ian Craggs CLA 2013-10-18 16:28:50 EDT
Sure Mike.  I'll start off by explaining that the only way I have installed headless compilers on both Windows and MacOS in recent years is to install the IDEs.  The headless compilers come with them.  

In about 2008 I could install gcc for MacOS, but in recent years I've had to install Xcode.  I'll find out whether there is a way to install the headless compilers on their own, but it would not surprise me if we can't.

Would it be a problem installing the IDEs even if they are never used?  Disk space?
Comment 9 Denis Roy CLA 2013-10-18 16:34:06 EDT
*** Bug 372091 has been marked as a duplicate of this bug. ***
Comment 10 Mike Milinkovich CLA 2013-10-18 16:39:29 EDT
(In reply to Ian Craggs from comment #8)
> Would it be a problem installing the IDEs even if they are never used?  Disk
> space?

That's Denis' call. I hope that as long as GUI's are never used it wouldn't be a problem.
Comment 11 Denis Roy CLA 2013-10-19 08:26:24 EDT
> Would it be a problem installing the IDEs even if they are never used?  Disk
> space?

Our experience with apps designed for GUIs is that the CLI tools are afterthoughts, and at some point, they will call on the GUI.  We regularly see builds hang on Windows and Mac because there's a dialog asking for user input, and this is problematic.

The other issue is the multi-user nature of Hudson and our build farm.  Even Eclipse (as an IDE) is not designed to be run by multiple users at the same time. Dedicating one server for only one concurrent build becomes costly.

Having true command-line tools that can be called by Hudson or from the comman line would be the most reliable way to make this work.
Comment 12 Denis Roy CLA 2013-10-19 08:28:13 EDT
FWIW, I'm trying real hard not to stonewall this, but my fear is that you'll eventually be asking me to open RDP and VNC to the world...
Comment 13 Thanh Ha CLA 2013-10-19 10:59:52 EDT
I think I may have missed out on some discussion so maybe someone could get me up to speed. Has cross compiling been removed as a potential option? or is it still worth considering / investigating as an alternative option?
Comment 14 Ian Craggs CLA 2013-10-19 13:32:10 EDT
Denis.  

Ok, I understand the problem of not wanting builds to hang.  I'm totally with you on that one.

For C/C++ on Windows, we use the cl.exe command line compiler, for our automated builds in IBM too.  I've been using this since the mid-90s.

For C/C++ on the Mac, we use Apple's build of gcc.

For both of these compilers, you used to be able to get them standalone.  But I had to change to getting them by installing the IDEs in the last 5 to 10 years, as Microsoft and Apple put more emphasis on their graphical IDEs.  But these compilers are true command line programs.  I can't see either Microsoft or Apple wanting to remove these programs either, as people like you and me will always want automated builds.

I'll check with the build guys here to see if how they install these tools.

I don't understand the connection to VNC/RDP :-)
Comment 15 Ian Craggs CLA 2013-10-19 13:49:48 EDT
Thanh.

It was I who suggested that cross-compiling was not a profitable use of time for people working on projects that target proprietary operating systems, and for which proprietary build tools are the norm (C/C++, .Net, Apple Objective C).  

There are some important proprietary platforms which we want to target in the m2m/mobile world:

- Windows desktop (including .Net)
- Windows Phone
- Windows CE/Embedded
- MacOS
- iOS

Cross-compiling has the disadvantages of:

1) it can be (very) time-consuming to get right
2) the cross-compiled libraries may not be compatible with applications built with the proprietary tools
3) we wouldn't be using the same tools as just about every other developer on the planet, for these platforms.  When they build our programs, they will want to use the standard tools
4) it will complicate build tests as the tests will have to be run on a different slave to where they are built

I wasn't suggesting that the Eclipse organization *should* use Microsoft and Apple development tools.  But I am suggesting that in Paho and Mosquitto at least we will want to use them, and that if we can't use the Eclipse build servers, then I would look at others, say at IBM.

Does that help?
Comment 16 Thanh Ha CLA 2013-10-19 13:56:18 EDT
(In reply to Ian Craggs from comment #15)
> Does that help?

Yes, thanks for the explanation.
Comment 17 Denis Roy CLA 2013-10-21 15:33:46 EDT
> I don't understand the connection to VNC/RDP :-)

If your build stalls because some application is showing some blocking dialog (such as, "Unable to find mouse.  Please click Ok") you'll want to see the screen.
Comment 18 Ian Craggs CLA 2013-12-14 18:35:54 EST
Thanks Denis for the explanation.  I've never had that problem with builds I've put together for Windows because I use the command line build and compile.  But I can see it's a risk.
Comment 19 David Williams CLA 2013-12-14 20:41:29 EST
Just to cross-reference, see also bug 405753 which is similar question about some of the Eclipse Platform "natives".
Comment 20 Denis Roy CLA 2014-05-06 10:34:12 EDT
Just moving to Hudson since that will likely be the vehicle that provides this service.
Comment 21 Thanh Ha CLA 2014-06-04 16:14:52 EDT
Ian,

can you point me to the repository and any documentation on how to build your c projects?

I'd like to look into testing building one of your projects as a POC for setting up a Windows build slave.

Thanks in advance.
Comment 22 Ian Craggs CLA 2014-06-05 05:13:31 EDT
Thanh,

the repository for the C client is:

git.eclipse.org/c/paho/org.eclipse.paho.mqtt.c.git/

build instructions for Windows are on this page:

http://www.eclipse.org/paho/clients/c/

I am interested to know if you find the build instructions adequate.
Comment 23 Thanh Ha CLA 2014-06-05 10:31:47 EDT
(In reply to Ian Craggs from comment #22)
> build instructions for Windows are on this page:
> 
> http://www.eclipse.org/paho/clients/c/
> 


Thanks, I was able to build on Linux just fine, however for Windows I'm missing some dependencies. I guess on Linux I must have already had them installed since it's my regular use system, however on Windows I seem to be missing "openssl/ssl.h".

I'll try to get through this and note down any dependencies that should be documented along the way. Do you have any recommendations on how I should get OpenSSL for Windows?
Comment 24 Thanh Ha CLA 2014-06-05 11:47:20 EDT
(In reply to Thanh Ha from comment #23)
> (In reply to Ian Craggs from comment #22)
> > build instructions for Windows are on this page:
> > 
> > http://www.eclipse.org/paho/clients/c/
> > 
> 
> 
> Thanks, I was able to build on Linux just fine, however for Windows I'm
> missing some dependencies. I guess on Linux I must have already had them
> installed since it's my regular use system, however on Windows I seem to be
> missing "openssl/ssl.h".
> 

I got this installed but the build isn't able to pick it up. How do I tell Windows builds where the headers are?
Comment 25 Ian Craggs CLA 2014-06-05 12:05:26 EDT
(In reply to Thanh Ha from comment #24)
> (In reply to Thanh Ha from comment #23)
> > (In reply to Ian Craggs from comment #22)
> > > build instructions for Windows are on this page:
> > > 
> > > http://www.eclipse.org/paho/clients/c/
> > > 
> > 
> > 
> > Thanks, I was able to build on Linux just fine, however for Windows I'm
> > missing some dependencies. I guess on Linux I must have already had them
> > installed since it's my regular use system, however on Windows I seem to be
> > missing "openssl/ssl.h".
> > 
> 
> I got this installed but the build isn't able to pick it up. How do I tell
> Windows builds where the headers are?

The paths are currently hardcoded in the solution to:

c:\work\openssl\windows_ia32\include

with the library files libeay32.lib and ssleay32.lib in:

c:\work\openssl\windows_ia32

just because that was quickest at the time.  If that's impossible for you I'll parameterize the solution (I'm assuming that must be possible).
Comment 26 Thanh Ha CLA 2014-06-05 13:20:30 EDT
(In reply to Ian Craggs from comment #25)
> The paths are currently hardcoded in the solution to:
> 
> c:\work\openssl\windows_ia32\include
> 
> with the library files libeay32.lib and ssleay32.lib in:
> 
> c:\work\openssl\windows_ia32
> 
> just because that was quickest at the time.  If that's impossible for you
> I'll parameterize the solution (I'm assuming that must be possible).

Thanks, this helps. I also had the 64 bit version. I'll try installing to this path.
Comment 27 Thanh Ha CLA 2014-06-05 13:37:39 EDT
(In reply to Thanh Ha from comment #26)
> (In reply to Ian Craggs from comment #25)
> > The paths are currently hardcoded in the solution to:
> > 
> > c:\work\openssl\windows_ia32\include
> > 
> > with the library files libeay32.lib and ssleay32.lib in:
> > 
> > c:\work\openssl\windows_ia32
> > 
> > just because that was quickest at the time.  If that's impossible for you
> > I'll parameterize the solution (I'm assuming that must be possible).
> 

I was able to get further (and turns out Windows 7 supports symlinks so I symlinked my install path to your hardcoded directories to get it working)

Unfortunately I'm getting numerous unresolved external symbol errors now when building. I'm guessing perhaps it has to do with the version of OpenSSL I installed. Which version are you using to build on Windows?

I installed the latest 1.0.1g.
Comment 28 Ian Craggs CLA 2014-06-05 15:34:39 EDT
(In reply to Thanh Ha from comment #27)
> (In reply to Thanh Ha from comment #26)
> > (In reply to Ian Craggs from comment #25)
> > > The paths are currently hardcoded in the solution to:
> > > 
> > > c:\work\openssl\windows_ia32\include
> > > 
> > > with the library files libeay32.lib and ssleay32.lib in:
> > > 
> > > c:\work\openssl\windows_ia32
> > > 
> > > just because that was quickest at the time.  If that's impossible for you
> > > I'll parameterize the solution (I'm assuming that must be possible).
> > 
> 
> I was able to get further (and turns out Windows 7 supports symlinks so I
> symlinked my install path to your hardcoded directories to get it working)
> 
> Unfortunately I'm getting numerous unresolved external symbol errors now
> when building. I'm guessing perhaps it has to do with the version of OpenSSL
> I installed. Which version are you using to build on Windows?
> 
> I installed the latest 1.0.1g.

Same here, 1.0.1g.  What sort of entries are missing - compile or link time?  Maybe you could send me the log.
Comment 29 Thanh Ha CLA 2014-06-05 15:41:11 EDT
Created attachment 244015 [details]
log

Attached build logs. The errors seem to be with linking.

I copied the 2 files libeay32.lib and ssleay32.lib to C:\work\openssl\windows_ia32 but it doesn't seem to work.
Comment 30 Ian Craggs CLA 2014-06-05 16:17:59 EDT
(In reply to Thanh Ha from comment #29)
> Created attachment 244015 [details]
> log
> 
> Attached build logs. The errors seem to be with linking.
> 
> I copied the 2 files libeay32.lib and ssleay32.lib to
> C:\work\openssl\windows_ia32 but it doesn't seem to work.

Those look pretty fundamental.  How about trying with the OpenSSL libraries that we have built?  They are 13M and 2M in size, so I don't know about attaching them to this bug.  I did try to send them to my home directory on build.eclipse.org temporarily so you could get them, but that stopped before finishing, and now I can't get log back in... I suspect I might have exceeded a quota (oops), unless it's a coincidence.

Where's the best place to put them for you?
Comment 31 Thanh Ha CLA 2014-06-05 16:25:01 EDT
(In reply to Ian Craggs from comment #30)
> They are 13M and 2M in size

Wow really? my copies seem to be 763KB and 65KB


> Where's the best place to put them for you?

Anywhere on build.eclipse.org would be the best place for me actually but I believe Webmaster is working on that system right now and it seems to be down.

You could try emailing them to me, not sure how well that will work...
Comment 32 Thanh Ha CLA 2014-06-05 16:36:26 EDT
(In reply to Thanh Ha from comment #31)
> > Where's the best place to put them for you?
> 
> Anywhere on build.eclipse.org would be the best place for me actually but I
> believe Webmaster is working on that system right now and it seems to be
> down.
> 

Looks like build.eclipse.org is back online. Can you try there again?
Comment 33 Thanh Ha CLA 2014-06-05 16:40:09 EDT
Actually I figured it out!

My copy of libeay32.lib and ssleay32.lib were from the 64-bit package. When I swapped it for the copy from the 32-bit package it started working.

I'm able to successfully build the project now.


I guess this project cannot be built with the 64-bit version of the libraries?
Comment 34 Ian Craggs CLA 2014-06-05 16:55:31 EDT
(In reply to Thanh Ha from comment #33)
> Actually I figured it out!
> 
> My copy of libeay32.lib and ssleay32.lib were from the 64-bit package. When
> I swapped it for the copy from the 32-bit package it started working.
> 
> I'm able to successfully build the project now.
> 
> 
> I guess this project cannot be built with the 64-bit version of the
> libraries?

This particular project is set for 32-bit builds.  I'd have to create another project for 64-bit builds.
Comment 35 Thanh Ha CLA 2014-06-05 17:04:39 EDT
(In reply to Ian Craggs from comment #34)
> This particular project is set for 32-bit builds.  I'd have to create
> another project for 64-bit builds.

Okay that's good to know.

I'm not sure how Visual Studio handles additional paths and variables (is it all static or can you pass parameters?) but I think instead of these paths we should use:


c:\work\openssl\windows_ia32\include -> c:\%OpenSSL_Path%\include
c:\work\openssl\windows_ia32 -> c:\%OpenSSL_Path%\lib

and maybe default %OpenSSL_Path% to C:\OpenSSL-Win32\ for 32-bit and C:\OpenSSL-Win64\ for 64-bit but allow it to be override-able via parameter.

This way we can put in the instructions to install OpenSSL and if the user leaves defaults it works out of the box.
Comment 36 Thanh Ha CLA 2014-06-06 11:32:22 EDT
I think I found a decent solution. I will post a Gerrit patch soon. I can provide a patch for the build instructions too but the paho www.eclipse.org repo is not available in Gerrit. I guess I can attach that patch to this bug?
Comment 37 Thanh Ha CLA 2014-06-06 13:58:11 EDT
Patch for build code: https://git.eclipse.org/r/28135
Comment 38 Thanh Ha CLA 2014-06-06 14:16:14 EDT
Created attachment 244049 [details]
patch
Comment 39 Thanh Ha CLA 2014-06-06 15:29:43 EDT
Just to document, this is what my HIPP Windows slave job calls as a shell script:

SET OpenSSLDir=C:\common\OpenSSL-1.0.1g-Win32
CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
msbuild "Windows Build\Paho C MQTT APIs.sln" /p:Configuration=Release
Comment 40 Ian Craggs CLA 2014-06-09 06:38:26 EDT
Thanks.  Out of interest, did you change the paths in the solution using the IDE or by directly editing the files?
Comment 41 Thanh Ha CLA 2014-06-09 09:19:59 EDT
(In reply to Ian Craggs from comment #40)
> Thanks.  Out of interest, did you change the paths in the solution using the
> IDE or by directly editing the files?

I modified the files by hand. I found that using the IDE always caused it to modify every line instead of just the lines I was interested in so it would have made change review confusing.
Comment 42 Denis Roy CLA 2016-05-19 11:23:52 EDT
We cannot do Windows and Mac slaves on our infra.  Please see bug 375991.

It may be possible to connect HIPP to external slaves run on Cloud provider resources.  Please see:

https://wiki.eclipse.org/Hudson/Connecting_HIPP_to_an_external_slave