似乎无法让错误消失。 错误如下。 我看了谷歌,仍然无法弄清楚。 这不像我对Cpp是新手,但是暂时还没有被愚弄。 奇怪的是它在Windows中使用G ++ … 错误: [泽@ fed0r! – – – ** _ _ *] $ g ++ main.cpp /tmp/ccJL2ZHE.o:在main函数中: main.cpp 🙁 .text + 0x11):未定义的引用“Help :: Help()” main.cpp 🙁 .text + 0x1d):未定义引用到`Help :: sayName()' main.cpp :(。text + 0x2e):未定义引用到`Help ::〜Help()' main.cpp 🙁 .text + 0x46):未定义引用到`Help ::〜Help()' collect2:ld返回1退出状态 main.cpp中 #include <iostream> #include "Help.h" using namespace […]
我已经得到这个未定义的符号build设与这个命令行: $ gcc test.cpp Undefined symbols: "___gxx_personality_v0", referenced from: etc… test.cpp很简单,应该build立好。 什么是交易?
为了创buildalgorithm模板函数,我需要知道类或模板参数中的x或X(以及y或Y)。 当使用我的函数为MFC CPoint类或GDI + PointF类或其他一些时可能会有用。 他们都使用不同的x。 我的解决scheme可以简化为以下代码: template<int> struct TT {typedef int type;}; template<class P> bool Check_x(P p, typename TT<sizeof(&P::x)>::type b = 0) { return true; } template<class P> bool Check_x(P p, typename TT<sizeof(&P::X)>::type b = 0) { return false; } struct P1 {int x; }; struct P2 {float X; }; // it also could […]
我试图编译我的程序,它返回这个错误: usr/bin/ld: cannot find -l<nameOfTheLibrary> 在我的makefile中,我使用命令g++并链接到我的库,这是一个符号链接到我的库位于另一个目录。 有没有可以添加的选项使其工作?
我使用Eclipse-CDT在Ubuntu x64上设置了一个C ++项目。 我基本上正在做一个你好的世界,并链接到商业第三方图书馆。 我已经包含链接到他们的库的头文件,但我仍然得到链接器错误。 除了显而易见的情况之外,是否还有其他一些可能的问题(例如,我确信我链接到了正确的库)。 有没有办法确认我连接的静态库是64位? 有没有办法确认图书馆有我期待的类(和方法)? Eclipse说: build立目标:LinkProblem 调用:GCC C ++链接器 g ++ -L / home / notroot / workspace / somelib-3 / somelib / target / bin -o“LinkProblem”./src/LinkProblem.o -lsomelib1 -lpthread -lsomelib2 -lsomelib3 ./src/LinkProblem.o:在函数`main'中: /home/notroot/workspace/LinkProblem/Debug/../src/LinkProblem.cpp:17:对“SomeClass :: close()”的未定义引用 ./src/LinkProblem.o:在函数SomeOtherClass中: /home/notroot/workspace/somelib-3/somelib/include/sql/somefile.h:148:对SomeClass :: SomeClass()的未定义引用 /home/notroot/workspace/somelib-3/somelib/include/sql/somefile.h:148:未定义对“SomeOtherClass的vtable”的引用 /home/notroot/workspace/somelib-3/somelib/include/sql/somefile.h:151:对SomeClass ::〜SomeClass()的未定义引用 ./src/LinkProblem.o:在函数`〜SomeOtherClass'中: /home/notroot/workspace/somelib-3/somelib/include/sql/somefile.h:140:未定义对“SomeOtherClass的vtable”的引用 /home/notroot/workspace/somelib-3/somelib/include/sql/somefile.h:140:对SomeClass ::〜SomeClass()的未定义引用 /home/notroot/workspace/somelib-3/somelib/include/sql/somefile.h:140:对SomeClass ::〜SomeClass()的未定义引用 collect2:ld返回1退出状态 make:*** [LinkProblem]错误1
有没有办法让gcc / g ++从命令行转储它的预处理器定义? 我的意思是像__GNUC__ , __STDC__等等。
我试图得到一个简单的例子来了解如何使用std::enable_if 。 读完这个答案之后 ,我想应该不难想出一个简单的例子。 我想使用std::enable_if来select两个成员函数,并只允许使用其中的一个。 不幸的是,下面的代码不能用gcc 4.7进行编译,并且在几个小时和几个小时的尝试之后,我问你们我的错误是什么。 #include <utility> #include <iostream> template< class T > class Y { public: template < typename = typename std::enable_if< true >::type > T foo() { return 10; } template < typename = typename std::enable_if< false >::type > T foo() { return 10; } }; int main() { Y< double […]
我正在制作一个小型的词汇记忆程序,在这个程序中,词语会随机地闪现在我的意思之中。 我想用Bjarne Stroustroup告诉我们的标准C ++库,但是我遇到了一个看起来很奇怪的问题。 我想更改一个long整型为std::string以便能够将其存储在一个文件中。 我已经雇用to_string()为相同。 问题是,当我用g ++(在版本标志中提到的版本4.7.0)编译它时,它说: PS C:\Users\Anurag\SkyDrive\College\Programs> g++ -std=c++0x ttd.cpp ttd.cpp: In function 'int main()': ttd.cpp:11:2: error: 'to_string' is not a member of 'std' 我的程序出现这个错误是: #include <string> int main() { std::to_string(0); return 0; } 但是,我知道这不可能,因为MSDN库明确表示它存在,堆栈溢出(对于g ++版本4.5) 早期的问题说,它可以用-std=c++0x标志打开。 我究竟做错了什么?
我正在尝试使用自定义类作为unordered_map的关键字,如下所示, #include <iostream> #include <algorithm> #include <unordered_map> //#include <map> using namespace std; class node; class Solution; class Node { public: int a; int b; int c; Node(){} Node(vector<int> v) { sort(v.begin(), v.end()); a = v[0]; b = v[1]; c = v[2]; } bool operator==(Node i) { if ( ia==this->a && ib==this->b &&i.c==this->c ) { return […]
g ++和gcc有什么区别? 哪些应该用于一般的c ++开发?