undefined reference to `ANativeWindow_fromSurface'

在调用ANativeWindow_fromSurface()和ANativeWindow_setBuffersGeometry()出现编译错误:
undefined reference to `ANativeWindow_setBuffersGeometry’
undefined reference to ‘ANativeWindow_fromSurface’

解决方法:
在CMakeList.txt中添加android共享库

find_library(
        android
        android
)

target_link_libraries(
        render

        ${log-lib}
        ${egl}
        ${gles}
        ${android}
)
发布了24 篇原创文章 · 获赞 15 · 访问量 5万+
展开阅读全文

c++ 编译时报错 "undefined reference to ……"

03-17

![编译情况](https://img-ask.csdn.net/upload/201803/17/1521251236_172399.png) 总共有五个文件,Graph.h ,Graph.cpp,diamond.h.diamond.cpp,new.cpp 编译成功的是我把diamond类的声明和定义(Graph的声明和定义也放在了一个文件里,但是没有影响)都放在diamond.cpp里。 new.cpp 就是包含了"Graph.h"和"diamond.",然后用diamond创建了一个对象,调用ShapePrint()函数。 Graph.h ``` #ifndef _Graph_H_ #define _Graph_H_ class shape { public: void ShapePrint(); void ShapePrint(int x); void ShapePrint(int x,int y); int GetLength_x(); int GetLength_y(); protected: void SetLength_x(int length_x); void SetLength_y(int length_y); private: int length_x ; int length_y ; }; #endif ``` diamond.h ``` #include <iostream> #include <iomanip> #include "Graph.h" #ifndef _diamond_ #define _diamond_ class diamond:public shape{ public: diamond(); diamond(int x); int GetLength(); protected: void SetLength(int l); private: int length; }; #endif ``` diamond.cpp ``` #include "diamond.h" using namespace std; void diamond::SetLength(int l) { this->length = l; } int diamond::GetLength() { return length; } diamond::diamond() { SetLength(7); } diamond::diamond(int l) { SetLength(l); } void diamond::ShapePrint() { int length=GetLength(); for(int i=1;i<=length;++i) { cout<<setw(length-i+1)<<"*"; if(i!=1) cout<<setw(2*i-2)<<"*"<<endl; else cout<<endl; } for(int k=1;k<=length-1;k++) { cout<<setw(k+1)<<"*"; if(k==length-1) cout<<endl; else cout<<setw(2*(length-k)-2)<<"*"<<endl; } } void diamond::ShapePrint(int x) { int length=GetLength(); for(int i=1;i<=length;++i) { cout<<setw(x+(length-i+1))<<"*"; if(i!=1) cout<<setw(2*i-2)<<"*"<<endl; else cout<<endl; } for(int k=1;k<=length-1;k++) { cout<<setw(x+k+1)<<"*"; if(k==length-1) cout<<endl; else cout<<setw(2*(length-k)-2)<<"*"<<endl; } } void diamond::ShapePrint(int x,int y) { int length=GetLength(); for(int i=1;i<=y;i++) cout<<endl; for(int i=1;i<=length;++i) { cout<<setw(x+(length-i+1))<<"*"; if(i!=1) cout<<setw(2*i-2)<<"*"<<endl; else cout<<endl; } for(int k=1;k<=length-1;k++) { cout<<setw(x+k+1)<<"*"; if(k==length-1) cout<<endl; else cout<<setw(2*(length-k)-2)<<"*"<<endl; } } ``` 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览