dirkschumacher / rcbc

COIN-OR branch and cut (CBC) bindings for R
https://dirkschumacher.github.io/rcbc/
Other
19 stars 5 forks source link

Compilation failure on Windows CI and R devel #57

Open dirkschumacher opened 2 years ago

dirkschumacher commented 2 years ago

2022-01-13T08:45:40.5951209Z rm -f rcbc.dll RcppExports.o cpp_cbc_solve.o rcbc-init.o 2022-01-13T08:45:40.5951715Z "C:/R/bin/x64/Rscript.exe" "../tools/winlibs.R" 2022-01-13T08:45:40.5952953Z g++ -std=gnu++11 -I"C:/R/include" -DNDEBUG -I../windows/cbc-2.10.5/include/coin -I'D:/a/_temp/Library/Rcpp/include' -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -c RcppExports.cpp -o RcppExports.o 2022-01-13T08:45:40.5954230Z g++ -std=gnu++11 -I"C:/R/include" -DNDEBUG -I../windows/cbc-2.10.5/include/coin -I'D:/a/_temp/Library/Rcpp/include' -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -c cpp_cbc_solve.cpp -o cpp_cbc_solve.o 2022-01-13T08:45:40.5955705Z gcc -I"C:/R/include" -DNDEBUG -I../windows/cbc-2.10.5/include/coin -I'D:/a/_temp/Library/Rcpp/include' -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -c rcbc-init.c -o rcbc-init.o 2022-01-13T08:45:40.5957053Z g++ -std=gnu++11 -shared -s -static-libgcc -o rcbc.dll tmp.def RcppExports.o cpp_cbc_solve.o rcbc-init.o -L../windows/cbc-2.10.5/lib-10.3.0/x64 -L../windows/cbc-2.10.5/lib/x64 -lCbcSolver -lClpSolver -lOsiCbc -lCbc -lCgl -lOsiClp -lClp -lOsi -lCoinUtils -lz -lm -Lc:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64 -Lc:/rtools42/x86_64-w64-mingw32.static.posix/lib -LC:/R/bin/x64 -lR 2022-01-13T08:45:40.5958485Z C:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../windows/cbc-2.10.5/lib/x64/libCbcSolver.a(CbcSolver.o):(.text+0x16e49): undefined reference to __imp___iob_func' 2022-01-13T08:45:40.5959379Z C:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../windows/cbc-2.10.5/lib/x64/libCbcSolver.a(CbcSolver.o):(.text+0x17a36): undefined reference toimp___iob_func' 2022-01-13T08:45:40.5962279Z C:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../windows/cbc-2.10.5/lib/x64/libCbcSolver.a(CbcSolver.o):(.text+0x17e6e): undefined reference to `imp_iob_func' 2022-01-13T08:45:40.5963787Z C:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../windows/cbc-2.10.5/lib/x64/libCbcSolver.a(CbcSolver.o):(.text+0x19154): undefined reference to `imp_iob_func' 2022-01-13T08:45:40.5964692Z C:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../windows/cbc-2.10.5/lib/x64/libCbcSolver.a(CbcSolver.o):(.text+0x3b8d5): undefined reference to `imp_iob_func' 2022-01-13T08:45:40.5965979Z C:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../windows/cbc-2.10.5/lib/x64/libCbcSolver.a(CbcSolver.o):(.text.startup+0x1e): more undefined references to `imp___iob_func' follow 2022-01-13T08:45:40.5967991Z collect2.exe: error: ld returned 1 exit status 2022-01-13T08:45:40.5968586Z no DLL was created 2022-01-13T08:45:40.5969394Z ERROR: compilation failed for package 'rcbc' 2022-01-13T08:45:40.5970245Z * removing 'C:/Users/RUNNER~1/AppData/Local/Temp/RtmpgJy71j/Rinst15384e762ac6/rcbc'

multiduplikator commented 2 years ago

This problem persists on R 4.2.0 and RTOOLS 4.2 on Windows 11.

Anything I can do to help sort this out?

multiduplikator commented 2 years ago

Is this because R 4.2 is now on ucrt?

cmber commented 2 years ago

Same issue with R 4.2.0 and RTools 4.2 on Windows 10 pro

multiduplikator commented 2 years ago

Is there anything happening on this issue? I am happy to help debug and test...

dirkschumacher commented 2 years ago

Happy to look at a PR for it, but I don't have the capacity to look into it.

multiduplikator commented 1 year ago

No patches needed. CBC 2.10.8 is required and fixes the problem.

As a dirty hack, I tried building the package. It downloads cbc 2.10.5. Then I replaced the files in "windows\cbc-2.10.5" with the corresponding versions of the 2.10.8 official releases from https://github.com/coin-or/Cbc/releases namely

Cbc-releases.2.10.8-i686-w64-mingw32.zip: lib\*.a -> windows\cbc-2.10.5\lib\i386

Cbc-releases.2.10.8-x86_64-w64-mingw64.zip: include -> windows\cbc-2.10.5\include share -> windows\cbc-2.10.5\share lib\*.a -windows\cbc-2.10.5\lib\x64

Then edited DESCRIPTION to call for roxygen2 7.2.0 (new version, so doc builds).

After that, Clean and Rebuild. Then Test Package - all 12+33 tests pass.

All perfectly fine.

BrunoCartu commented 1 year ago

Could you be a bit more specific @multiduplikator please? I'm not a computer science guy and I'm missing some key details here. And are you describing a fix you did or a procedure we should follow? Thanks

multiduplikator commented 1 year ago

Before you start, you might want to update all packages first.

Download the rcbc master branch as zip and unpack. You will get a directory namedrcbc-master. In that directory, open the file Rcbc.Rproj in RStudio.

Run Build > Check Package. Which will produce the error situation as described in #34.

Now comes the dirty fixing part.

You need to download two files from https://github.com/coin-or/Cbc/releases :

Cbc-releases.2.10.8-i686-w64-mingw32.zip
Cbc-releases.2.10.8-x86_64-w64-mingw64.zip

In the directory rcbc-master\windows\cbc-2.10.5\lib\i386 delete all files with ending .a. Copy all files with ending .a from the lib directory in the downloaded zip Cbc-releases.2.10.8-i686-w64-mingw32.zip. In shorthand pseudo code, I write: copy Cbc-releases.2.10.8-i686-w64-mingw32.zip\lib\*.a TO rcbc-master\windows\cbc-2.10.5\lib\i386\

Now delete all files in rcbc-master\windows\cbc-2.10.5\include\coin. copy Cbc-releases.2.10.8-x86_64-w64-mingw64.zip\include\coin\* TO rcbc-master\windows\cbc-2.10.5\include\coin\

Next, delete everything in rcbc-master\windows\cbc-2.10.5\share\coin\Data (two directories). copy (directories) Cbc-releases.2.10.8-x86_64-w64-mingw64.zip\share\coin\Data\* TO rcbc-master\windows\cbc-2.10.5\share\coin\Data

Finally, delete all files in rcbc-master\windows\cbc-2.10.5\lib\x64 ending in .a. copy Cbc-releases.2.10.8-x86_64-w64-mingw64.zip\lib\*.a TO rcbc-master\windows\cbc-2.10.5\lib\x64

What we have done effectively is to keep the folder structure of rcbc-master as is, but replaced the libraries of cbc-2.10.5 with the ones from cbc-2.10.8. This is dirty, but it works.

Finally, you have to check which version of roxygen2 you have installed. For me it is 7.2.1 version. Hence, I check the file rcbc-master\DESCRIPTION to contain the line:

RoxygenNote: 7.2.1

Run Build > Build Binary Package.

This will produce rcbc_0.1.0.9001.zip in the directory above rcbc-master.

That zip can be installed via "Tools > Install > Install from: Package archive file".

Hope this helps.

PS: You might want to backup the zip you created, can be installed as is when you redo your R environment.

BrunoCartu commented 1 year ago

Thank you so much @multiduplikator, works like a charm.

multiduplikator commented 1 year ago

A pleasure :)

multiduplikator commented 1 year ago

A bit more user friendly, I made a fork of the libraries.

So you can just download the rcbc-master, unpack, and then:

In the file rcbc-master\src\Makevars.win change line 1 to become

VERSION = 2.10.8

In the file rcbc-master\tools\winlibs.R change line https url in line 8 to become

https://github.com/multiduplikator/cbc/releases/download/2.10.8/cbc-2.10.8.zip

Now load rcbc-master\Rcbc.rproj in Rstudio and build as usual.

jeffreyhanson commented 1 year ago

Just in case it's helpful, I've been working on a PR for rcbc so that it will work on R version 4.2+ and older versions, and I think it's working now (#66). I've tested it on GitHub Actions and on a Windows PC and it installs and runs correctly. I'm waiting for a seperate PR to RWinLib before the PR to rcbc can be merged, but in the meantime, it can be installed with remotes::install_github("jeffreyhanson/rcbc@rwinlib"). Please let me know if anyone runs into any issues with it.

multiduplikator commented 1 year ago

I just did a build on Win11, R 4.2.2. Played a bit with it, executed the sample code from help. Looks good to me!

However, why did you choose 2.10.5b of cbc, when there is 2.10.8 at least since May 2022?