[ADMB Users] Building ADMB on Windows - more failures

Jon Schnute schnutej-dfo at shaw.ca
Wed Nov 20 18:36:49 PST 2013

Hi Wade and Chris - I've now tried the two methods that each of you
recommends for downloading mingw and building ADMB. You might recall that
Chris's method seemed to build the ADMB library OK, but it failed when I
tried to run a particular example. More precisely, it failed at the link
step (adlink.bat) with a strange message about WinMain at 16.

I thought this might have happened because I used a Windows command shell,
rather than a Unix msys shell, when I built ADMB. Today, I tried it again
with the msys shell, but I ended up with exactly the same problem. So,
Chris, no matter how hard I try, I can't replicate your success.

I then moved to Wade's method, that is, I  downloaded the software
recommended in his message. After fiddling with the paths, I again built
ADMB with seeming success. (Oddly, the build seemed to happen much faster
this time, but maybe I just lost track.) However, when I attempted to run
the example "simple", I got these results:

***** tpl2cpp
D:\PBS\Rdevel\DevADMB>tpl2cpp simple
        1 file(s) copied.

***** Compile
D:\PBS\Rdevel\DevADMB>adcomp simple
g++ -c  -O3 -D__GNUDOS__  -Dlinux -DOPT_LIB -DUSE_LAPLACE -fpermissive -I.
include" -o simple.obj simple.cpp

