I am trying to use gdb with R. My gdb command seems to work fine with executable (written in C) but I encounter some issue when I use gdb in R.
I did
sudo R -d gdb
In case it matters, the reason for using the sudo command can be found in this post (see most upvoted but not accepted answer) (I am on MAC OSX 10.11.3).
Right before the (gdb) prompt, it says:
Reading symbols from /Library/Frameworks/R.framework/Resources/bin/exec/R...
warning: `/Builds/CRAN-QA-Simon/R-build/mavericks-x86_64/R-3.2.3/src/main/Rmain.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.
I can confirm this file does not exist, I don't even have a /Builds directory. When I enter run, then a very long list of [..] can't open to read symbols: No such file or directory appears.
How can I debug this issue and make gdb work with R?
Related
I'm trying to install wholebrain by Daniel Fürth, following the instructions on the macosX install page (available here). I am running MacOS Big Sur 11.5.2, R 4.1.2, and RStudio 2021.09.1.
Unfortunately, the program is not straight-forward to install and requires significant developer tools to work correctly. I'm not a programmer and have almost no experience with coding, so I've been mucking through the instructions for two days now trying to get the install to work correctly and I'm firmly stuck on the final step.
In RS, when I run, devtools::install_github("tractatus/wholebrain", INSTALL_opts=c("--no-multiarch")) I get the following error message:
/bin/sh: pkg-config: command not found filter.cpp:9:10: fatal error: 'fftw3.h' file not found #include "fftw3.h" ^~~~~~~~~ 1 error generated. make: *** [filter.o] Error 1 ERROR: compilation failed for package ‘wholebrain’
I have been trying to figure out what this means for quite awhile now and I think I've narrowed it down to R is not reading the location of the fftw header file from where it was installed by Homebrew. (I could be totally wrong, again- not a programmer)
From what I understand, Homebrew always installs under opt/homebrew/cellar. And, in fact, in there is the compiled fftw program with the needed "fftw3.h" file. But for some reason, RStudio is not able to find and read the file in that location.
From random googling and reading of other posted issues, I think that RStudio may expect the file to be under usr/local/include. Can I just copy and paste the header file into that folder? Or will I be screwing something up if I do that? I am totally intimidated by fftw's description of manual compilation so I don't really want to attempt that. Is there a way to change where R is looking for that header file? I already set my wd to "/" so shouldn't R be able to access any folder on my computer?
I want to post an answer here for anyone who comes after me with the same issue. It came down to RStudio not recognizing the programs Homebrew had installed because it wasn't reading the file location where Homebrew saves them. Homebrew always installs programs in /opt/homebrew/... Here is what I had to do:
In RStudio, open your Renviron file using this command: usethis::edit_r_environ()
In the file that opens (which for me was totally blank), type: PATH=/opt/homebrew/bin:${PATH}, or whatever your particular path you want prepended to the Renviron path is.
Quit RStudio and, when prompted, save. Re-open RStudio and run Sys.getenv("PATH") to check. Your new path (in the example above, '/opt/homebrew/bin') should now be prepended to the list of paths that RStudio will use when looking for programs/files. For me this now looks like /opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Applications/RStudio.app/Contents/MacOS/postback
Finally, I want to say thank you very much to Mark Setchell who really helped point me in the correct direction!
I know this question has already been asked, but I encounter an issue that I haven't seen elsewhere.
I am trying to build automatically a QT program on Jenkins through a JenkinsFile.
So I want to build this program in command line.
On Qt Creator, everything works fine, my makefile is generated and the program compiles.
But when I manually type the exact commands that are executed in Qt on a terminal (cmd and cygwin), the compilation fails.
The errors are usually ld: cannot find -lXXXXXX
My guess is that it is an environment problem so I tried to add some lib paths in the $PATH, $LIBRARY_PATH, and $LD_LIBRARY_PATH variables but it doesn't resolve the problem. The error just becomes Undefined reference to ___XXXXXX
I would appreciate some help on this issue !
Thanks.
EDIT
The building (slave) machine is a windows 7. Here is a screenshot of the compilation stage in Qt (which works fine). The commands I try to type in a terminal are exactly the same as the blue lines on the screenshot. (sorry some lines are written in French)
From the error message ld: cannot find -lXXXXXX and the environment variables, I would suppose that you are compiling in Linux/Unix. Now, if you are compiling with g++, the environment variables $PATH, $LIBRARY_PATH, and $LD_LIBRARY_PATH won't have any effect on finding libraries. What you may try is an -L argument to the compiler telling it where the library is located, I mean:
g++ -L /path/to/libXXXXX.so -l XXXXX -o result source.cpp
I'm calling an .exe from R using system("script.exe object").
I get Warning: running command had status 127. I know it means the .exe file has not been found.
I'm on windows. When I use shell instead of system it works like a charm. However, I am designing a Shiny application that will be deployed in a Linux environment (shinyapps.io). This is why I need to use system.
EDIT
On Windows, it works with system(paste("cmd.exe /c", "script.exe object"), intern = FALSE, wait = TRUE) as suggested here. But not when I deploy the app (on Linux).
HINT
Locally on Windows, if I replace system with system2: system2(paste("cmd.exe /c", "script.exe object"), wait = TRUE), it raises the status 127 warning and the output is exactly the same as in my deployed app on Linux.
It's tough to create a reproducible example here but if needed I can try. Please tell me.
Context: basically the .exe is a black box (compiled C++ code) that takes a .txt file as input and outputs another .txt file. I am using R to dump the .txt file to the current working directory, then read back in the .txt file generated by the .exe (created in the current working directory, where the .exe file is stored).
Just add \" could solve you problem, e.g.
> setwd("W:/www/ADemo/")
> system(paste0(getwd(),"/Hi 2.exe"))
Hello, world.
> setwd("W:/www/A Demo/")
> system(paste0(getwd(),"/Hi 2.exe"))
Warning message:
running command 'W:/www/A Demo/Hi 2.exe' had status 127
> system(paste0("\"",getwd(),"/Hi 2.exe","\" "))
Hello, world.
Update:
The 127 error is usually seen when there is a space in the path. One also needs to worry about the input of the application, e.g. "/path A/A 2" --in-path "/home/A/B C/d 123.dta". Here are some update comments:
system(shQuote(paste0(getwd(),"/Hi 2.exe"))) is much more convenient.
At least in R 3.2.4, the manual of system() recommends to use system2() instead to avoid path problem under Win/Linux/OSX/.
Update 2:
For Linux user, I created a function to detect the given file in your working directory is executable or not:
chkpermission<-function(file, mode='0777'){
exe_list <- system("echo `ls -l | grep -E ^-.{2}x\\|^-.{5}x\\|^-.{8}x` | awk '{print $9}'", intern=T)
if(length(exe_list)==0){
stop("no file is executable");
##Make sure you know what you are doing here, add a+x permission:
## if (!(file%in%exe_list)) Sys.chmod(file, mode = mode)
}
return(file%in%exe_list);
}
I've tested it on GNU awk/grep. The 2/5/8 indicates the executable permission of [u/2]ser, [g/5]roup, [o/8]thers., one could change it to meet the requirement.
The problem actually stemmed from the fact that .exe files are executables for Windows only. It does not work out of the box on Linux environments (you can use WINE but in my case it is not possible because I am calling the executable from within R, I don't have any sudo rights or anything on the virtual machine used by the host of my app). So I compiled the c++ code I had using g++ on a Linux virtual machine and used the .out file rather than the .exe.
Then in my R script I just needed these two calls:
system("chmod a+x script.out") # to make Linux understand that the file is an executable
system("./script.out object") # to run the script
I have R script within a plain text file named "TestFile.R".
I am running RStudio. I want to use the Windows console (cmd.exe) to pipe "TestFile.R" directly into the "R Script" editor of RStudio, without launching a new thread of RStudio.
This command in the console does exactly what I want:
rstudio -f TestFile.R
The contents of "TestFile.R" go straight into the RScript editor of the existing thread of RStudio.
It assumes, however, that "TestFile.R" is in the "bin" folder of RStudio, and also that
cmd.exe is running within that folder.
But I want to be able to do this from anywhere on my computer, using a console command like:
pathToRstudio\rstudio -f pathToTestFile\TestFile.R
To give an example, on my computer, this command fails:
C:\"Statistical packages"\RStudio\bin\rstudio -f E:\"my project"\TestFile.R
By trial and error, I discovered these solutions:
1/ omit the "C:\" part
2/ avoid quotation marks in the pathToTestFile.
So this console command works fine:
"Statistical packages"\RStudio\bin\rstudio -f E:\myproject\TestFile.R
Of course, I still am very restricted ; my default folder has to be "C:\", and I cannot have spaces in the path to TestFile.R, even though spaces within the Rstudio path are apparently OK !?
Could somebody please explain to me how to write this command in a way that is completely generic with regard to path specification?
I want to be able to run it from any folder, and have TestFile.R in any other folder. I do not want hassles about folder names containing spaces.
So I am trying to install a program on my windows machine that required me to install Cygwin to install it. So I am working from a README file and assueme I have compiled the code previously correctly (its one line sh build.sh) and when actually trying to use the program I get the following error:
BabakP#Babak /cygdrive/c/Users/BabakP/Desktop/test
$ ./Runlock input.tst output.tst 1
./Ostrich: Exec format error. Binary file not executable.
I guess I am trying to figure out why I am getting this error so any suggestions on how to troubleshoot it would be great!
./Ostrich is a Mac executable. It can't be executed under Cygwin. (A MacOS emulator that runs under Windows or Cygwin is theoretically possible, but I don't know of any such thing.)
Without knowing the details of the software you're trying to install, it's hard to say how or whether you can fix it.
You may be able to rebuild Ostrich from source (if you have the source, and if it's not MacOS-specfic).