如何将 glfw 构建为共享库?
How to build glfw as a shared library?
我正在尝试将 Linux 上的 glfw 库构建为共享库。我从克隆 git repository. Then, according to this 编译指南开始,我在 repo 中创建了一个名为 glfw-build
的文件夹,并将 cd
放入其中。 Runnnig cmake ..
从那里给出输出
-- The C compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Using X11 for window creation
-- Using GLX for context creation
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/<user>/lib-sources/glfw/glfw-build
运行 make
之后给出
Scanning dependencies of target glfw
[ 1%] Building C object src/CMakeFiles/glfw.dir/context.c.o
[ 2%] Building C object src/CMakeFiles/glfw.dir/init.c.o
[ 4%] Building C object src/CMakeFiles/glfw.dir/input.c.o
[ 5%] Building C object src/CMakeFiles/glfw.dir/monitor.c.o
[ 7%] Building C object src/CMakeFiles/glfw.dir/window.c.o
[ 8%] Building C object src/CMakeFiles/glfw.dir/x11_init.c.o
[ 9%] Building C object src/CMakeFiles/glfw.dir/x11_monitor.c.o
[ 11%] Building C object src/CMakeFiles/glfw.dir/x11_window.c.o
[ 12%] Building C object src/CMakeFiles/glfw.dir/xkb_unicode.c.o
[ 14%] Building C object src/CMakeFiles/glfw.dir/linux_joystick.c.o
[ 15%] Building C object src/CMakeFiles/glfw.dir/posix_time.c.o
[ 16%] Building C object src/CMakeFiles/glfw.dir/posix_tls.c.o
[ 18%] Building C object src/CMakeFiles/glfw.dir/glx_context.c.o
Linking C static library libglfw3.a
[ 18%] Built target glfw
Scanning dependencies of target boing
[ 19%] Building C object examples/CMakeFiles/boing.dir/boing.c.o
[ 21%] Building C object examples/CMakeFiles/boing.dir/__/deps/glad.c.o
Linking C executable boing
[ 21%] Built target boing
Scanning dependencies of target gears
[ 22%] Building C object examples/CMakeFiles/gears.dir/gears.c.o
[ 23%] Building C object examples/CMakeFiles/gears.dir/__/deps/glad.c.o
Linking C executable gears
[ 23%] Built target gears
Scanning dependencies of target heightmap
[ 25%] Building C object examples/CMakeFiles/heightmap.dir/heightmap.c.o
[ 26%] Building C object examples/CMakeFiles/heightmap.dir/__/deps/glad.c.o
Linking C executable heightmap
[ 26%] Built target heightmap
Scanning dependencies of target particles
[ 28%] Building C object examples/CMakeFiles/particles.dir/particles.c.o
[ 29%] Building C object examples/CMakeFiles/particles.dir/__/deps/tinycthread.c.o
[ 30%] Building C object examples/CMakeFiles/particles.dir/__/deps/getopt.c.o
[ 32%] Building C object examples/CMakeFiles/particles.dir/__/deps/glad.c.o
Linking C executable particles
[ 32%] Built target particles
Scanning dependencies of target simple
[ 33%] Building C object examples/CMakeFiles/simple.dir/simple.c.o
[ 35%] Building C object examples/CMakeFiles/simple.dir/__/deps/glad.c.o
Linking C executable simple
[ 35%] Built target simple
Scanning dependencies of target splitview
[ 36%] Building C object examples/CMakeFiles/splitview.dir/splitview.c.o
[ 38%] Building C object examples/CMakeFiles/splitview.dir/__/deps/glad.c.o
Linking C executable splitview
[ 38%] Built target splitview
Scanning dependencies of target wave
[ 39%] Building C object examples/CMakeFiles/wave.dir/wave.c.o
[ 40%] Building C object examples/CMakeFiles/wave.dir/__/deps/glad.c.o
Linking C executable wave
[ 40%] Built target wave
Scanning dependencies of target clipboard
[ 42%] Building C object tests/CMakeFiles/clipboard.dir/clipboard.c.o
[ 43%] Building C object tests/CMakeFiles/clipboard.dir/__/deps/getopt.c.o
[ 45%] Building C object tests/CMakeFiles/clipboard.dir/__/deps/glad.c.o
Linking C executable clipboard
[ 45%] Built target clipboard
Scanning dependencies of target cursor
[ 46%] Building C object tests/CMakeFiles/cursor.dir/cursor.c.o
[ 47%] Building C object tests/CMakeFiles/cursor.dir/__/deps/glad.c.o
Linking C executable cursor
[ 47%] Built target cursor
Scanning dependencies of target empty
[ 49%] Building C object tests/CMakeFiles/empty.dir/empty.c.o
[ 50%] Building C object tests/CMakeFiles/empty.dir/__/deps/tinycthread.c.o
[ 52%] Building C object tests/CMakeFiles/empty.dir/__/deps/glad.c.o
Linking C executable empty
[ 52%] Built target empty
Scanning dependencies of target events
[ 53%] Building C object tests/CMakeFiles/events.dir/events.c.o
[ 54%] Building C object tests/CMakeFiles/events.dir/__/deps/getopt.c.o
[ 56%] Building C object tests/CMakeFiles/events.dir/__/deps/glad.c.o
Linking C executable events
[ 56%] Built target events
Scanning dependencies of target gamma
[ 57%] Building C object tests/CMakeFiles/gamma.dir/gamma.c.o
[ 59%] Building C object tests/CMakeFiles/gamma.dir/__/deps/getopt.c.o
[ 60%] Building C object tests/CMakeFiles/gamma.dir/__/deps/glad.c.o
Linking C executable gamma
[ 60%] Built target gamma
Scanning dependencies of target glfwinfo
[ 61%] Building C object tests/CMakeFiles/glfwinfo.dir/glfwinfo.c.o
[ 63%] Building C object tests/CMakeFiles/glfwinfo.dir/__/deps/getopt.c.o
[ 64%] Building C object tests/CMakeFiles/glfwinfo.dir/__/deps/glad.c.o
Linking C executable glfwinfo
[ 64%] Built target glfwinfo
Scanning dependencies of target iconify
[ 66%] Building C object tests/CMakeFiles/iconify.dir/iconify.c.o
[ 67%] Building C object tests/CMakeFiles/iconify.dir/__/deps/getopt.c.o
[ 69%] Building C object tests/CMakeFiles/iconify.dir/__/deps/glad.c.o
Linking C executable iconify
[ 69%] Built target iconify
Scanning dependencies of target joysticks
[ 70%] Building C object tests/CMakeFiles/joysticks.dir/joysticks.c.o
[ 71%] Building C object tests/CMakeFiles/joysticks.dir/__/deps/glad.c.o
Linking C executable joysticks
[ 71%] Built target joysticks
Scanning dependencies of target monitors
[ 73%] Building C object tests/CMakeFiles/monitors.dir/monitors.c.o
[ 74%] Building C object tests/CMakeFiles/monitors.dir/__/deps/getopt.c.o
[ 76%] Building C object tests/CMakeFiles/monitors.dir/__/deps/glad.c.o
Linking C executable monitors
[ 76%] Built target monitors
Scanning dependencies of target msaa
[ 77%] Building C object tests/CMakeFiles/msaa.dir/msaa.c.o
[ 78%] Building C object tests/CMakeFiles/msaa.dir/__/deps/getopt.c.o
[ 80%] Building C object tests/CMakeFiles/msaa.dir/__/deps/glad.c.o
Linking C executable msaa
[ 80%] Built target msaa
Scanning dependencies of target reopen
[ 81%] Building C object tests/CMakeFiles/reopen.dir/reopen.c.o
[ 83%] Building C object tests/CMakeFiles/reopen.dir/__/deps/glad.c.o
Linking C executable reopen
[ 83%] Built target reopen
Scanning dependencies of target sharing
[ 84%] Building C object tests/CMakeFiles/sharing.dir/sharing.c.o
[ 85%] Building C object tests/CMakeFiles/sharing.dir/__/deps/glad.c.o
Linking C executable sharing
[ 85%] Built target sharing
Scanning dependencies of target tearing
[ 87%] Building C object tests/CMakeFiles/tearing.dir/tearing.c.o
[ 88%] Building C object tests/CMakeFiles/tearing.dir/__/deps/getopt.c.o
[ 90%] Building C object tests/CMakeFiles/tearing.dir/__/deps/glad.c.o
Linking C executable tearing
[ 90%] Built target tearing
Scanning dependencies of target threads
[ 91%] Building C object tests/CMakeFiles/threads.dir/threads.c.o
[ 92%] Building C object tests/CMakeFiles/threads.dir/__/deps/tinycthread.c.o
[ 94%] Building C object tests/CMakeFiles/threads.dir/__/deps/glad.c.o
Linking C executable threads
[ 94%] Built target threads
Scanning dependencies of target title
[ 95%] Building C object tests/CMakeFiles/title.dir/title.c.o
[ 97%] Building C object tests/CMakeFiles/title.dir/__/deps/glad.c.o
Linking C executable title
[ 97%] Built target title
Scanning dependencies of target windows
[ 98%] Building C object tests/CMakeFiles/windows.dir/windows.c.o
[100%] Building C object tests/CMakeFiles/windows.dir/__/deps/glad.c.o
Linking C executable windows
[100%] Built target windows
和运行 sudo make install
之后直接给出
[ 18%] Built target glfw
[ 21%] Built target boing
[ 23%] Built target gears
[ 26%] Built target heightmap
[ 32%] Built target particles
[ 35%] Built target simple
[ 38%] Built target splitview
[ 40%] Built target wave
[ 45%] Built target clipboard
[ 47%] Built target cursor
[ 52%] Built target empty
[ 56%] Built target events
[ 60%] Built target gamma
[ 64%] Built target glfwinfo
[ 69%] Built target iconify
[ 71%] Built target joysticks
[ 76%] Built target monitors
[ 80%] Built target msaa
[ 83%] Built target reopen
[ 85%] Built target sharing
[ 90%] Built target tearing
[ 94%] Built target threads
[ 97%] Built target title
[100%] Built target windows
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include/GLFW
-- Installing: /usr/local/include/GLFW/glfw3.h
-- Installing: /usr/local/include/GLFW/glfw3native.h
-- Installing: /usr/local/lib/cmake/glfw/glfw3Config.cmake
-- Installing: /usr/local/lib/cmake/glfw/glfw3ConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/glfw/glfwTargets.cmake
-- Installing: /usr/local/lib/cmake/glfw/glfwTargets-noconfig.cmake
-- Installing: /usr/local/lib/pkgconfig/glfw3.pc
-- Installing: /usr/local/lib/libglfw3.a
我似乎得到的只是一个 a 文件,即静态库,但如前所述,我需要一个共享库,即 so 文件。
为什么我没有得到so文件;这不应该是默认的吗?我怎样才能得到它?
一些项目(其中 glfw3
)隐含地允许用户通过 BUILD_SHARED_LIBS 变量影响他们生成的库类型:
If present and true, this will cause all libraries to be built shared unless the library was explicitly added as a static library. This variable is often added to projects as an OPTION so that each user of a project can decide if they want to build the project using shared or static libraries.
配置
cmake -DBUILD_SHARED_LIBS=ON ..
告诉项目生成共享库。
注意,如果您希望两种类型的库都存在于您的系统中,您需要为它们分配不同的安装前缀(CMAKE_INSTALL_PREFIX
变量)。
并非所有项目都允许进行此类调整。一些项目 select 自己构建类型。其他一些人为此目的使用另一个变量。只需阅读项目的自述文件或检查其代码。
我正在尝试将 Linux 上的 glfw 库构建为共享库。我从克隆 git repository. Then, according to this 编译指南开始,我在 repo 中创建了一个名为 glfw-build
的文件夹,并将 cd
放入其中。 Runnnig cmake ..
从那里给出输出
-- The C compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Using X11 for window creation
-- Using GLX for context creation
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/<user>/lib-sources/glfw/glfw-build
运行 make
之后给出
Scanning dependencies of target glfw
[ 1%] Building C object src/CMakeFiles/glfw.dir/context.c.o
[ 2%] Building C object src/CMakeFiles/glfw.dir/init.c.o
[ 4%] Building C object src/CMakeFiles/glfw.dir/input.c.o
[ 5%] Building C object src/CMakeFiles/glfw.dir/monitor.c.o
[ 7%] Building C object src/CMakeFiles/glfw.dir/window.c.o
[ 8%] Building C object src/CMakeFiles/glfw.dir/x11_init.c.o
[ 9%] Building C object src/CMakeFiles/glfw.dir/x11_monitor.c.o
[ 11%] Building C object src/CMakeFiles/glfw.dir/x11_window.c.o
[ 12%] Building C object src/CMakeFiles/glfw.dir/xkb_unicode.c.o
[ 14%] Building C object src/CMakeFiles/glfw.dir/linux_joystick.c.o
[ 15%] Building C object src/CMakeFiles/glfw.dir/posix_time.c.o
[ 16%] Building C object src/CMakeFiles/glfw.dir/posix_tls.c.o
[ 18%] Building C object src/CMakeFiles/glfw.dir/glx_context.c.o
Linking C static library libglfw3.a
[ 18%] Built target glfw
Scanning dependencies of target boing
[ 19%] Building C object examples/CMakeFiles/boing.dir/boing.c.o
[ 21%] Building C object examples/CMakeFiles/boing.dir/__/deps/glad.c.o
Linking C executable boing
[ 21%] Built target boing
Scanning dependencies of target gears
[ 22%] Building C object examples/CMakeFiles/gears.dir/gears.c.o
[ 23%] Building C object examples/CMakeFiles/gears.dir/__/deps/glad.c.o
Linking C executable gears
[ 23%] Built target gears
Scanning dependencies of target heightmap
[ 25%] Building C object examples/CMakeFiles/heightmap.dir/heightmap.c.o
[ 26%] Building C object examples/CMakeFiles/heightmap.dir/__/deps/glad.c.o
Linking C executable heightmap
[ 26%] Built target heightmap
Scanning dependencies of target particles
[ 28%] Building C object examples/CMakeFiles/particles.dir/particles.c.o
[ 29%] Building C object examples/CMakeFiles/particles.dir/__/deps/tinycthread.c.o
[ 30%] Building C object examples/CMakeFiles/particles.dir/__/deps/getopt.c.o
[ 32%] Building C object examples/CMakeFiles/particles.dir/__/deps/glad.c.o
Linking C executable particles
[ 32%] Built target particles
Scanning dependencies of target simple
[ 33%] Building C object examples/CMakeFiles/simple.dir/simple.c.o
[ 35%] Building C object examples/CMakeFiles/simple.dir/__/deps/glad.c.o
Linking C executable simple
[ 35%] Built target simple
Scanning dependencies of target splitview
[ 36%] Building C object examples/CMakeFiles/splitview.dir/splitview.c.o
[ 38%] Building C object examples/CMakeFiles/splitview.dir/__/deps/glad.c.o
Linking C executable splitview
[ 38%] Built target splitview
Scanning dependencies of target wave
[ 39%] Building C object examples/CMakeFiles/wave.dir/wave.c.o
[ 40%] Building C object examples/CMakeFiles/wave.dir/__/deps/glad.c.o
Linking C executable wave
[ 40%] Built target wave
Scanning dependencies of target clipboard
[ 42%] Building C object tests/CMakeFiles/clipboard.dir/clipboard.c.o
[ 43%] Building C object tests/CMakeFiles/clipboard.dir/__/deps/getopt.c.o
[ 45%] Building C object tests/CMakeFiles/clipboard.dir/__/deps/glad.c.o
Linking C executable clipboard
[ 45%] Built target clipboard
Scanning dependencies of target cursor
[ 46%] Building C object tests/CMakeFiles/cursor.dir/cursor.c.o
[ 47%] Building C object tests/CMakeFiles/cursor.dir/__/deps/glad.c.o
Linking C executable cursor
[ 47%] Built target cursor
Scanning dependencies of target empty
[ 49%] Building C object tests/CMakeFiles/empty.dir/empty.c.o
[ 50%] Building C object tests/CMakeFiles/empty.dir/__/deps/tinycthread.c.o
[ 52%] Building C object tests/CMakeFiles/empty.dir/__/deps/glad.c.o
Linking C executable empty
[ 52%] Built target empty
Scanning dependencies of target events
[ 53%] Building C object tests/CMakeFiles/events.dir/events.c.o
[ 54%] Building C object tests/CMakeFiles/events.dir/__/deps/getopt.c.o
[ 56%] Building C object tests/CMakeFiles/events.dir/__/deps/glad.c.o
Linking C executable events
[ 56%] Built target events
Scanning dependencies of target gamma
[ 57%] Building C object tests/CMakeFiles/gamma.dir/gamma.c.o
[ 59%] Building C object tests/CMakeFiles/gamma.dir/__/deps/getopt.c.o
[ 60%] Building C object tests/CMakeFiles/gamma.dir/__/deps/glad.c.o
Linking C executable gamma
[ 60%] Built target gamma
Scanning dependencies of target glfwinfo
[ 61%] Building C object tests/CMakeFiles/glfwinfo.dir/glfwinfo.c.o
[ 63%] Building C object tests/CMakeFiles/glfwinfo.dir/__/deps/getopt.c.o
[ 64%] Building C object tests/CMakeFiles/glfwinfo.dir/__/deps/glad.c.o
Linking C executable glfwinfo
[ 64%] Built target glfwinfo
Scanning dependencies of target iconify
[ 66%] Building C object tests/CMakeFiles/iconify.dir/iconify.c.o
[ 67%] Building C object tests/CMakeFiles/iconify.dir/__/deps/getopt.c.o
[ 69%] Building C object tests/CMakeFiles/iconify.dir/__/deps/glad.c.o
Linking C executable iconify
[ 69%] Built target iconify
Scanning dependencies of target joysticks
[ 70%] Building C object tests/CMakeFiles/joysticks.dir/joysticks.c.o
[ 71%] Building C object tests/CMakeFiles/joysticks.dir/__/deps/glad.c.o
Linking C executable joysticks
[ 71%] Built target joysticks
Scanning dependencies of target monitors
[ 73%] Building C object tests/CMakeFiles/monitors.dir/monitors.c.o
[ 74%] Building C object tests/CMakeFiles/monitors.dir/__/deps/getopt.c.o
[ 76%] Building C object tests/CMakeFiles/monitors.dir/__/deps/glad.c.o
Linking C executable monitors
[ 76%] Built target monitors
Scanning dependencies of target msaa
[ 77%] Building C object tests/CMakeFiles/msaa.dir/msaa.c.o
[ 78%] Building C object tests/CMakeFiles/msaa.dir/__/deps/getopt.c.o
[ 80%] Building C object tests/CMakeFiles/msaa.dir/__/deps/glad.c.o
Linking C executable msaa
[ 80%] Built target msaa
Scanning dependencies of target reopen
[ 81%] Building C object tests/CMakeFiles/reopen.dir/reopen.c.o
[ 83%] Building C object tests/CMakeFiles/reopen.dir/__/deps/glad.c.o
Linking C executable reopen
[ 83%] Built target reopen
Scanning dependencies of target sharing
[ 84%] Building C object tests/CMakeFiles/sharing.dir/sharing.c.o
[ 85%] Building C object tests/CMakeFiles/sharing.dir/__/deps/glad.c.o
Linking C executable sharing
[ 85%] Built target sharing
Scanning dependencies of target tearing
[ 87%] Building C object tests/CMakeFiles/tearing.dir/tearing.c.o
[ 88%] Building C object tests/CMakeFiles/tearing.dir/__/deps/getopt.c.o
[ 90%] Building C object tests/CMakeFiles/tearing.dir/__/deps/glad.c.o
Linking C executable tearing
[ 90%] Built target tearing
Scanning dependencies of target threads
[ 91%] Building C object tests/CMakeFiles/threads.dir/threads.c.o
[ 92%] Building C object tests/CMakeFiles/threads.dir/__/deps/tinycthread.c.o
[ 94%] Building C object tests/CMakeFiles/threads.dir/__/deps/glad.c.o
Linking C executable threads
[ 94%] Built target threads
Scanning dependencies of target title
[ 95%] Building C object tests/CMakeFiles/title.dir/title.c.o
[ 97%] Building C object tests/CMakeFiles/title.dir/__/deps/glad.c.o
Linking C executable title
[ 97%] Built target title
Scanning dependencies of target windows
[ 98%] Building C object tests/CMakeFiles/windows.dir/windows.c.o
[100%] Building C object tests/CMakeFiles/windows.dir/__/deps/glad.c.o
Linking C executable windows
[100%] Built target windows
和运行 sudo make install
之后直接给出
[ 18%] Built target glfw
[ 21%] Built target boing
[ 23%] Built target gears
[ 26%] Built target heightmap
[ 32%] Built target particles
[ 35%] Built target simple
[ 38%] Built target splitview
[ 40%] Built target wave
[ 45%] Built target clipboard
[ 47%] Built target cursor
[ 52%] Built target empty
[ 56%] Built target events
[ 60%] Built target gamma
[ 64%] Built target glfwinfo
[ 69%] Built target iconify
[ 71%] Built target joysticks
[ 76%] Built target monitors
[ 80%] Built target msaa
[ 83%] Built target reopen
[ 85%] Built target sharing
[ 90%] Built target tearing
[ 94%] Built target threads
[ 97%] Built target title
[100%] Built target windows
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include/GLFW
-- Installing: /usr/local/include/GLFW/glfw3.h
-- Installing: /usr/local/include/GLFW/glfw3native.h
-- Installing: /usr/local/lib/cmake/glfw/glfw3Config.cmake
-- Installing: /usr/local/lib/cmake/glfw/glfw3ConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/glfw/glfwTargets.cmake
-- Installing: /usr/local/lib/cmake/glfw/glfwTargets-noconfig.cmake
-- Installing: /usr/local/lib/pkgconfig/glfw3.pc
-- Installing: /usr/local/lib/libglfw3.a
我似乎得到的只是一个 a 文件,即静态库,但如前所述,我需要一个共享库,即 so 文件。
为什么我没有得到so文件;这不应该是默认的吗?我怎样才能得到它?
一些项目(其中 glfw3
)隐含地允许用户通过 BUILD_SHARED_LIBS 变量影响他们生成的库类型:
If present and true, this will cause all libraries to be built shared unless the library was explicitly added as a static library. This variable is often added to projects as an OPTION so that each user of a project can decide if they want to build the project using shared or static libraries.
配置
cmake -DBUILD_SHARED_LIBS=ON ..
告诉项目生成共享库。
注意,如果您希望两种类型的库都存在于您的系统中,您需要为它们分配不同的安装前缀(CMAKE_INSTALL_PREFIX
变量)。
并非所有项目都允许进行此类调整。一些项目 select 自己构建类型。其他一些人为此目的使用另一个变量。只需阅读项目的自述文件或检查其代码。