Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic library is kept open after dyn.unload #292

Open
Lee-Cronin-Fine-NOAA opened this issue Dec 4, 2018 · 0 comments
Open

Dynamic library is kept open after dyn.unload #292

Lee-Cronin-Fine-NOAA opened this issue Dec 4, 2018 · 0 comments
Labels
External A problem in an external project that TMB depends on

Comments

@Lee-Cronin-Fine-NOAA
Copy link

I have an issue compiling the cpp file. Specifically, when I compile the cpp file the first time, it runs just fine. However, if I make a change to the cpp file (something as small as adding a space) and then try to recompile it, it won't work. This is what RStudio shows me:

library(TMB)
dyn.unload(dynlib('melba'))
Error in dyn.unload(dynlib("melba")) :
shared object 'C:/Users/lcron/Desktop/melba.dll' was not loaded
compile('melba.cpp')
c:/Rtools/mingw_64/bin/g++ -I"C:/PROGRA1/R/R-3.5.1/include" -DNDEBUG -IC:/Users/lcron/DOCUME1/R/WIN-LI1/3.5/TMB/include -IC:/Users/lcron/DOCUME1/R/WIN-LI1/3.5/RcppEigen/include -DTMB_SAFEBOUNDS -DLIB_UNLOAD=R_unload_melba -DTMB_LIB_INIT=R_init_melba -O2 -Wall -mtune=generic -c melba.cpp -o melba.o
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o melba.dll tmp.def melba.o -LC:/PROGRA
1/R/R-3.5.1/bin/x64 -lR
[1] 0
dyn.load(dynlib('melba'))
dyn.unload(dynlib('melba'))
compile('melba.cpp')
c:/Rtools/mingw_64/bin/g++ -I"C:/PROGRA1/R/R-3.5.1/include" -DNDEBUG -IC:/Users/lcron/DOCUME1/R/WIN-LI1/3.5/TMB/include -IC:/Users/lcron/DOCUME1/R/WIN-LI1/3.5/RcppEigen/include -DTMB_SAFEBOUNDS -DLIB_UNLOAD=R_unload_melba -DTMB_LIB_INIT=R_init_melba -O2 -Wall -mtune=generic -c melba.cpp -o melba.o
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o melba.dll tmp.def melba.o -LC:/PROGRA
1/R/R-3.5.1/bin/x64 -lR
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file melba.dll: Permission denied
collect2.exe: error: ld returned 1 exit status
[1] 0

If I delete the dll file and try again to recompile the cpp file, it compiles just fine. Interestingly, in order to delete the dll file, I had to close RStudio because I got the following warning when I tried to delete the dll file "The action can't be completed because the file is open in RStudio R Session" Another interesting factor is that this issue only occurs for one specific cpp file. The other cpp files I have created work just fine. Additionally, if I move the cpp file to a separate computer the cpp file compiles fine. I have tried un-installing and re-installing Rtools and TMB. I have also removed admb from my computer since I heard that that can cause problems.

The TMB version I have is 1.7.15
The R version I ave is 3.5.1
Operating System XPS 15 9550

@euclaise euclaise changed the title Weird Compile issue Dynamic library is kept open after dyn.unload Jul 31, 2020
@euclaise euclaise added the External A problem in an external project that TMB depends on label Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External A problem in an external project that TMB depends on
Projects
None yet
Development

No branches or pull requests

2 participants