FreeGLUT linking Issues in Linux

本秂侑毒 提交于 2019-12-01 04:31:33

You have to pass the libraries last (after the object file)

g++  -I/usr/include -L/usr/lib/x86_64-linux-gnu Main.o \
  -lGL -lglut -lGLU -lGLEW -lX11 -lm -lrt -lpng -o main

The reason behind this is, that the linker only links symbols, that are currently undefined. If you pass the libraries before the object files, then there aren't any undefined symbols to be linked and compilation/linking will therefore fail.

The libraries need to come after your object files:

g++ -I/usr/include -L/usr/lib/x86_64-linux-gnu Main.o -lGL -lglut -lGLU -lGLEW -lX11 -lm -lrt -lpng  -o main
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!