***** Link
D:\PBS\Rdevel\DevADMB>adlink simple
g++ -s  -static  -o
4-mingw32/lib/../lib\libmingw32.a(lib64_libmingw32_a-crt0_c.o): In function
h:/crossdev/src/mingw-w64-v3-svn/mingw-w64-crt/crt/crt0_c.c:18: undefined
nce to `WinMain'
collect2.exe: error: ld returned 1 exit status

The time the undefined reference is to "WinMain", not "WinMain at 16" (probably
because Wade uses a 64-bit compiler).

In summary, I can't get any mingw version to work if I start from fresh
Internet sources. Do you have any suggestions? Is it possible that I'm using
more recent versions of mingw than either of you? Perhaps a bug has crept
into mingw itself.

Incidentally, I made quite a few changes to my "path" variable today. To
facilitate this, I used a free tool called the "Rapid Environment Editor"
(http://www.rapidee.com/). It helped me make sure that I wasn't using
unintended paths for different setups. It also found a false entry in my
current path, that is, a directory that doesn't exist.  

Best wishes,

-----Original Message-----
From: Cooper, Wade [mailto:Wade.Cooper at MyFWC.com] 
Sent: November-20-13 11:17 AM
To: Jon Schnute
Subject: RE: Building ADMB on Windows

Hi Jon,

Let me know if the approach builds OK for you, it's worked pretty faithfully
for me so far.  

As long as you download the right version of MinGW (32 or 64bit) everything
else should work fine for either 32 or 64bit.  But it'd need testing to
check for sure.  MinGW-w64 may work on 32bit too (I don't have a 32bit
machine to try), but i'd probably just use the normal 32-bit MinGW
(http://sourceforge.net/projects/mingw/files/latest/download?source=files or
TDM-GCC).  The nice thing with the TDM-GCC build is that you can download
either the 32 or 64bit version if you use the "on demand installer"
ebdl.exe/download).  I started using the TDM-GCC when first trying to build
ADMB on a Windows XP 64-bit machine, and it took me a while to get
everything worked out.  I had errors early on trying to get things to work
in the DOS shell, but once I switch to MSYS it worked fine using the old
ADMB install instructions for Linux for version 9 or 10, I can't remember
when I first built the source.

Keep me posted on how things turn out for you,


From: Jon Schnute [schnutej-dfo at shaw.ca]
Sent: Wednesday, November 20, 2013 2:38 AM
To: Cooper, Wade
Subject: Building ADMB on Windows

Wade - Thanks very much for your nicely articulated solution to building
ADMB on Windows. I've downloaded the tools you recommended, but I won't
actually try this until tomorrow.

I meant to copy you on the email below. I think you might have the first
solution that produces a 64-bit ADMB library on Windows (for ADMB 11.1 or
higher). Will your method also allow someone to compile in 32-bit mode?

Best wishes,


From: Jon Schnute [mailto:schnutej-dfo at shaw.ca]
Sent: November-19-13 11:27 PM
To: 'Grandin, Chris'
Cc: 'Steve Martell'; 'johnoel at hawaii.edu'; 'arnima at hafro.is'
Subject: RE: [ADMB Users] Please test updated installation documentation.

Hi Chris - Thanks for this. I talked with Rowan today, and I realize that
you're really busy. So I'm sorry for the interruption.

I think my mistake was that I ran "make" from a Windows command shell, not a
Unix msys shell. (Strangely, it seemed to work until I tried to link an ADMB
example.) I note that Wade Cooper used the same technique, i.e., running
"make" in msys. However, notice that his installation makes a 64-bit version
of ADMB. If I recall correctly, you still hadn't been able to build ADMB on
Windows in 64-bit mode. So this would be a breakthrough. (Wade - I'm copying
you on this so that you can see this comment.)

I'll try this again tomorrow. Thanks again,


From: Grandin, Chris [mailto:Chris.Grandin at dfo-mpo.gc.ca]
Sent: November-18-13 8:06 AM
To: Jon Schnute
Cc: Steve Martell; johnoel at hawaii.edu<mailto:johnoel at hawaii.edu>;
arnima at hafro.is<mailto:arnima at hafro.is>
Subject: RE: [ADMB Users] Please test updated installation documentation.

Hi Jon,
  I've been really busy this month with the Silvergray assessment and with
an acoustics meeting all last week - I apologize for the delay.

Here is the way I compile ADMB using minGW:

1. Get the ADMB source from the svn into a directory called C:\admb-trunk.
2. Install mingw with MSYS and developer package included, install into
3. Open the minGW shell (C:\MinGW\msys\1.0\msys.bat or shortcut in start
menu) 4. type cd ../../../../c/admb-trunk (you have to get out of
C:\MinGW\msys\1.0\ and into C:\admb-trunk) 5. type which make (it should say
/bin/make.exe which is the make included with minGW) 6. type make 7. Once
complete, close the mingw shell 8. Open a DOS shell and go to
C:\admb-trunk\build\dist\examples\admb\simple and type admb simple

Here is my PATH: (Note the PATH does not matter for the building of the
source, only for the building of TPLS outside the minGW shell) C:\mingw\bin
C:\mingw\msys\1.0\bin %ADMB_HOME%\bin

By having your ADMB_HOME set like this, you are always accessing the newest
build without having to change the PATH variable.

The Win16 at Main error is a linker error and caused by an erroneously linked
file, which means that the version of MinGW you are using is not compatible
with the linker.  This happens because the ADMB binary you have installed
was built with a different version of MinGW g++ than the one installed on
your computer that you are trying to build your project with, and this can
happen even if it is the same version number. This is why I always build the
ADMB from source using the same exact version of MinGW as I use to build my
projects. This method has always worked for me and I have left behind all
these woes by doing so!

Jon, if you want to ensure that your package doesn't break then I would
suggest building the ADMB from source using the method above, then
distributing the exact same version of MinGW with your R package so that
there are never linking problems. Would this work or is there some reason
for not doing it this way?

Note 1:  I use the Emacs IDE for all of Windows/VS Windows/MinGW, and Linux,
completely independent of the compilation scheme.

Note 2: After much testing, Arni Magnusson and I have found that different
MinGW compilers work on different machines. i.e. Some versions work on some
machines but not others. This might makes things tough.

I hope this helped,

From: Jon Schnute [mailto:schnutej-dfo at shaw.ca]
Sent: November-17-13 1:01 PM
To: 'Steve Martell'
Cc: Grandin, Chris
Subject: RE: [ADMB Users] Please test updated installation documentation.

Thanks, Steve. Part of the problem stems from the fact that different
developers have different approaches to the Windows platform. From my point
of view, I don't think that any one approach is 'right', but the ADMB
project needs at least one approach that actually works. In my first email
about this, I think I was taking Chris's approach, but this failed with a
weird error.

What about this, Chis? What the blazes is 'WinMain at 16'? I enclose my
detailed notes about the test I conducted. Chris, can you describe any
procedure with the current Gnu software (even just a 32 bit compiler) that
actually works?

In  the end, the ADMB web site needs an unambiguous explanation of how to
install ADMB with Gnu on Windows. It could also report more than one
approach, but the choices should be clear and they all should work. While I
certainly appreciate Arni's work with the IDE, the Windows installation
shouldn't depend on that, just as any Unix installation is also independent
of the IDE.


PS to Steve - Congratulations to you and Liz on the birth of your (third?
I'm losing track) child. I hope everything is working very well for your
whole family in Seattle.

PPS - Have you seen the recent talk by Doug Butterworth in Reykjavik:


From: Steve Martell [mailto:SteveM at iphc.int]
Sent: November-17-13 9:15 AM
To: Jon Schnute
Subject: Re: [ADMB Users] Please test updated installation documentation.

Hi Jon,

Thanks for your persistence on this.  I do test install procedures for the
Mac OSX.  Johnoel and most of the ADMB developers are non-windows users, so
its nice to follow this up.  Chris Grandin has been a huge resource for the
windows community, however, I note that he' uses many unix-tools on his
windows machine.

On Nov 16, 2013, at 8:17 PM, Jon Schnute
<schnutej-dfo at shaw.ca<mailto:schnutej-dfo at shaw.ca>> wrote:

Further to my previous message, I have now tried the same experiment using
the version 11.1 source code, rather than ADMB-latest. I discovered that
this version produces a much smaller Unix tree in the directory
..\admb\utilities\mingw, so I used the ..\mingw tree that I downloaded from
the latest. (I just replaced the 11.1 ..\mingw directory with the new one
obtained today.) Then I tried to make the 11.1 binary ADMB library as
before, and again the process failed while trying to compile 'amoeba.cpp'.

Does amoeba.cpp require something special? Are both of you getting this same
problem? I'm taking care to ensure that nothing on my path would override
the Unix tools at ..\admb\utilities\mingw.

Incidentally, for step 5 I used '\utilities\make' rather than 'make' as
stated in my previous message. On this point, why do you use a possibly old
version of 'make' embedded in the ADMB source code, rather than the version
of 'make' that currently comes with mingw/msys?

These problems help illustrate the reasons that I flagged this as an
important issue. I'm not blaming anyone, but I hope you'll stay with this
until the problems are resolved.


PS - I really sympathize with Dave's question: "Doesn't anyone test this
stuff?" I think the ADMB project needs some volunteer testers who at least
check each new release on each OS. I'm trying to play that role in this
exercise, at least for the Windows OS.

PPS - I wonder why the version of mingw that Dave obtained yesterday worked,
whereas the version obtained with get-mingw.bat appears not to.

From: Jon Schnute [mailto:schnutej-dfo at shaw.ca]
Sent: November-16-13 4:28 PM
To: 'Johnoel Ancheta'; 'dave fournier'
Cc: 'ADMB Users'
Subject: RE: [ADMB Users] Please test updated installation documentation.

Johnoel and Dave - Thanks for the updated documentation. I've tried to
follow it carefully, starting with the file admb-latest.zip obtained via
your link:


>From this I manually extracted the 'admb' directory tree to D:\Temp\admb.
That's essentially step 2,  where I've used a slightly different directory
than you suggested. I then used a command window to install mingw:

D:\Temp\admb\> utilities\get-mingw.bat

That seemed to work fine, giving me a fully populated tree at
D:\Temp\admb\utilities\mingw. Furthermore, I get g++ version 4.8.1 with the

D:\Temp\admb\utilities\mingw\bin>g++ --version
g++ (GCC) 4.8.1

I presume this is a 32-bit compiler, right? Anyway I'm now done with step 4.

To implement step 5, I used the command:


This seemed to be working nicely for a while  until it failed suddenly while
trying to compile the file amoeba.cppp. Here is the final console of

***** Final screen
g++ -c -O3 -Wall -DSAFE_ALL -D__GNUDOS__ -Dlinux -D__SPDLL__ 
build\dist\include -o..\build\objects\dist\saflp-linad99-vrannegbin.obj
linad99\ vrannegbin.cpp
g++ -c -O3 -Wall -DSAFE_ALL -D__GNUDOS__ -Dlinux -D__SPDLL__ 
build\dist\include -o..\build\objects\dist\saflp-linad99-vregress.obj
linad99\vr egress.cpp
g++ -c -O3 -Wall -DSAFE_ALL -D__GNUDOS__ -Dlinux -D__SPDLL__ 
build\dist\include -o..\build\objects\dist\saflp-linad99-vspline.obj
linad99\vsp line.cpp
g++ -c -O3 -Wall -DSAFE_ALL -D__GNUDOS__ -Dlinux -D__SPDLL__ 
build\dist\include -o..\build\objects\dist\saflp-linad99-vtdev.obj
linad99\vtdev .cpp
g++ -c -O3 -Wall -DSAFE_ALL -D__GNUDOS__ -Dlinux -D__SPDLL__ 
build\dist\include -o..\build\objects\dist\saflp-linad99-xfmmtr1.obj
linad99\xfm mtr1.cpp
g++ -c -O3 -Wall -DSAFE_ALL -D__GNUDOS__ -Dlinux -D__SPDLL__ 
build\dist\include -o..\build\objects\dist\saflp-linad99-xgradclc.obj
linad99\xg radclc.cpp
g++ -c -O3 -Wall -DOPT_LIB -D__GNUDOS__ -Dlinux -D__SPDLL__ 
g++ -DUSE_LAPLACE -I..\b
uild\dist\include -o..\build\objects\dist\optlp-nh99-adsleep.obj
nh99\adsleep.cp p
g++ -c -O3 -Wall -DOPT_LIB -D__GNUDOS__ -Dlinux -D__SPDLL__ 
g++ -DUSE_LAPLACE -I..\b
uild\dist\include -o..\build\objects\dist\optlp-nh99-amoeba.obj
process_begin: CreateProcess(NULL, cat ../VERSION, ...) failed.
***** End of final screen

This is a bit weird, perhaps the result of recent changes to the source
code. But rest assured that I'm taking everything written by both of you
very seriously. I really appreciate your efforts.


From: users-bounces at admb-project.org<mailto:users-bounces at admb-project.org>
[mailto:users-bounces at admb-project.org] On Behalf Of Johnoel Ancheta
Sent: November-16-13 12:04 PM
To: dave fournier
Cc: ADMB Users
Subject: Re: [ADMB Users] Please test updated installation documentation.

Ahh, thanks for the feedback.  I assume that you are using


Which failed at step 5

On Sat, Nov 16, 2013 at 9:55 AM, dave fournier
<davef at otter-rsch.com<mailto:davef at otter-rsch.com>> wrote:

So then I installed the msys tools using the installer at.  Note that I ONLY
installed the tools since the comiler is presumably already installed with
Johnoel's commands.




on my path.

Check by  using commands like rm and cp.  OK so far.

Users mailing list
Users at admb-project.org<mailto:Users at admb-project.org>

Users mailing list
Users at admb-project.org<mailto:Users at admb-project.org>


This internet e-mail message, and any files transmitted with it, contains
confidential, privileged information that is intended only for the
addressee. If you have received this e-mail message in error, please call us
at (206) 634-1838 collect if necessary) and ask to speak to the message
sender. Nothing in this e-mail or the act of transmitting it, is to be
construed as a waiver of any rights or privileges enjoyed by the sender or
the International Pacific Halibut Commission pursuant to the International
Organizations Immunities Act, 22 U.S.C. Sec. 288 et seq.
No virus found in this message.
Checked by AVG - www.avg.com<http://www.avg.com>
Version: 2014.0.4158 / Virus Database: 3629/6829 - Release Date: 11/12/13

More information about the Users mailing list