Statically Linking freeglut
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的更多相关文章
- [Artoolkit] Can I Use LGPL code for commercial application
这是一个比较普遍但又容易被忽略的问题. From: http://answers.google.com/answers/threadview/id/439136.html 假设背景: - want t ...
- nginx HttpLuaModule
http://wiki.nginx.org/HttpLuaModule#Directives Name ngx_lua - Embed the power of Lua into Nginx This ...
- DWF Toolkit on Microsoft Windows
If you are statically linking on Windows, you need these preprocessor defines: DWFTK_STATIC DWFTK_BU ...
- Cap'n Proto, FlatBuffers, and SBE
转自:utm_source=tuicool">http://kentonv.github.io/capnproto/news/2014-06-17-capnproto-flatbuff ...
- 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 ...
- java sqlite配置和自定义函数
资源 jetty Jetty Downloads地址 sqlite sqlite JDBC Driver 地址:bitbucket代码托管 和 Github代码托管 jetty配置sqlite 在je ...
- Nginx+lua+openresty精简系列
1. CentOS系统安装openresty 你可以在你的 CentOS 系统中添加 openresty 仓库,这样就可以便于未来安装或更新我们的软件包(通过 yum update 命令).运行下面的 ...
- OpenGL 笔记 <2> Compiling and Linking a shader program
Preface 这一节所有的主要内容都在一个OpenGL库文件中<LoadShaders.h> ,只需要用LoadShader()函数进行加载即可.但是由于老是出错,所以自己实现了一下,也 ...
- 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 ...
随机推荐
- C语言数据类型的转换(隐式转换)
算术运算符中的转换规则: double ←── float 高↑long↑unsigned↑int ←── char,short 低 注意: 图中横向箭头表示必须的转换,如两个float型数参加运算, ...
- STM32学习笔记:【001】常见数据查阅
了方便开发学习,现整理在学习过程中经常查阅的资料 (注意,以下资料都可以在ST给出官方手册中查到) 本人所持型号:STM32F429ZI-DISCOVERY, 芯片内核 :Cortex - ...
- 使用java的wsimport.exe生成wsdl的客户端代码【转】
使用java的wsimport.exe工具生成wsdl的客户端代码 wsimport -keep -d d:\ -s d:\src -p com.map -verbose http://192.168 ...
- Mac Office 2016 破解
官方最新版本office 是2016.15.38 此版本主要是修复了Excel内存损害漏洞. 官方下载的版本大小是1.67G,因为其他途径下载的版本,不确保是最新版本且为完整的版本.不知道我说的这个大 ...
- [Android] Android 用于异步加载 ContentProvider 中的内容的机制 -- Loader 机制 (LoaderManager + CursorLoader + LoaderManager.LoaderCallbacks)
Android 用于异步加载 ContentProvider 中的内容的机制 -- Loader 机制 (LoaderManager + CursorLoader + LoaderManager.Lo ...
- tomcat自动重新加载应用
前言 当应用配置文件发生变化时,无需重启tomcat,可以使tomcat重新加载应用. 场景 假设存在一个J2EE应用A,对应war文件名称为A.war,部署在tomcat的webapps目录下,即: ...
- 解决浏览器跨域限制方案之CORS
一.什么是CORS CORS是解决浏览器跨域限制的W3C标准,详见:https://www.w3.org/TR/cors/. 根据CORS标准的定义,在浏览器中访问跨域资源时,需要做如下实现: 服务端 ...
- 从虚拟机指令执行的角度分析JAVA中多态的实现原理
从虚拟机指令执行的角度分析JAVA中多态的实现原理 前几天突然被一个"家伙"问了几个问题,其中一个是:JAVA中的多态的实现原理是什么? 我一想,这肯定不是从语法的角度来阐释多态吧 ...
- extjs.net Combox赋值
1.直接赋值 ].Rows) //遍历获取两个值 { Ext.Net.ListItem listItem = new Ext.Net.ListItem(); //每次创建一个Ext.Net.ListI ...
- 【全文转载】Precision Helper:最佳免费 CHM 制作软件
跳至内容 善用佳软 IT义工的个人博客: 善用佳软= (善意+善于)应用优秀软件 xbeta= x(未知数)+β(改进测试版) Precision Helper:最佳免费 CHM 制作软件 许多用户都 ...