admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

Using Rtools to compile models on Windows #134

Closed Cole-Monnahan-NOAA closed 4 years ago

Cole-Monnahan-NOAA commented 4 years ago

I vaguely remember discussion of trying to get Rtools to be compatible with ADMB. I see threads/issues on how to avoid the conflict with the ADMB compiler, but really the ideal solution for users would be to just use Rtools. This is the compiler that TMB and Stan use so it would make a lot of sense to use the same one.

@johnoel Is this possible? Any thoughts/updates?

iantaylor-NOAA commented 4 years ago

I'm seeing "Supported Windows C++ 64-Bit Compilers: Rtools 3.5, Rtools 4.0, Msys2 and Microsoft Visual Studio 2015, 2017 and 2019." at http://www.admb-project.org/downloads/ and have had no issues with compiling recent ADMB versions using the Rtools compiler on my windows computer.

Also AD Studio "Uses the C++ compiler from Rtools": https://github.com/admb-project/adstudio

Cole-Monnahan-NOAA commented 4 years ago

Maybe I'm just doing something wrong? When I use a normal shell window I get this

C:\Users\cole.monnahan\admb\examples\admb\catage>c:\Users\cole.monnahan\admb\build\admb\admb catage
Error: Unable to find libadmb

I have to put the full path to the ADMB executable b/c I don't have ADMB in my PATH because NOAA. The same approach works with the ADMB Command Prompt. What's your workflow Ian?

kellijohnson-NOAA commented 4 years ago

I was able to have IT put the admb folder that I needed in my path, as well as other paths. I also use Rtools, but I think there was a recent upgrade. Which version of Rtools are you using Cole?

Cole-Monnahan-NOAA commented 4 years ago

I"m using 3.5.0.4 apparently. So must be a configuration thing. I did a PATH hack so that ADMB 12.0 release was in my path and tried to compile with Rtools. It throws a ton of errors but here are the first and last ones.

C:\Users\cole.monnahan\admb\examples\admb\catage>where g++
C:\Rtools\mingw_64\bin\g++.exe

*** Compile: catage.cpp
g++ -c -std=c++11 -O3 -fpermissive -D_FILE_OFFSET_BITS=64 -I. -I"C:\Program Files (x86)\ADMB\include" -I"C:\Program Files (x86)\ADMB\contrib\include" -o catage.obj catage.cpp

*** Linking: catage.obj
g++ -static -o catage.exe catage.obj "C:\Program Files (x86)\ADMB\lib\libadmb-contrib.a"
C:\Program Files (x86)\ADMB\lib\libadmb-contrib.a(saflp-linad99-dmat.obj):dmat.cpp:(.text+0x17f): undefined reference to `operator delete[](void*, unsigned long long)'
....
C:\Program Files (x86)\ADMB\lib\libadmb-contrib.a(saflp-df1b2-separable-mod_rhes.obj):mod_rhes.cpp:(.text+0x32a2): undefined reference to `std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_istringstream()'
collect2.exe: error: ld returned 1 exit status
arni-magnusson commented 4 years ago

I agree that the GCC release of ADMB for Windows should definitely be compiled with Rtools - and not some other flavor of GCC for Windows.

The version of Rtools may also be relevant. If it's not currently the case, the ADMB 12.1 binary release should probably be compiled with the current version of Rtools 4.0 that includes GCC 8.3.0.

A large proportion of ADMB users in Windows have Rtools in their path, so building ADMB with any other version of GCC than Rtools is likely to create version conflicts.

Cole-Monnahan-NOAA commented 4 years ago

I tried building ADMB from source using Rtools and then tried building the catage example with Rtools and get the same errors. I'll ask IT to upgrade my version of Rtools and try that.

iantaylor-NOAA commented 4 years ago

I also have 3.5.0.4:

C:\Users\ian.taylor>where gcc
C:\Rtools\mingw_64\bin\gcc.exe

C:\Users\ian.taylor>cat c:\Rtools\VERSION.txt
Rtools version 3.5.0.4

I can post more about my path setup later.

Cole-Monnahan-NOAA commented 4 years ago

OK quick update. I got it working after rebuilding from source and then using Rtools to compile the model using that one. I still get the errors if I try to use the release version 12.0 and build models with Rtools.

My path situation is a bit complicated b/c I need to be able to compile the same model with 12.0 and a development branch of 13.0 so that I can easily check for changes.

This is great b/c I can abandon the special ADMB Console. I'm going to close it. Thanks for the quick replies all.