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. Nginx记录-Nginx基础(转载)

    1.Nginx常用功能 1.Http代理,反向代理:作为web服务器最常用的功能之一,尤其是反向代理. Nginx在做反向代理时,提供性能稳定,并且能够提供配置灵活的转发功能.Nginx可以根据不同的 ...

  2. PHP7 网络编程(四)signal信号【待】

    https://blog.csdn.net/summy_j/article/details/73199069

  3. PHP 调第三方跨域接口示例

    <?php ); //错误信息 ); //php启动错误信息 ini_set('date.timezone','Asia/Shanghai'); ); //打印出所有的 错误信息 ini_set ...

  4. RIPS PHP源码静态分析(转)

    0x00背景 对于PHP代码审计的需求,我们当然需要一款好的php代码审计分析工具--RIPS,它使用了静态分析技术,能够自动化地挖掘PHP源代码潜在的安全漏洞如XSS ,sql注入,敏感信息泄漏,文 ...

  5. STLINK V2安装使用详解

    1.      解压st-link_v2_usb driver.zip文件. 2.       运行解压后的st-link_v2_usbdriver.exe文件,安装STLINK V2驱动程序.安装路 ...

  6. 初识生成器与生成器表达式 Day12

    一.生成器 1,生成器基本概念 生成器的实质是迭代器 迭代器:Iterator 内部同时包含了__iter__()和__next__()函数 可迭代对象:Iterable 内部包含__iter__() ...

  7. ARC071D Infinite Sequence

    传送门 仔细观察可以发现,如果在一个\(> 1\)的数后面放一个\(> 1\)的数,那么后面的序列也就确定了,所以我们考虑dp出特定长度的序列,然后在后面加上能确定序列的数来贡献答案 为了 ...

  8. 商业版微信小程序开发流程

    一.产品阶段 ①功能规划思维导图——产品经理了解清楚整个项目需求,产出清晰明确的功能需求说明. ②需求报价预算——产品经理确定好功能需求后,输出整个项目开发的报价方案. ③组建技术开发团队——初步确认 ...

  9. mybatis批量更新报错

    批量更新sql <update id="updateAutoAppraiseInfo" parameterType="Object"> <fo ...

  10. Centos7 nginx提示错误 Access denied.

    SELinux will cause this error on CentOS/RHEL 7+ by default :( CentOS/RHEL 7+ 系统默认会因为SELinux出现这个报错 To ...