创建静态库并将其链接到 Visual Basic windows 表单应用程序
Creating and linking a static library to visual basic windows forms application
我在 Visual Studio2010 年创建了两个程序。
一个是 visual basic windows 表单应用程序(用户前端),它提示用户 select 文件路径(.bin 文件)。
第二个程序是一个 Visual Studio C++ 应用程序,它有一个 ReadFile() 函数,它读取二进制文件的内容并执行一些数学计算。
我想从第二个程序生成一个静态库 (.lib),然后 link 它与第一个程序(用户前端)一起生成。
用户前端程序必须能够将文件路径传递给静态库中的 ReadFile() 函数。
我已经分别创建了这两个程序,但发现很难创建静态库和 link 用户前端。
我该怎么办??
P.S:这听起来可能很愚蠢,但我的目标是学习如何创建和link静态库以windows形成应用程序。
The user front end application which prompts the user to select the file.
执行以下步骤创建静态库项目:
- On the menu bar, choose File, New, Project.
- In the left pane of the New Project dialog box, expand Installed,
Templates, Visual C++, and then select Win32.
- In the center pane, select Win32 Console Application.
- Specify a name for the project—for example, MathFuncsLib—in the Name
box. Specify a name for the solution—for example, StaticLibrary—in
the Solution Name box. Choose the OK button.
- On the Overview page of the Win32 Application Wizard dialog box,
choose the Next button.
- On the Application Settings page, under Application type, select
Static library.
- On the Application Settings page, under Additional options, clear
the Precompiled header check box.
- Choose the Finish button to create the project.
创建引用静态库的 C++ 控制台应用程序
- On the menu bar, choose File, New, Project.
- In the left pane, under Visual C++, select Win32.
- In the center pane, select Win32 Console Application.
- Specify a name for the project—for example, MyExecRefsLib—in the
Name box. In the drop-down list next to Solution, select Add to
Solution. This adds the new project to the solution that contains
the static library. Choose the OK button.
- On the Overview page of the Win32 Application Wizard dialog box,
choose the Next button.
- On the Application Settings page, under Application type, select
Console application.
- On the Application Settings page, under Additional options, clear
the Precompiled header check box.
- Choose the Finish button to create the project.
来源:https://msdn.microsoft.com/en-us/library/ms235627.aspx
您可以在上面的 link 中查看更多信息,了解如何在您的项目中使用代码。
更新评论中的以下问题:
在解决方案资源管理器中右键单击您的项目,然后单击 属性。
接下来打开 Configuration Properties,然后打开 Linker。
现在您想将拥有 Allegro 库的文件夹添加到其他库目录中,
Linker -> Input 您将在 Additional Dependencies.
下添加实际的库文件
对于头文件,您还需要在 C/C++ -> 附加包含目录下包含它们的目录。
在主项目文件夹中复制一份 lib 文件,然后完成
希望它能支持你的问题。
我在 Visual Studio2010 年创建了两个程序。
一个是 visual basic windows 表单应用程序(用户前端),它提示用户 select 文件路径(.bin 文件)。 第二个程序是一个 Visual Studio C++ 应用程序,它有一个 ReadFile() 函数,它读取二进制文件的内容并执行一些数学计算。
我想从第二个程序生成一个静态库 (.lib),然后 link 它与第一个程序(用户前端)一起生成。 用户前端程序必须能够将文件路径传递给静态库中的 ReadFile() 函数。
我已经分别创建了这两个程序,但发现很难创建静态库和 link 用户前端。 我该怎么办??
P.S:这听起来可能很愚蠢,但我的目标是学习如何创建和link静态库以windows形成应用程序。
The user front end application which prompts the user to select the file.
执行以下步骤创建静态库项目:
- On the menu bar, choose File, New, Project.
- In the left pane of the New Project dialog box, expand Installed, Templates, Visual C++, and then select Win32.
- In the center pane, select Win32 Console Application.
- Specify a name for the project—for example, MathFuncsLib—in the Name box. Specify a name for the solution—for example, StaticLibrary—in the Solution Name box. Choose the OK button.
- On the Overview page of the Win32 Application Wizard dialog box, choose the Next button.
- On the Application Settings page, under Application type, select Static library.
- On the Application Settings page, under Additional options, clear the Precompiled header check box.
- Choose the Finish button to create the project.
创建引用静态库的 C++ 控制台应用程序
- On the menu bar, choose File, New, Project.
- In the left pane, under Visual C++, select Win32.
- In the center pane, select Win32 Console Application.
- Specify a name for the project—for example, MyExecRefsLib—in the Name box. In the drop-down list next to Solution, select Add to Solution. This adds the new project to the solution that contains the static library. Choose the OK button.
- On the Overview page of the Win32 Application Wizard dialog box, choose the Next button.
- On the Application Settings page, under Application type, select Console application.
- On the Application Settings page, under Additional options, clear the Precompiled header check box.
- Choose the Finish button to create the project.
来源:https://msdn.microsoft.com/en-us/library/ms235627.aspx
您可以在上面的 link 中查看更多信息,了解如何在您的项目中使用代码。
更新评论中的以下问题:
在解决方案资源管理器中右键单击您的项目,然后单击 属性。
接下来打开 Configuration Properties,然后打开 Linker。
现在您想将拥有 Allegro 库的文件夹添加到其他库目录中,
Linker -> Input 您将在 Additional Dependencies.
下添加实际的库文件对于头文件,您还需要在 C/C++ -> 附加包含目录下包含它们的目录。
在主项目文件夹中复制一份 lib 文件,然后完成
希望它能支持你的问题。