0

I have an OSX 10.7 computer with a non-administrator account, and was attempting to install the pre-compiled versions of gcc and g++ found here. I've attempted to use the answers presented in these questions (three different links) to compile some code with g++, to confusing avail. I have a folder structure like this:

~/code/:
    usr/:
        local/:
            bin/ (3.6MB)
            include/ (8.6MB)
            lib/ (51MB)
            libexec/ (49MB)
            share/ (16MB)
    c++/:
        source/ (contains .cpp files)

g++ -v returns this:

code USER$ usr/local/bin/g++ -v
Using built-in specs.
COLLECT_GCC=usr/local/bin/g++
COLLECT_LTO_WRAPPER=/Users/USERNAME/code/usr/local/bin/../libexec/gcc/    x86_64-apple-darwin11.4.0/4.7.1/lto-wrapper
Target: x86_64-apple-darwin11.4.0
Configured with: ../gcc-4.7.1/configure --enable-languages=fortran
Thread model: posix
gcc version 4.7.1 (GCC)

An attempt at compiling a file that "#include"s only iostream:

$ usr/local/bin/g++ c++/source/test.cpp -o ex6
In file included from     /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/postypes.h:42:0,
             from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/iosfwd:42,
             from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ios:39,
             from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ostream:40,
             from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/iostream:40,
             from c++/source/ex6.cpp:1:
/Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/cwchar:46:19: fatal error: wchar.h: No such file or directory
compilation terminated.

I tried compiling with some flags recommended in one of the links mentioned, like this: (with all combinations of "usr/" to "usr/local/include/" and "usr/" to "/usr/local/lib" giving the same result (which is also the same as using no flags).

$ /Users/USERNAME/code/usr/local/bin/g++ source/ex6.cpp -I/Users/USERNAME/code/usr/local/include/ -L/Users/USERNAME/code/usr/local/lib/In file included from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/postypes.h:42:0,
             from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/iosfwd:42,
             from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ios:39,
             from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ostream:40,
             from /Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/iostream:40,
             from source/ex6.cpp:1:
/Users/USERNAME/code/usr/local/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/cwchar:46:19: fatal error: wchar.h: No such file or directory
compilation terminated.

In short, I'm having trouble understanding what the answers in the links provided are saying to do. I saw reference to a specs file, which I could find no specific information for, and "-Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)", for which I couldn't figure out what I was supposed to substitute for "DEFAULT_LIB_INSTALL_PATH".

What should I do to point the downloaded g++ compiler to its own files without placing them in their default location, as I do not have administrative capabilities on this account?

I will provide any information as necessary.

Community
  • 1
  • 1
mckryall
  • 27
  • 1
  • 9

1 Answers1

0

It looks like you don't have required header files. You need to install Command Line Tools from Apple Developers site (free registration needed). The problem is that you don't have administrator account. I suggest that you ask the administrator to install the tools for you. If it is not possible you could try to extract the contents of downloaded package (DevSDK.pkg) to your local directory (Pacifist can do that) and pass the path with the missing headers to your compiler. I haven't tried that though.

baf
  • 4,531
  • 1
  • 21
  • 24
  • I actually have tried that (using Pacifist, even). I can't remember why, but it didn't work. I tried using a guide that used tar to unzip the pkg files, and I think that there was something about the file structure that I didn't know how to deal with. I'll check. – mckryall Apr 19 '15 at 13:15
  • I can't find the tutorial that I tried to use. I'm fairly certain that it was on stackoverflow, though. – mckryall Apr 19 '15 at 13:27
  • It is easy. Just use Pacifist to extract `usr/include` folder with libc headers to your local folder. Then add `-I/path/to/extracted/include` to compiler. – baf Apr 19 '15 at 20:06
  • I just tried that, and it gave the same message. The exact command that I used is `$ ../usr/local/bin/g++ -I../include source/ex6.cpp`. I, then, tried copying the files within include to the downloaded g++ directory (I backed it up before that), without replacing the only conflicting folder: "c++". Same message. I tried replacing "c++". Same message. I don't entirely understand what I'm doing wrong here. – mckryall Apr 19 '15 at 23:24
  • If you have exactly the same error message as before, complaining about missing `wchar.h` file, make sure the file is in the folder you copied from downloaded package. Also make sure you pass the file path to the compiler – baf Apr 20 '15 at 05:49
  • I made sure before I moved the folder that `wchar.h` was there. What do you mean by "pass the file path to the compiler? Would you mind typing out the command that I should use, based on the command in my above comment and the file structure that I have provided, with `include` being at `code/include/`. – mckryall Apr 20 '15 at 12:56
  • I will try that, but how is that path different from `../include` when in the `c++` folder? – mckryall Apr 20 '15 at 17:07