问题标签 [gcc4.7]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2100 浏览

c++11 - Mac 上的 gcc 4.7.3 和 gdb 7.6 - 奇怪的步进问题

我最近通过 MacPorts 在我的 OS X 10.7 系统上安装了GCC 4.7.3GDB 7.6,以便能够编译 C++11 代码。我不能使用 Apple 的自制 clang++ 和 gdb,因为它不允许我正确调试标准模板库代码(例如,如果我取消引用列表迭代器,程序会崩溃)。

现在,有了新的 GCC / GDB 组合,我在进入函数时遇到了一些奇怪的问题。举这个最小的例子:

如果我用 编译代码g++ -O0 -ggdb test.cpp,GDB 根本不会介入A::testMethod。我可以通过指定里面的代码行来设置断点A::testMethod,但不能通过指定方法名(b A::testMethod())。

更奇怪的是,如果我用 编译g++ -O0 -ggdb -std=c++11 test.cpp,如果从 调用 GDB 会进入 testMethod void test()。从主要方面来说,步进仍然不起作用。但是,现在,我可以通过仅指定方法名称来设置断点。

此外,一旦我在 GDB 中启动程序,就会收到 GDB 警告,如相关问题中所述。无论我是否指定,这些警告都会出现-std=c++11

我知道以下问题: 调试问题奇怪的 GDB 消息GDB 错误消息GDB 在 Mountain Lion 上失败,但他们没有帮助我。指定-gdwarf-2 -gstrict-dwarf也无济于事。

-EDIT- 的输出nm在两种情况下都是相同的:

有没有人设法让 GCC 4.7 和一些合适的调试器在 OS X Lion 上工作?

0 投票
2 回答
408 浏览

c++ - C++ 我期待一个缩小的转换错误,但没有得到它

Stroustrup 书中的以下代码中,我们被警告不要在我的版本 GCC (4.7.2) 上发生的缩小转换错误

正如在 ideone上演示的那样,这是一个错误还是我没有使用编译器的适当命令行参数运行?或者这是否意味着纯粹的语义错误?

0 投票
1 回答
1206 浏览

c++ - Issues of running C++11 executable compiled with gcc 4.7 on a computer with an older gcc / glibc / libstdc++

I am a newbie to C++ compilation in production environment I wonder if there are any issues in running a C++11 executable compiled with gcc4.7 ( on debian 6 ) on a computer with an older gcc version, an older glibc / libstdc++.

Thanks

EDIT :

