Linker Property Pages

本文详细解析了MSDN链接属性页中几个关键属性的功能:IgnoreImportLibrary用于忽略导入库文件的存在;RegisterOutput针对.dll项目运行regsvr32.exe/s指令;Per-userRedirection允许在不以提升模式运行的情况下进行注册;LinkLibraryDependencies控制是否链接依赖项目的.lib文件;UseLibraryDependencyInputs在大型项目中启用增量链接。此外,提供了如何通过属性页面设置项目属性的方法。


http://msdn.microsoft.com/en-us/library/024awkd1.aspx


This topic discusses the following properties on the General linker property page:

Ignore Import Library

Tells the linker not to try to link any .lib output generated from this build into any dependent project. This allows the project system to handle .dll files that do not produce a .lib file when built. If a project depends on another project that produces a DLL, the project system automatically will link the .lib file produced by that child project. This may not be needed by projects that are producing COM DLLs or resource-only DLLs; these DLLs do not have any meaningful exports. If a DLL has no exports, the linker will not generate a .lib file. If no export .lib file is present on the disk, and the project system tells the linker to link with this (missing) DLL, the link will fail.

Use Ignore Import Library to resolve this problem. When set to Yes, the project system will ignore the presence or absence of that .lib file and cause any project that depends on this project to not link with the nonexistent .lib file.

To programmatically access this property, see IgnoreImportLibrary.

Register Output

Run regsvr32.exe /s $(TargetPath), which is valid only on .dll projects. For .exe projects, this property is ignored. If you want to register an .exe output, set a postbuild event on the configuration to do the custom registration that is always required for registered .exe files.

To programmatically access this property, see RegisterOutput.

Per-user Redirection

Registration in Visual Studio has traditionally been done in HKEY_CLASSES_ROOT (HKCR). With Windows Vista, to access HKCR you must run Visual Studio in elevated mode. Developers do not always want to run in elevated mode but still must work with registration. Per-user redirection allows you to register without having to run in this mode.

Per-user redirection will force any writes to HKCR to be redirected to HKEY_CURRENT_USER (HKCU). If per-user redirection is turned off, it can cause Project Build Error PRJ0050 when the program tries to write to HKCR.

Link Library Dependencies

Gives you the choice of linking in the .lib files that are produced by dependent projects. Typically, you will want to link in the .lib file.

You can also specify a .obj file by providing the file name and relative path, for example ..\..\MyLibProject\MyObjFile.obj. If the source code for the .obj file #includes a precompiled header, for example pch.h, then pch.obj file is located in the same folder as MyObjFile.obj and you must also add pch.obj as an additional dependency.

Use Library Dependency Inputs

In a large project, when a dependent project produces a .lib file, incremental linking is disabled. If there are many dependent projects that produce .lib files, building the application can take a long time. When this property is set to Yes, the project system links in the .obj files for .libs produced by dependent projects, thus enabling incremental linking.

For information about how to access the General linker property page, see How To: Specify Project Properties with Property Pages.

# Instructions to compile on Windows ## Create a new Visual Studio project with the library included Download the latest version of libmodbus source code from Github `https://github.com/stephane/libmodbus` -> Code -> Download ZIP. Once the archive is decompressed, launch a Windows terminal (`cmd`) in `src/win32` directory and run `cscript configure.js`. 1. copy the file `config.h` from `src/win32` to `src`. 2. create a new 'Console App' project under Visual Studio. 3. create a new directory called `libmodbus` inside your VS project (same level as the `.vcxproj` file). 4. copy all `*.c` and `*.h` from libmodbus `src` in the new `libmodbus` folder of your VS project. 5. copy `modbus.rc` in your VS project (same level as the `.vcxproj` file). 6. drag and drop `libmodbus/*.c` files (4) in *Solution Explorer -> Source Files*. 7. drag and drop `libmodbus/*.h` files (8) in *Solution Explorer -> Header Files*. 8. drag and drop `modbus.rc` file in *Solution Explorer -> Resource Files*. 9. check path is `#include "modbus-version.h"` in `modbus.rc`. 10. in the **Property Pages** of the project *Configuration Properties -> C/C++ -> General -> Additional Include Directories*, add `libmodbus` folder. 11. in the **Property Pages** of the project *Configuration Properties -> Resources -> Additional Include Directories*, add `libmodbus` folder. 12. in the **Property Pages** of the project *Configuration Properties -> Linker -> Input*, define `ws2_32.lib`. 13. if required, add `_CRT_SECURE_NO_WARNINGS` to *C/C++ -> Preprocessor -> Preprocessor Definitions*. ## Create a libmodbus DLL This directory contains the project file for Visual Studio to build `modbus.dll` and import library `modbus.lib`. In the Windows terminal, run `cscript configure.js` to generate: - `config.h` - `modbus-version.h` are generated using configure.js. To write... 翻译中文并总结
最新发布
09-02
======================================================================== DYNAMIC LINK LIBRARY : YRMotionControl Project Overview ======================================================================== AppWizard has created this YRMotionControl DLL for you. This file contains a summary of what you will find in each of the files that make up your YRMotionControl application. YRMotionControl.vcxproj This is the main project file for VC++ projects generated using an Application Wizard. It contains information about the version of Visual C++ that generated the file, and information about the platforms, configurations, and project features selected with the Application Wizard. YRMotionControl.vcxproj.filters This is the filters file for VC++ projects generated using an Application Wizard. It contains information about the association between the files in your project and the filters. This association is used in the IDE to show grouping of files with similar extensions under a specific node (for e.g. ".cpp" files are associated with the "Source Files" filter). YRMotionControl.cpp This is the main DLL source file. When created, this DLL does not export any symbols. As a result, it will not produce a .lib file when it is built. If you wish this project to be a project dependency of some other project, you will either need to add code to export some symbols from the DLL so that an export library will be produced, or you can set the Ignore Input Library property to Yes on the General propert page of the Linker folder in the project's Property Pages dialog box. ///////////////////////////////////////////////////////////////////////////// Other standard files: StdAfx.h, StdAfx.cpp These files are used to build a precompiled header (PCH) file named YRMotionControl.pch and a precompiled types file named StdAfx.obj. ///////////////////////////////////////////////////////////////////////////// Other notes: AppWizard uses "TODO:" comments to indicate parts of the source code you should add to or customize. /////////////////////////////////////////////////////////////////////////////
08-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值