24.c++-lib文件简述

本文介绍了如何使用LIB文件链接其他LIB文件,并解释了这种链接机制的实际工作原理。文章还讲解了如何利用lib.exe工具将多个LIB文件整合成一个,以便更方便地进行项目管理。

1.LIB可以链接其他LIB,比如:

lib2依赖于lib1,libTest.exe依赖于lib2,这样肯定是OK的

但也算不上真实的链接,它没有链接选项,只能通过

#pragma comment(lib,"F:\\LiBTest\\Debug\\Lib1.lib")
这种类似方式去链接,所以实际链接的是调用它的exe程序,也就是lib1,lib2必须都存在


2.lib文件其实就是obj文件的打包而已,比如你链接一个静态库,如果其中有错,它会准确的找到是哪个obj有错,即静态lib只是壳子,  所以使用lib.exe可以组合它们:比如下面就是直接把lib1和lib2组合成liball

如果lib1和lib2为各自独立的模块,那么我们可以直接使用liball.lib即可,包含lib1和lib2的头文件

上面代码中的lib.exe来自于\Microsoft Visual Studio 9.0\VC\bin目录下,另需要把link.exe也拷过来

Collecting pycuda Using cached pycuda-2025.1.1.tar.gz (1.7 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting pytools>=2011.2 (from pycuda) Using cached pytools-2025.2.2-py3-none-any.whl.metadata (2.9 kB) Requirement already satisfied: platformdirs>=2.2.0 in d:\programdata\anaconda3\envs\gprmax\lib\site-packages (from pycuda) (4.3.7) Collecting mako (from pycuda) Using cached mako-1.3.10-py3-none-any.whl.metadata (2.9 kB) Collecting siphash24>=1.6 (from pytools>=2011.2->pycuda) Using cached siphash24-1.7.tar.gz (19 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [12 lines of output] + meson setup C:\Users\vbh\AppData\Local\Temp\pip-install-te4kac5b\siphash24_966747fbced8481995d9b721bf8e6e91 C:\Users\vbh\AppData\Local\Temp\pip-install-te4kac5b\siphash24_966747fbced8481995d9b721bf8e6e91\.mesonpy-npmhf9wz -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\vbh\AppData\Local\Temp\pip-install-te4kac5b\siphash24_966747fbced8481995d9b721bf8e6e91\.mesonpy-npmhf9wz\meson-python-native-file.ini The Meson build system Version: 1.8.2 Source dir: C:\Users\vbh\AppData\Local\Temp\pip-install-te4kac5b\siphash24_966747fbced8481995d9b721bf8e6e91 Build dir: C:\Users\vbh\AppData\Local\Temp\pip-install-te4kac5b\siphash24_966747fbced8481995d9b721bf8e6e91\.mesonpy-npmhf9wz Build type: native build Project name: python-siphash24 Project version: undefined ..\meson.build:4:0: ERROR: Compiler cl cannot compile programs. A full log can be found at C:\Users\vbh\AppData\Local\Temp\pip-install-te4kac5b\siphash24_966747fbced8481995d9b721bf8e6e91\.mesonpy-npmhf9wz\meson-logs\meson-log.txt [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
07-26
c:/users/lenovo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Lenovo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2/tools/sdk/esp32/lib\libfreertos.a(port_common.c.obj):(.literal.main_task+0x10): undefined reference to `app_main' c:/users/lenovo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Lenovo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2/tools/sdk/esp32/lib\libfreertos.a(port_common.c.obj): in function `main_task': /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port/port_common.c:118: undefined reference to `app_main' c:/users/lenovo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Lenovo\AppData\Local\arduino\cores\8f29e38a3034b8e6fd526d2722594d3b\core.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial9availableEv+0x0): undefined reference to `uartAvailable' c:/users/lenovo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Lenovo\AppData\Local\arduino\cores\8f29e38a3034b8e6fd526d2722594d3b\core.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial17availableForWriteEv+0x0): undefined reference to `uartAvailableForWrite' c:/users/lenovo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Lenovo\AppData\Local\arduino\cores\8f29e38a3034b8e6fd526d2722594d3b\core.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial4peekEv+0x0): undefined reference to `uartPeek' c:/users
06-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值