I want to add more details to my question ( maybe it's better to open a new question ? )

I need to compile a legacy C++ code with new libs in C++11

  • on debian 7 ( for gcc 4.7 ) and run the exe on debian 6
  • on fedora 18 ( for gcc 4.7 ) and run the exe on centos 6

How to achieve this ?

0 投票
0 回答
1256 浏览

gcc - 构建我自己的 gcc 版本

我的发行版(CentOS 6.3)带有 gcc 4.4.6。因为我想尝试 Fortran2003 的特性,所以我决定编译 gcc 4.7。

我按照我在网上找到的步骤:先分别编译gmp、mpc、mpfr、ppl和cloog以及编译后的gcc。

我将配置的脚本运行为:

这一切正常,我能够使用make&进行编译make install

现在,当我用一个简单的测试程序(一个 hello world 之类的东西)尝试我的新编译器时,我得到了错误:

所以我决定设置LD_LIBRARY_PATH=/home/amcastro/gcc-4.7/output/lib ,然后我可以编译。

运行时出现错误:

所以我设置LD_LIBRARY_PATH=/home/amcastro/gcc-4.7/output/lib:/home/amcastro/gcc-4.7/output/lib64

现在程序运行正常。

问题是:为什么我的 gcc (4.4.6) 发行版不需要我设置LD_LIBRARY_PATH?发行版 gcc 如何知道在哪里寻找这些动态喜欢的库?我应该以某种方式让它们静态链接吗?我还读到设置LD_LIBRARY_FLAG不是一个好主意。还有其他解决方案吗?

先感谢您

一个。

0 投票
1 回答
860 浏览

gcc - gcc 4.7.3 编译期间的错误

我正在尝试在集群上编译本地版本的 gcc 4.7.3。对于配置:

./configure --prefix=$HOME/opt/gcc-4.7.3 --with-gmp=$HOME/opt/gmp --with-mpfr=$HOME/opt/mpfr --with-mpc=$HOME/opt/mpc --with-libelf=$HOME/opt/libelf

编译时我得到:

/home/users/didymos/opt/gmp/lib/libgmp.a(pprime_p.o):(.text+0x448): 未定义引用`__multi3'

/home/users/didymos/opt/gmp/lib/libgmp.a(mod_1.o):(.text+0x158): undefined reference to `__multi3'

/home/users/didymos/opt/gmp/lib/libgmp.a(mod_1.o):(.text+0x1b8): 未定义引用`__multi3'

/home/users/didymos/opt/gmp/lib/libgmp.a(mod_1.o):(.text+0x358): 未定义引用`__multi3'

/home/users/didymos/opt/gmp/lib/libgmp.a(pre_mod_1.o):(.text+0x74): undefined reference to `__multi3'

/home/users/didymos/opt/gmp/lib/libgmp.a(mod_1_1.o):(.text+0x60): 更多未定义的“__multi3”引用如下

collect2:错误:ld 返回 1 个退出状态

make[8]: * [libjavamath.la] 错误 1

make[8]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/32/libjava/classpath/native/jni/java-math'

make[7]: * [all-recursive] 错误 1

make[7]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/32/libjava/classpath/native/jni'

make[6]: * [all-recursive] 错误 1

make[6]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/32/libjava/classpath/native'

make[5]: * [all-recursive] 错误 1

make[5]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/32/libjava/classpath'

make[4]: * [all-recursive] 错误 1

make[4]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/32/libjava'

make[3]: * [multi-do] 错误 1

make[3]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/libjava'

make[2]: * [all-multi] 错误 2

make[2]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/libjava'

make[1]: * [all-target-libjava] 错误 2

make[1]: *等待未完成的工作....

libtool:链接:ranlib .libs/libgfortran.a

libtool: 链接: ( cd ".libs" && rm -f "libgfortran.la" && ln -s "../libgfortran.la" "libgfortran.la" )

make[6]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/32/nof/libgfortran'

make[5]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/32/nof/libgfortran'

make[4]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/libgfortran'

make[3]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/libgfortran'

make[2]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch/powerpc64-unknown-linux-gnu/libgfortran'

make[1]: 离开目录`/home/users/didymos/opt/gcc-4.3.7-scratch'

制作:* [全部] 错误 2

有任何想法吗?谢谢

0 投票
1 回答
182 浏览

c++ - 将从函数返回的向量传递给另一个函数

我有一个返回字符串向量的函数

我有另一个带有以下签名的构造函数的类(这实际上来自 TCLAP):

如果我尝试执行以下操作,我会收到错误

但不是当我执行以下操作时

这发生在 GCC 4.4.7 中,但不在 VS2010 中。错误如下:

为什么会发生此错误,我该怎么做才能将返回值直接传递给构造函数?

0 投票
2 回答
1462 浏览

c++ - 如何使用 isnan 作为 std::find_if (c++11) 的谓词函数

我有一段代码在 a 上运行,std::vector<double> cats并且正在执行以下操作:

这在 4.3 之前的 gcc 下编译,但不再使用 gcc 4.7.2 编译。我收到这样的错误:

我怎样才能让它在较新的 gcc 下编译?而且最好也在旧的gcc下?当然,无需摆脱 stl 并手动编写循环。如果两者都做不到,那么新的 gcc 就足够了,我会将两个实现都留在那里,并带有#define.

0 投票
2 回答
375 浏览

c++ - 模板向后兼容 gcc 4.7

采取以下代码片段:

它在 gcc 4.1.2 下编译良好,但在 gcc 4.7.2 下编译时产生以下错误:

这是我似乎能够重现此错误的最小示例代码片段,但我不知道发生了什么。为什么代码被拒绝,是否有正确的方法可以在两者下编译?

0 投票
1 回答
1024 浏览

c++ - 在 Linux 上编译 C++ 代码。需要使用 gcc/4.7.2。找不到标准库

就处理编译/链接错误而言,我有点新手。

我正在使用大型 C++ 代码(也有一些 C 文件)。我已经在使用 g++ 编译的 Mac 上成功运行它。现在我需要在基于 Linux 的集群上运行它,因为它在我的 Mac 上太慢了。该代码由我必须编译的几个库以及我自己的使用这些库的代码组成。

我可以使用默认的 g++ 编译器编译集群上的所有代码。然而,不幸的是,我发现我需要使用 gcc/4.7.2 进行编译,这样代码才能与集群上的其他软件一起使用。我一直在努力解决编译和链接错误。到目前为止,它们都与 C++ 与 C 的问题有关。例如,我不得不在一些 C 文件中添加“extern”。我不得不将包含从 C++ 更改为 C 头文件。

我的问题似乎与一个特定的库有关(我已经成功处理了所有其他库)。它在其目录中编译。但是当我进入我的运行目录时,我得到了各种似乎与构成这个问题库的代码有关的错误。我的猜测是它们主要与找不到标准库有关。我只是不明白我的包含有什么问题,如果有人能看看我在这个库的 makefile 中有什么,我会非常感激。这个库正式基于“C++”,但它的文件中似乎确实有很多 C 风格的代码。

有太多的错误(页面)和太多的代码来发布所有内容。我希望我发布的内容已经足够,如果有帮助可以添加。我无法在我的代码中找到它们的确切来源,因为它们非常神秘;例如:

Code.cpp:(.text+0x35): undefined reference to `std::cout'

我的 makefile 包含和编译器选项如下。我最初使用 QT 在我的 Mac 上创建了这个。我对其进行了修改,以便与 gcc/4.7.2 上的 Linux 集群一起使用。所以完全有可能有点乱。

首先我做(终端中的命令行):

模块加载 gcc/4.7.2

然后makefile是:

CC = gcc

定义 = -DIPMGEMPLUGIN -DNOPARTICLEARY -D__unix

CFLAGS = -c -g -O2 -pedantic -fno-nonansi-builtins -D__unix -m64

CXXFLAGS = -pipe -O2 -Wall -W -fPIC $(DEFINES) -lstdc++ -m64

INCPATH = -I。\

AR = ar cq RANLIB = ranlib -s 目标 = mylib.a

.后缀:.o .c .cpp .cc .cxx .C

.cpp.o: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cc.o: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cxx.o: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.Co: $(CC) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.co: $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"

现在我得到的错误种类:

Code.o: 在函数 _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.part.8': Code.cpp:(.text+0x12): undefined reference tostd::basic_ios >::clear(std::_Ios_Iostate)' Code.o: 在函数 _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.constprop.101': Code.cpp:(.text+0x35): undefined reference tostd::cout' Code.cpp:(.text+0x3a): 未定义引用`std:: basic_ostream >& std::__ostream_insert

(std::basic_ostream >&, char const*, long)' Code.cpp:(.text+0x3f): undefined reference to std::cout' Code.cpp:(.text+0x49): undefined reference tostd::cout' Code.cpp:(.text+0x53): undefined reference to std::cout' Code.o: In function _ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode。 constprop.99': Code.cpp:(.text+0x93): undefined reference to std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)' Code.o: In function _ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode.constprop.96': Code.cpp:(.text+0x103): undefined reference to std::ios_base::ios_base()' Code.cpp:(.text+0x10b): undefined reference tovtable for std::basic_ios' Code.cpp :(.text+0x11b): 对VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >' Code.cpp:(.text+0x15d): undefined reference to std::basic_iostream >::basic_iostream()' 的未定义引用 Code.cpp:(.text+0x16c): vtable for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >' Code.cpp:(.text+0x174): undefined reference to std::basic_stringstream, std::allocator >' 对 vtable 的未定义引用.cpp:(.text+0x17c):vtable for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >' Code.cpp:(.text+0x184): undefined reference to 对 std::的 vtable 的未定义引用 basic_streambuf >'

更进一步:

gl3.cpp:(.text+0x18d): undefined reference to `operator new[](unsigned long)'

gl3.cpp:(.text+0x1a1): undefined reference to `operator new[](unsigned long)'

gl3.cpp:(.text+0x1b5): undefined reference to `operator new[](unsigned long)'

gl3.cpp:(.text+0x1c9): undefined reference to `operator new[](unsigned long)'

gl3.cpp:(.text+0x1dd): undefined reference to `operator new[](unsigned long)'

/data/place/number/account/CodeDirectory/../ProblemLibraryDirectory/libProblem.a(gl3.o): 在函数Other::free_internal()': gl3.cpp:(.text+0x251): undefined reference to操作符中删除'gl3.cpp:(.text+0x262): ...

这对任何人都意味着什么吗?

0 投票
1 回答
207 浏览

c++ - 可以通过模板间接访问基类中的私有类型

我试图在编译时根据一个类型是否在给定范围内公开可用来选择要使用的类型。最好直接看代码:

我的意图是 in A,有一个类型Log,所以应该使用而不是 global ::Log,并且在B没有的地方,它应该使用 global ::Log。现在这两个工作都不管1.(我不正确的测试,看看该类型在这个范围内是否是私有的..)

问题出在Cand中D,通常 - 没有测试,Log::log()失败,因为它是私有的A。但是,如果std::conditional<>使用了,则没有编译错误,并且输出不正确,因为它带有前缀A:。那么,我错过了什么(除了不正确的测试 - 我需要以某种方式修复......)?如果没有,那么这种暴露私有类型的A方法是std::conditional合法的吗?

编辑:为了理智,我测试了以下内容:

它确实使用了 global ::Log,如果它是真的,它以某种方式使用 private A::Log

EDIT2:事实上,这似乎是一个更一般的条件,即您可以通过模板间接访问一些内部私有类型,例如:

编辑 3:好的 - 已经确认,这是一个报告的 GCC 错误,与 无关std::conditional,尚未在 4.7 或 4.8 中修复。http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47346

我将暂时保留这个问题..稍后将用上述内容关闭它。