在编译Kphone4.2时,提示以下错误:
c++ -I/usr/lib/qt3/include -Wall -O3 -I. -I../gsm -I../ilbc -I../dissipate2 -DHAVE_CONFIG_H -DSHARE_DIR=\"/usr/local/share/apps/kphone\" -DPO_DIR=\"/usr/local/share/kphone/translations//\" -c -o main.o main.cpp
In file included from main.cpp:5:
kcallwidget.h:70: error: extra qualification ‘KCallWidget::’ on member ‘setDTMFSender’
In file included from main.cpp:7:
kphoneview.h:57: error: extra qualification ‘KPhoneView::’ on member ‘DoCall’
make[1]: *** [main.o] 错误 1
make[1]: Leaving directory `/home/soft/kphone/kphone'
make: *** [all] 错误 2
查找原因如下:
很多比较旧的代码会有如写法
class Foo
{
int Foo::Foo(void);
}
在g++ 4.1以后会报错 extra qualification
直接改为
class Foo
{
int Foo(void);
}
即可
Extra qualification errors are common with gcc4. This means a class is
redundantly mentioned with a class function. Just remove the part before :: on the mentioned line"
Extra qualification error是使用版本4以上的GCC/G++编译C++程序时经常出现的错误。
这是语句中多引用了类的名称--把函数前面::的类名称去掉即可
如:
std::string Socket::connectionName();
connectionName是类Socket的成员函数,而Socket是std 中type为string的子类.
这里不用重复引用Socket,可直接写成
std::string connectionName();
1、invalid conversion from ‘const char*’ to ‘char*’
解决:
pn = strchr(p, PATH_SP);
改为
pn = (char *)strchr(p, PATH_SP);
2、 ‘PACKAGE_STRING’ was not declared in this scope
‘PACKAGE_BUGREPORT’ was not declared in this scope
解决:
fprintf(stderr,"%s Copyright: YuHong(992126018601033)",PACKAGE_STRING);
fprintf(stderr,"bug report: %s\n\n",PACKAGE_BUGREPORT);
替换为:
fprintf(stderr,"CTorrent devel Copyright: YuHong(992126018601033)");
fprintf(stderr,"bug report: [email protected]\n\n");
3、fatal error: openssl/sha.h: 没有那个文件或目录
缺少 openssl dev包,解决:安装libssl-dev
sudo apt-get install libssl-dev
4、undefined reference to `SHA1_Init'
undefined reference to `SHA1_Update'
undefined reference to `SHA1_Final'
解决1:
1.确认你装了openssl
2.g++ 后加上参数 -lssl
解决2:
或者/usr/lib/libssl.so加入程序library库下
Eclipse CDT下设置g++参数的方法
Project->Properties->C/C++ Build->Setting->GCC C++ Linker->Miscellaneous->Linker Flag 处加上 -lssl