问题
In R 3.4.0,
install.packages('RODBC', type='source')
fails on macOS 10.12.4. I also downloaded RODBC_1.3-15.tar.gz
from CRAN and tried,
R CMD INSTALL RODBC_1.3-15.tar.gz
In both cases, I got "ODBC headers sql.h and sqlext.h not found". A discussion of this in Installation of RODBC/ROracle packages on OS X Mavericks says the following:
To fix this, you need to download the latest version of iODBC (www.iodbc.org), and then unzip the file and set your header and library search paths to the location where you put the unzipped package. If you don't know how to set your search paths, you could just put the header files (
sql.h
andsqlext.h
) in the/usr/include
directory, and thelibiodbc.a
file in the/usr/lib
directory.
I downloaded iodbc-42.5.tar.gz
and untarred it into a directory next to RODBC, untarred from RODBC_1.3-15.tar.gz
. Sadly, I can't find how to set header and library search paths, and when I try to put the header files in /usr/include
, the system won't let me.
iodbc-42.5/iodbc/README.MACOSX
says,
You first need to install the latest Mac OS X Developer Packages, which can be found at http://developer.apple.com/tools
I think I've done that, but I don't know how to check it. [In fact, I think I've done it multiple times: The message ODBC headers sql.h and sqlext.h not found
, disappeared for a while from the still-negative response to install.packages('RODBC', type='source')
, only to reappear later after I successfully installed port
and ran sudo port install gcc6
. Then I got ODBC headers sql.h and sqlext.h not found
again.]
iodbc-42.5/iodbc/README.MACOSX
continues,
Then, you can open the Xcode Project Builder files under
mac/iODBCinst
,mac/iODBC
,mac/iODBCtest
andmac/iODBCtestw
.
I don't know how find any of these. It further continues,
or execute the following commands from a terminal session to build all the frameworks and demo applications:
$ cd mac $ make
I did $ cd mac
and got -bash: cd: mac: No such file or directory
. Evidently, I need to substitute something for mac
here, but I don't know what. ???
Thanks.
回答1:
I solved the problem with:
ODBC_INCLUDE=/path/to/libiodbc-srcs/include R CMD INSTALL RODBC
where "/path/to/libiodbc-srcs/include" is the path to the "include" folder containing the missing files, "sql.h" and "sqlext.h". In my case it was something like '~/Documents/Rstuff/iodbc-42.5/iodbc/include', which I checked with the following in R:
dir('~/Documents/current/Rstuff/iodbc-42.5/iodbc/include')
Then the following worked for me:
ODBC_INCLUDE=~/Documents/current/Rstuff/iodbc-42.5/iodbc/include R CMD INSTALL RODBC
This is described in p. 19 of https://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf, except that contains a stray quote (<'>), which threw me off the first few times I read it, because was not familiar with that syntax.
On R-Sig-Mac, Marc Schwartz offered two suggestions: First, Installation of RODBC on OS X Yosemite, which may work with "brew"; I didn't try that, because I got the above to work first.
Second:
install.packages("RODBC", type = "source",
configure.args = "--with-odbc-include=/path/to/libiodbc-srcs/include/")
This should work also with the path substitution mentioned above.
I hope this helps someone else.
来源:https://stackoverflow.com/questions/43804850/how-to-install-rodbc-on-macos-sierra-10-12-4