如何在 os x 10.10 中使用自制软件安装 gcc -4.8.4

How to install gcc -4.8.4 using homebrew in os x 10.10

本文关键字:安装 软件 gcc os      更新时间:2023-10-16

我已经从github克隆了某人的c ++代码,但未能成功。作者告诉我,他使用的 gcc 版本是 4.8.4,他可以成功运行它。所以我使用 brew install homebrew/versions/gcc48 安装了 gcc48,并在放置在他代码文件夹中的makefile中指定了 gcc 的版本。

但是,编译过程中出现错误:

g++-4.8  -c -pipe -O3 BurstyBTM.cpp -o BurstyBTM.o 
BurstyBTM.cpp: In member function 'Pvec<double> BurstyBTM::compute_pz_b(Biterm&)':
BurstyBTM.cpp:129:23: error: could not convert 'pz.Pvec<T>::normalize<double>(0.0)' from 'void' to 'Pvec<double>'
   return pz.normalize();
                       ^
BurstyBTM.cpp: In member function 'void BurstyBTM::save_pz(std::string)':
BurstyBTM.cpp:158:41: error: conversion from 'void' to non-scalar type 'Pvec<double>' requested
   Pvec<double> pz = nb_z.normalize(alpha);
                                         ^
BurstyBTM.cpp: In member function 'void BurstyBTM::save_pw_z(std::string)':
BurstyBTM.cpp:164:37: error: conversion from 'void' to non-scalar type 'Pmat<double>' requested
   Pmat<double> pw_z = nwz.normr(beta);
                                     ^
make: *** [BurstyBTM.o] Error 1

如何专门安装带有 4.8.4 版的 gcc?否则,我该如何处理此问题?提前感谢!

您尝试使用 C 编译器而不是C++编译器编译代码。

在"生成文件"中,替换

CC=gcc-4.8

CC=g++-4.8

如果您没有安装 g++,请使用

brew install gcc48 --enable-cxx