Annettest 0 Light Poster

Hello everyone.

I am having problems with compiling code on my Mac (OS X, 10.6.5).

This started happening suddenly when I tried to (1) install f2c using g++, and then (2) compile code including f2c. Now I'm having problems compiling ALL code!

I don't understand the error, and would really appreciate any help. From searching online, I suspect there may be a problem with my gcc compiler. Just in case, I reinstalled Xcode (twice), which installs a new compiler. But I still get the same error.

Here's the error:

cc1plus: error: /include: not a directory
cc1plus: error: /lib: not a directory
make: *** [Task1.o] Error 1

Someone told me to try executing:

gcc -v

to see what directories the gcc I'm using has by default. I got this:

Target: i686-apple-darwin10 Configured with: /var/tmp/gcc/gcc-5659~1/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5659)

This person said that my problem is shown by this piece of output:

--with-gxx-include-dir=/include/c++/4.2.1

He said it should read:

--with-gxx-include-dir=/usr/include/c++/4.2.1

and that there must therefore be a problem with the g++ installation on my system.

Is this right? I have reinstalled Xcode twice and don't know what else to do! I would really appreciate any help!

Thanks.

Dani AI

Generated

For : the symptoms point to a non-Apple g++/gcc binary being used that was built with a wrong install-prefix, so the compiler is trying to use root-level include/lib paths instead of the system headers. Reinstalling Xcode won't help if your shell still finds a different compiler earlier in PATH.

Quick checks to run (do these from Terminal):

which -a g++
ls -l $(which g++)
echo $PATH
env | egrep 'CPATH|C_INCLUDE|CPLUS|LIBRARY_PATH'

If which -a g++ shows a copy outside /usr/bin (for example in /usr/local/bin or /opt/local/bin), that is the culprit. To test without changing anything, invoke the Apple compiler by full path and try building.

Ways to fix it safely:

  • If a stray compiler in /usr/local/bin or /opt/local/bin is being picked up, rename or move it (do not delete) so /usr/bin comes first in PATH.
  • If you use MacPorts or Homebrew, either use their wrapper helpers to select the toolchain or adjust PATH so the desired tool is first.
  • Use xcode-select to ensure the developer tools path is correct if that applies on your macOS version.

After making a change, re-run the compiler info to confirm the include/lib prefixes point at system locations. Make a backup before moving files and avoid removing anything from /usr/bin. If the bad compiler came from the f2c install, undoing that install or re-running its install with proper options (or using the Apple compiler to rebuild) will resolve the mismatch.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.