Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I transfer a library from one Visual Studio C++ project to another? Is it possible?

Posted on 2011-05-11
2
Medium Priority
?
438 Views
Last Modified: 2012-05-11
I copied a folder from another project containing all the libraries I needed over to a new project folder but what do I do next?
0
Comment
Question by:Eindoofus
  • 2
2 Comments
 

Accepted Solution

by:
Eindoofus earned 0 total points
ID: 35743483
Found this on stackoverflow.com posted by giooo:

Here is the solution: http://melbsdailydigest.blogspot.com/

1.) Download one of the latest projects from the Stanford CS106B Website:

http://www.stanford.edu/class/cs106b/spring/assignments/assn-0-narcissism-pc.zip

2.) Unzip the project and find its subdirectory \CS106. This is the folder that contains all the library (CS106CPPLib.lib) and header files for the CS106 program.

3.) Copy this folder as a subdirectory to one of your assignment folders (ex. C:\Assignment1\CS106.

4.) Startup Visual Studio2008 and click File->New->Project… When given the choice choose to create a new Console program.

5.) You’ll then be presented with a new project with multiple files including stdafx.h, stdafx.cpp and similarly named files for whatever you named your project when prompted earlier. DELETE/ REMOVE all these files from the project.

6.) Right click the Source File Folder and choose Add->Existing Item… Choose the first assignment file (Assign1warmup.cpp).

7.) If you compile at this point you’ll realize that it’s still looking for the stdafx.h precompiled header. Let’s fix that. Go to Project->Assignment1 Properties… (or whatever your project might be named). Go to the option in the “tree” menu for Configuration Properties->C/C++->Pre-Compiled Headers . Under the option for Create/Use Precompiled header, choose the drop down option for Not Using Precompiled headers.

8.) While you’re in this section, take the time now to also select the location for the header files for this project. Under the Configuration Properties->C/C++->General section choose the Additional Include Directories option and use the … to browse and select the CS106 folder that you copied to your project folder earlier.

9.) One last thing you should change here is in the Configuration Properties->C/C++->Code Generation section. Change the default (which I believe is for a Multi-Threaded Debug .DLL) to just Multi-Threaded Debug (or just Multi-Threaded if you are doing your release build).

10.) Lastly, we’ll need to let the linker know where to find the CS106 library file. To do that you’ll need to make 2 additional settings. One is in the Configuration Properties->Linker->General section where you can select the location of your additional library files in the section titled appropriately enough – “Additional Library Directories”. You’ll also need to add your library to the project through the “Additional Dependencies” section which is under Configuration Properties->Linker->Input. Just type in CS106CPPLIB.lib.

Note: I found that there seems to be some difference in the menus you get and the settings that get saved depending on what your selection is at the moment in the solution Explorer Window. I originally made all my changes while I was selecting the actual source file, but there were no linker menus at that point. I had to move up to the Source File Folder level to get additional menus where I could set my linker options. Also important to note is that if you make your settings at the lower level (ie. Cpp file) they seem to supersede whatever is set in the level above it.

At this point the project should correctly build with the selection of the Build->Rebuild Solution command. Happy programming!
0
 

Author Closing Comment

by:Eindoofus
ID: 35743488
No one replied and I found the solution which I would also like to keep a record of in my knowledgebase.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Screencast - Getting to Know the Pipeline

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question