【问题标题】:How to install gcc -4.8.4 using homebrew in os x 10.10如何在 os x 10.10 中使用自制软件安装 gcc -4.8.4
【发布时间】:2016-02-16 12:00:28
【问题描述】:

我从 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?否则,我该如何处理这个问题?提前致谢!

【问题讨论】:

  • BurstyBTM. 来自哪里?
  • 文件夹中有BurstyBTM.oBurstyBTM.hBurstyBTM.cpp
  • 你能把ld: symbol(s) not found for architecture x86_64上面的错误行贴出来吗?
  • @purplepsycho 我已经编辑了这个问题。

标签: c++ gcc homebrew


【解决方案1】:

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

在make文件中,替换

CC=gcc-4.8

通过

CC=g++-4.8

如果你没有安装 g++,安装它

brew install gcc48 --enable-cxx

【讨论】:

  • 感谢您的回答。但是这次报错了:g++-4.8 BurstyBTM.o main.o -o bbtm Undefined symbols for architecture x86_64: "BurstyBTM::run(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make: *** [bbtm] Error 1
  • 你之前试过make clean吗?
  • 是的,但我认为可能没有必要:make: *** No rule to make target clean'。停止。`
  • 你的问题可能是因为.o文件是用gcc而不是g++编译的,所以你应该在再次运行make之前删除.o文件。
  • 你是对的!但是出现另一个错误,请查看更新。
猜你喜欢
  • 2013-03-28
  • 2017-05-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多