Having trouble with stanford 106B in Xcode - c++

I am following stanford 106B online and download the assignment file "Mac os x 10.8 files"here. The download gave me proper xcode projects that can be opened with the current version of xcode(5.1.1) I am using.But while trying to run the project I repeatedly get this error. I'm using OS X 10.9.4
clang: error: unknown argument: '-fstack-check' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
is there anyone who can help? I'm trying to fix it for long but failed. it's killing me...
PS: I also found another post asking the same question https://stackoverflow.com/questions/24890564/having-trouble-starting-with-stanford-cs106b-course-with-xcode-5-1-1?lq=1

Related

unable to knit pdf on M2 Mac: pandoc error Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc: Bad CPU type in executable

I get this error
sh: /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc: Bad CPU type in executable
Error in strsplit(info, "\n")[[1]] : subscript out of bounds
In addition: Warning message:
In system(paste(shQuote(path), "--version"), intern = TRUE) :
running command ''/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc' --version' had status 126
MAC OS: 13.1
Macbook Air M2
Rstudio: 2022.12.0+353
Can someone please help. Thanks!
As suggested by #guna, I followed the GitHub link to find the solution. What I needed to do was run the following code in the Terminal:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
After this, the knitting started working fine again. No RStudio or R restart needed.
Ok, looks like Ventura upgrade removed Rosetta 2
Fix; install Rosetta 2
More here;
https://github.com/rstudio/rstudio/issues/12512

C++ build failing on MacOS

I'm trying to run my C++ program on my Macbook and I'm trying to run my program in VSCode by running the build task C/C++:clang++ build active file. However, every time I do this I get this error ld: can't open output file for writing: /Users/admin/first/first, errno=21 for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) The terminal process terminated with exit code: 1
This appears to be a simple permission problem here:
ld: can't open output file for writing
The linker cannot write to the file specified.
Edit: As correctly pointed to by molbdnilo, the error 21 is EISDIR, which means the file you are trying to write to already exists as a directory. So ... just this folder? :)
Did you brew install any c++ tools? Sometimes that is the source of these issues. The program is trying to use native OS versions of things when it should use Homebrew's or vice versa.

mex error 206 Matlab

The cpp code I received for a project isn't working so I want to compile and see if it compiles. It didn't compile, but I tried compiling another cpp file that I know works just to see what would happen. In both cases I get the following error:
EDU>> mex max.cpp
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang++", not a developer tool or in PATH
mex: compile of ' "max.cpp"' failed.
Any suggestions how I can either fix the cpp file or maybe I'm not running this correctly? Can't figure out where to go from here.
EDIT:
I figured it out. My mexopts.sh file was pointing to an old version of mac so I had to manually edit that file and change 10.7 to 10.9.
I figured it out. My mexopts.sh file was pointing to an old version of mac so I had to manually edit that file and change 10.7 to 10.9.

Compiling phantom.js to LLVM IR

I downloaded the phantomjs source off of their github. I am trying to compile phantomjs into LLVM bytecode. However, when I run
> clang -S -emit-llvm main.cpp
It keeps saying:
In file included from main.cpp:31:
./utils.h:34:10: fatal error: 'QtGlobal' file not found
#include <QtGlobal>
^
1 error generated.
I'm on Ubuntu 14.04. Do I need to install Qt or something?
BTW, I'm not sure if StackOverflow is the best place to ask this, but I couldn't think of any other SE site that would be better.

Error in compiling when installing Stan for R and when using Rcpp

I need to install Rstan for a data analysis class. The instructions are posted here http://code.google.com/p/stan/wiki/RStanGettingStarted. I'm running Mac OS 10.5.8 and R 2.15.1 GUI 1.52 Leopard build 32-bit (6188). I just installed Xcode version 3.1.4, the Xcode c++ compiler that is compatible with leopard (I had to get a mac developer account to do this).
Per the Stan installation instruction, I entered the following code to see if my compiler was working:
library(inline)
library(Rcpp)
src <- '
std::vector<std::string> s;
s.push_back("hello");
s.push_back("world");
return Rcpp::wrap(s);
'
hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE)
cat(hellofun(), '\n')
It returns the following error:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created!
Library/Frameworks/R.framework/Versions/2.15/Resources/library/
Rcpp/include/Rcpp/internal/export.h: In function ‘void
Rcpp::internal::export_range__dispatch(SEXPREC*, InputIterator,
Rcpp::traits::r_type_primitive_tag)’:
/Library/Frameworks/R.framework/Versions/2.15/Resources/
library/Rcpp/include/Rcpp/internal/export.h:56: internal
compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for
instructions.
make: *** [file795214e66510.o] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/
R CMD SHLIB file795214e66510.cpp 2>
file795214e66510.cpp.err.txt' had status 1
When I try to install stan:
install.packages('rstan', type = 'source') ]
I get this warning:
Warning message:
In install.packages("rstan", type = "source") :
installation of package ‘rstan’ had non-zero exit status
I have no idea how C++ works. All of my coding experience is in R and has not before required compiling into C++. I've been trying really hard to figure out what's wrong for the last 4 hours or so, googling these error messages over and over without much luck. Any help would be greatly appreciated and would also help about 10 other students in my class who are having identical or analogous problems. Thank you very, very much.
This looks to me like an issue with the installation of your C++ compiler or with your installation of the Rcpp package, rather than an issue with the rstan package. However, if g++ is causing an intractable problem for you, an alternative is the clang compiler, which should work with Rcpp and rstan if you create $HOME/.R/Makevars with these two lines
CC=clang
CXX=clang++
As mentioned in another answer, the first step is to get Rcpp working on your Mac (i.e,. at least pass the hello world example).
A similar issue for Rcpp previously:
https://stat.ethz.ch/pipermail/r-sig-mac/2010-July/007574.html
In addition, from this webpage http://useyourloaf.com/blog/2011/03/21/compiler-options-in-xcode-gcc-or-llvm.html, it seems that gcc 4.2 and 4.0 are both in Xcode 3.14 (not sure as it does not say it's 3.14). So try to make sure gcc 4.2.1 is used by R is important. Executing the following in a terminal will show what is the current version of gcc.
$ g++ -v