zoukankan      html  css  js  c++  java
  • 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 FilesCommon FilesMinGWfreeglutinclude"

    gcc -o example.exe example.o -L"C:Program FilesCommon FilesMinGWfreeglutlib" -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.

  • 相关阅读:
    文件修改的两种方式
    人工智能 01. 语音合成,语音识别,相似度,图灵机器人,智能对话
    flask --- 04 . 偏函数, 线程安全,栈堆,
    flask --- 03 .特殊装饰器, CBV , redis ,三方组件
    flask --- 02. 路由, 初始化配置,蓝图
    linux --- 10.常见命令
    flask --- 01 .初始
    linux --- 9. docker 容器 和 rabbitmq 队列
    linux --- 8. mysql数据库,redis 数据库
    linux --- 7. 路飞学城部署
  • 原文地址:https://www.cnblogs.com/nlsoft/p/8974174.html
Copyright © 2011-2022 走看看