I have created two programs in Visual Studio2010.
One is a visual basic windows forms application(user frontend) which prompts the user to select a file path (.bin file). The second program is a Visual Studio C++ Application, which has a ReadFile() function, which reads the contents of the binary file and performs some mathematical calculations.
I want to generate a static library(.lib) from the second program and link it with the first program (user frontend). The user frontend program must be able to pass the file path to the ReadFile() function in the static library.
I have created both the programs separately, but finding it difficult to create the static library and link it with the user frontend. How do i go about this ??
P.S: This may sound as stupid, but my aim is to learn how to create and link a static library to windows forms application.
The user front end application which prompts the user to select the file.
Do the following steps To create a static library project:
- 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.
To create a C++ console app that references the static library
- 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.
Source: https://msdn.microsoft.com/en-us/library/ms235627.aspx
You can see additional info in the link above, how to use the code in your project.
Update following question in comment:
Right click on your project in the solution explorer and then click on Properties.
Next open Configuration Properties and then Linker.
Now you want to add the folder you have the Allegro libraries in to Additional Library Directories,
Linker -> Input you'll add the actual library files under Additional Dependencies.
For the Header Files you'll also want to include their directories under C/C++ -> Additional Include Directories.
Have a copy of your lib file in your main project folder, and done
I hope it supports your question.