It’s possible statically link freeglut into your applications, instead of dynamically linking against the DLL as detailed above. The main disadvantage of static linking is that when an updated version of freeglut becomes available, the application must be recompiled in order to use the newer version. This is much more effort than when using dynamic linking, where it’s only necessary to deploy the newer version of the DLL—if your user has freeglut knowledge, they could even do this for their self! In any case, if you do want to use static linking it’s fairly simple.

The compilation step is almost the same as before, except that you need to define “FREEGLUT_STATIC” before any freeglut headers are included. This is best done by adding “-D FREEGLUT_STATIC” to the compiler command line. The linker step is also slightly different, as you must specify the static version of the freeglut library rather than the dynamic import library. It’s additionally necessary to link against the Windows multimedia library and GDI libraries, as freeglut uses functions from both of these libraries.

Given a source file “example.c”, which you want to compile to an application “example.exe”, you can compile and link it with the static freeglut library using following commands:

gcc -c -o example.o example.c -D FREEGLUT_STATIC -I"C:\Program Files\Common Files\MinGW\freeglut\include"

gcc -o example.exe example.o -L"C:\Program Files\Common Files\MinGW\freeglut\lib" -lfreeglut_static -lopengl32 -lwinmm ^
-lgdi32 -Wl,--subsystem,windows
[Windows 7 Command Prompt showing the compile and link commands being executed.]
If you get undefined references to functions when trying to statically link freeglut into your application, check your preprocessor definition and linker flags—static linking will fail if you forget to define “FREEGLUT_STATIC”, or if you have defined it but are linking against wrong libraries.

Statically Linking freeglut的更多相关文章

  1. [Artoolkit] Can I Use LGPL code for commercial application

    这是一个比较普遍但又容易被忽略的问题. From: http://answers.google.com/answers/threadview/id/439136.html 假设背景: - want t ...

  2. nginx HttpLuaModule

    http://wiki.nginx.org/HttpLuaModule#Directives Name ngx_lua - Embed the power of Lua into Nginx This ...

  3. DWF Toolkit on Microsoft Windows

    If you are statically linking on Windows, you need these preprocessor defines: DWFTK_STATIC DWFTK_BU ...

  4. Cap'n Proto, FlatBuffers, and SBE

    转自:utm_source=tuicool">http://kentonv.github.io/capnproto/news/2014-06-17-capnproto-flatbuff ...

  5. Application binary interface and method of interfacing binary application program to digital computer

    An application binary interface includes linkage structures for interfacing a binary application pro ...

  6. java sqlite配置和自定义函数

    资源 jetty Jetty Downloads地址 sqlite sqlite JDBC Driver 地址:bitbucket代码托管 和 Github代码托管 jetty配置sqlite 在je ...

  7. Nginx+lua+openresty精简系列

    1. CentOS系统安装openresty 你可以在你的 CentOS 系统中添加 openresty 仓库,这样就可以便于未来安装或更新我们的软件包(通过 yum update 命令).运行下面的 ...

  8. OpenGL 笔记 <2> Compiling and Linking a shader program

    Preface 这一节所有的主要内容都在一个OpenGL库文件中<LoadShaders.h> ,只需要用LoadShader()函数进行加载即可.但是由于老是出错,所以自己实现了一下,也 ...

  9. How to put a relative path for a DLL statically loaded?

    How to put a relative path for a DLL statically loaded? I have a DLL made in Delphi 7/Windows XP tha ...

随机推荐

  1. HDU 1015(字符运算 **)

    题意是在一段大写英文字符中找出 5 个字符通过代入公式运算得到目标值,如有多组字符满足题意,则输出字典序最大的一组,否则输出 no solution. 应该是用深搜做的,但是直接暴力也过了……(应该没 ...

  2. 细说JDK日志组件

    1. 概述 JDK自带的日志组件在包java.util.logging下,如图: 2. 架构如上图所示,JDK日志组件核心元素包括:Logger,Handler,Filter和Formatter,他们 ...

  3. SQL行列转置

    今天给公司同事们出了一道例行考试题,要求写一句SQL语句从上面表转换为下面表,经过艰难思索,一个同事做了出来. 小区             总数    A类车 B类车 C类车建业森林半岛     2 ...

  4. 【python小练】0014题 和 0015 题

    第 0014 题: 纯文本文件 student.txt为学生信息, 里面的内容(包括花括号)如下所示: { ":["张三",150,120,100], ":[& ...

  5. VUE项目安装

    连接转载:https://www.cnblogs.com/Colwill-Blog/p/6682091.html 刚刚开始学习Vue.js.今天分享一下我的Vue项目安装过程. 我是windows系统 ...

  6. 迅为-IMX6UL开发板丨双网口丨双CAN总线丨4路USB HOST丨2路串口、6路插座引出,共8路串口丨1路RGB信号丨2路LVDS信号

    迅为iMX6UL开发板多路串口开发平台迅为i.MX 6UL开发板基于ARM Cortex-A7内核,主频高达528 MHz,内存:512MDDR3存储:8G EMMC,支持2路CAN,2路百兆以太网, ...

  7. Python 9 进程,线程

    本节内容 python GIL全局解释器锁 线程 进程 Python GIL(Global Interpreter Lock) In CPython, the global interpreter l ...

  8. IDEA-使用技巧

    IDEA--个性化配置 - 心飞扬的博客 - CSDN博客--里面很好,http://blog.csdn.net/afzaici/article/details/71524643 IntelliJ I ...

  9. DeepLearning.ai-Week1-Convolution+model+-+Step+by+Step

    1 - Import Packages import numpy as np import h5py import math import matplotlib.pyplot as plt %matp ...

  10. MyBatis-Plus的简单使用

    mybatis-plus也只是听过,可是终究没有使用过.于是自己花几天晚上的时间研究mybatis-plus的使用. 下面的研究也是基于其官网:http://mp.baomidou.com/guide ...