无法使用头文件链接.so文件:Linux上的GLEW和freeglut库的未定义引用

时间:2017-07-13 13:58:21

标签: c++ ubuntu glut glew freeglut

我正在使用docker VM,我在我的docker镜像上安装了glew和freeglut,并通过这样做更新了环境变量以包含.h和.so文件:

> export $PATH = /usr/include/GL:

> export $PATH = /usr/lib/:

因为我的main.cpp文件使用两个库。 所以当我这样编译文件时:

g++ main.cpp 

它打印出以下错误:

  

/tmp/ccZTc4GP.o:在函数main': main.cpp:(.text+0x621): undefined reference to __ glewGenBuffers'中   main.cpp :(。text + 0x636):对__glewBindBuffer' main.cpp:(.text+0x649): undefined reference to __ glewBufferData'的未定义引用   main.cpp :(。text + 0x676):对__glewBindBufferBase' main.cpp:(.text+0x6f3): undefined reference to __ glewMemoryBarrier'的未定义引用   main.cpp :(。text + 0x701):对__glewMapBufferRange' /tmp/ccZTc4GP.o: In function __ static_initialization_and_destruction_0(int,int)'的未定义引用:   main.cpp :(。text + 0x796):未定义引用std::ios_base::Init::Init()' main.cpp:(.text+0x7a5): undefined reference to std :: ios_base :: Init :: ~Init()'   /tmp/ccZTc4GP.o:(.eh_frame+0x73):对__gxx_personality_v0' /tmp/cc5rJijl.o: In function ParallelMapping :: init()'的未定义引用:   ParallelMapping.cpp :(。text + 0x57):对__glewCreateProgram' ParallelMapping.cpp:(.text+0x69): undefined reference to __ glewCreateShader'的未定义引用   ParallelMapping.cpp :(。text + 0x93):对__glewShaderSource' ParallelMapping.cpp:(.text+0xb3): undefined reference to __ glewCompileShader'的未定义引用   ParallelMapping.cpp :(。text + 0xc4):对__glewGetShaderiv' ParallelMapping.cpp:(.text+0xeb): undefined reference to __ glewGetShaderInfoLog'的未定义引用   ParallelMapping.cpp :(。text + 0x10d):对__glewAttachShader' ParallelMapping.cpp:(.text+0x129): undefined reference to __ glewLinkProgram'的未定义引用   ParallelMapping.cpp :(。text + 0x13d):未定义引用__glewUseProgram' /tmp/cc5rJijl.o: In function ParallelMapping :: compute(int,int,int,int,int,int,int,float *,float *,int,int,int) “:   ParallelMapping.cpp :(。text + 0x199):对__glewUseProgram' ParallelMapping.cpp:(.text+0x1aa): undefined reference to __ glewUniform1f'的未定义引用   ParallelMapping.cpp :(。text + 0x1bb):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x1da): undefined reference to __ glewUniform1f'的未定义引用   ParallelMapping.cpp :(。text + 0x1eb):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x20a): undefined reference to __ glewUniform1f'的未定义引用   ParallelMapping.cpp :(。text + 0x21b):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x23a): undefined reference to __ glewUniform1f'的未定义引用   ParallelMapping.cpp :(。text + 0x24b):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x26a): undefined reference to __ glewUniform1f'的未定义引用   ParallelMapping.cpp :(。text + 0x27b):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x29a): undefined reference to __ glewUniform1f'的未定义引用   ParallelMapping.cpp :(。text + 0x2ab):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x2ca): undefined reference to __ glewUniform1f'的未定义引用   ParallelMapping.cpp :(。text + 0x2db):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x2fa): undefined reference to __ glewUniform1fv'的未定义引用   ParallelMapping.cpp :(。text + 0x30f):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x330): undefined reference to __ glewUniform1fv'的未定义引用   ParallelMapping.cpp :(。text + 0x345):对__glewGetUniformLocation' ParallelMapping.cpp:(.text+0x366): undefined reference to __ glewDispatchCompute'的未定义引用   /tmp/cc5rJijl.o:在函数ParallelMapping::initGLEW()': ParallelMapping.cpp:(.text+0x392): undefined reference to glutInitDisplayMode'中   ParallelMapping.cpp :(。text + 0x397):对glewInit' /tmp/cc5rJijl.o: In function ParallelMapping :: initGLUT()'的未定义引用:   ParallelMapping.cpp :(。text + 0x3c2):对glutInit' ParallelMapping.cpp:(.text+0x3cc): undefined reference to glutCreateWindow'的未定义引用   collect2:错误:ld返回1退出状态

它知道函数在头文件中,但它不能引用.so文件。

如何将两个文件链接在一起?

0 个答案:

没有答案