gcc下使用stl库出错,怎么解决

2024-05-13 19:55

1. gcc下使用stl库出错,怎么解决

如果可以的话,应当导出STL类的实例。或者不导出STL类的实例,只是简单地忽略C4251警告,但应该保证dll和exe都使用相同的STL头文件以及相同的编译设置。

gcc下使用stl库出错,怎么解决

2. c++ 编译出现 undefined reference to,检查了很多遍还是没发现错误。

你只有Vector类的声明,没有实现阿。

-----

g++ -o exo3 fonction_exo3.o exo3.o


你需要把实现链接起来:
g++ Vector.cpp
g++ -o exo3 fonction_exo3.o exo3.o Vector.o

3. C++ 函数模版 显示匹配 出错了

因为你写的min和std::min重名了,在函数中使用using声明使用哪个min或者使用时指定命名空间,还有,对于可以由函数参数确定模板参数,可以不给出模板参数


int main(void)
{
//cout<<max(1.5,6)<<endl;

using ::min; //指定使用全局的min,也就是你的min


cout<<min(8, 2.9)<<endl;
cout<< ::min(8, 2.9)<<endl; //这样也可以

return 0;
}

C++ 函数模版 显示匹配 出错了

4. c++程序出错了,哪位大神帮帮我

注意看出错信息

In instantiation of 'struct std::iterator_traits':|
说明在提到的头文件stl_iterator_base_types.h当中还有一个也叫point的类
把你的类改个名字吧
比如改成Point
那么就是
#include#includeusing namespace std;class Point{private:    int x;    int y;public:    Point(int a,int b)    {        x=a;        y=b;    }    friend double distance (Pointp1,Pointp2);};double distance(Pointp1,Point p2){    double d;    d=pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2);    return sqrt(d);}int main(){    Point p1(3,4),p2(0,0);    cout<<"两点之间的距离为:"<<distance(p1,p2)<<endl;    return 0;}试试吧 其他的没什么问题 函数同名没关系 参数不同就可以 

5. Android平台下NDK编译出现的问题,求高手指导!!

找到 ./obj/local/armeabi/libstlport_static.a 这个文件
然后 chmode 777 libstlport_static.a
然后再编译试试

Android平台下NDK编译出现的问题,求高手指导!!

6. NDK编译时,报错error: undefined reference to 'rand',是不是安卓库函数里面没有这个函数的实现呢?

把proj.android文件夹下的obj文件夹删除,重新编译试试

7. 编译C++代码出现下面错误no type named ‘iterator_category’ in ‘class std::vector<double>’

把代码贴出来把?你可以双击一下错误···会跳到错误的地方

编译C++代码出现下面错误no type named ‘iterator_category’ in ‘class std::vector<double>’

8. 使用g++或gcc34编译一个有关std::sort代码的错误,如何改正?

你把常指针引用和指针常引用混淆了。
static bool SortAccount(const Account*& pAcct1, const Account*& pAcct2);

应定义为static bool SortAccount(Account* const & pAcct1, Account* const & pAcct2);

指针可以直接给指针常引用赋值,但不能直接给常指针引用赋值。
因为你vector 定义vector内元素是Account*,不能直接给const Account*& 赋值,改成 Account* const &就OK 

vc6能编过不奇怪,因为VC6很多地方不合标准。