Cannot include a static library in the project - visual-studio-2005

I am developing a subproject in a solution in MS Visual Studio 2005. The subproject is a Windows CE 6.0 service (as DLL) and it is included in the Windows CE 6.0 OS Project. In the subproject I need to use some functions from "ceosutil.lib" (svsutil.hxx is the header), but I cannot link it to my subproject. When building, I get the following type of errors: "error LNK2019: unresolved external symbol".
What is interesting, when I switch the project type to a static library, it compiles without problems. If I start a new DLL project (standalone one, not as subproject), it also works (the "ceosutil.lib" is already listed in the Additional Dependencies of the project and all configurations).
Please help!

I have found the answer to my own question. The solution is to add the name of the library ("ceosutil.lib", after a space) to Additional Libraries field in the Link tab of the subproject properties:
In MS Visual Studio 2005:
Right Mouse Click on subproject name -> Properties -> Link tab -> Additional Libraries.
default value was: $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib
new value: $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib ceosutil.lib
Update:
It is even easier to open the subproject (right mouse btn -> open) and paste the path to the library in the TARGETLIBS section. The result will be exactly the same:
TARGETLIBS= \
$(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib \

Related

Include c++ project in another c++ project from different solution in Visual Studio 2015

I have 2 c++ projects in different solutions. When I built the project B solution's it generated a .dll, .exp, .exe, and .lib files.
How I have to reference the project B in the project A?. I've tried rigth click -> add -> reference -> B.dll.
But it shows me a window error with the following message:
could not add a reference to B.dll for one of the following reasons:
Targets a higher version of the .NET Framework
Not a .NET assembly
Not a registered ActiveX control
I've never worked with visual studio,I'm a little bit lost
Thank you and sorry for my english

How to link a static library in Visual C++ 2017?

Trying to set up libtins on windows. Im relatively new to Visual studio and most of the documentation on the matter was for older versions. I was able to get the include files set up with the project but linking the .lib's was problematic and i cant seem to configure it properly. The properties menu seems pretty convoluted as im used to doing most things compiler related configurations from a command line.
In the Solution Explorer, right click on the project, select Properties. Expand to Configuration Properties > Linker > Input. Add the .lib file to Additional Dependencies. Do this for both the Release and Debug configuration.
If the static library in question is in fact the output of another visual studio project, you can just add that project to your solution file, and then add a reference to that project, and let VS2017 figure out where the lib files are located, and that the linker needs them.
i.e.
Solution '...' (2 projects)
Lib Consuming Project
References(Lib Producing Project)
Lib Producing Project
hint for creating static libraries from visual studio
for Lib Producing Project, go to Properties
Properties->Configuration Properties->General
and set Configuration Type to static lib (for both debug and release)
for foreign static libs, the accepted answer is AFAIK the proper way to do it.

Framework and References

I used to use the VS2010. And there exists an option:
"Project "X" -> Properties -> Common Properties -> Framework and References"
And then I can add a bunch of references and set a few properties:
"Build Prop.. Project Reference.. etc"
In VS2015 I can't find this "properties path" or the properties in them. I also have googled and found nothing. It happens that I need to change some of that properties. Any suggestion?
Project description:
addon (principal); DLL to run nodejs addon (c++ with node.h and v8.h) (dependes on all)
g2pproj - static lib to convert phonemes and graphemes (c++)
libjulius - static lib with julius speech recognizer options (c) (dependes on libsent)
libsent - static lib with low level features (C)
Another libs:
ws2_32.lib - win sockets
portaudio.lib - link
The error is in portaudio (only one):
error LNK2001: unresolved external symbol __snwprintf
I already link and add all the additional dependencies.
In VS2010 I can compile this project without problems, and not in 2015. I want to use 2015, because is new and has the thread features

How do I add a lib file to link in Visual C++ 2010?

I've found the Additional Dependencies thing on Visual C++ 2010, but I can't seem to find any option of adding new .lib files when I go to .
I need to add wsock32.lib to link with my file, how do I make it happen?
Thanks!
Add the wsock32.lib in the text field.
Project Properties -> Linker -> Input -> Additional Dependencies.
When you click in the field, you get a ... button. Click on this button and add one library name per line. Alternatively you can write the names in the field. Separate all entries with space characters.
You can verify that it's on the command line in
Project Properties -> Linker -> Command Line.
Here is a GUI way to add a LIB file to your Visual Studio project in C and C++ Languages (for those of us who like to mouse-around like me). I did this in Visual Studio 2012. But I think it works in previous versions, as well.
Find the LIB or other file you want to add to your project in
Windows Explorer. Drag the LIB file from Windows Explorer onto
Visual Studio's Solution Explorer, to the project to which you wish
to add the LIB file. Now, you will see the file listed in Solution Explorer.
That's it! Just one step! You will not see the file in "Project Properties -> Linker -> Input -> Additional Dependencies." However, it is there hidden in the macro
%(AdditionalDependencies).
edit Additional Dependencies and puts wsock32.lib in it.
and also add the path of lib in Link->general-> additional library directories

How to debug external class library projects in visual studio?

I have a project(A) that references an assembly from an external project(B) class library that is located in another vs solution.
I have yet to understand how i can efficiently debug the class library from B while running the program from project A. Is there something I have to enable on project B such as debug info etc so I can step-into at debug time from A?
Try disabling Just My Code (JMC).
Tools > Options > Debugging
Uncheck "Enable Just My Code"
By default the debugger tries to restrict the view of the world to code that is only contained within your solution. This is really heplful at times but when you want to debug code which is not in your solution (as is your situation) you need to disable JMC in order to see it. Otherwise the code will be treated as external and largely hidden from your view.
EDIT
When you're broken in your code try the following.
Debug > Windows > Modules
Find the DLL for the project you are interested in
Right Click > Load Symbols > Select the Path to the .PDB for your other project
Assume the path of
Project A
C:\Projects\ProjectA
Project B
C:\Projects\ProjectB
and the dll of ProjectB is in
C:\Projects\ProjectB\bin\Debug\
To debug into ProjectB from ProjectA, do the following
Copy B's dll with dll's .PDB to the ProjectA's compiling directory.
Now debug ProjectA. When code reaches the part where you need to call dll's method or events etc while debugging, press F11 to step into the dll's code.
NOTE : DO NOT MISS TO COPY THE .PDB FILE
This has bugged me for some time. What I usually end up doing is rebuilding my external library using debug mode, then copy both .dll and the .pdb file to the bin of my website. This allows me to step into the libarary code.
I run two instances of visual studio--one for the external dll and one for the main application.
In the project properties of the external dll, set the following:
Build Events:
copy /y "$(TargetDir)$(TargetName).dll" "C:\<path-to-main> \bin\$(ConfigurationName)\$(TargetName).dll"
copy /y "$(TargetDir)$(TargetName).pdb" "C:\<path-to-main> \bin\$(ConfigurationName)\$(TargetName).pdb"
Debug:
Start external program: C:\<path-to-main>\bin\debug\<AppName>.exe
Working Directory C:\<path-to-main>\bin\debug
This way, whenever I build the external dll, it gets updated in the main application's directory. If I hit debug from the external dll's project--the main application runs, but the debugger only hits breakpoints in the external dll. If I hit debug from the main project, the main application runs with the most recently built external dll, but now the debugger only hits breakpoints in the main project.
I realize one debugger will do the job for both, but I find it easier to keep the two straight this way.
If you have main (project A) and external library (project B):
Open (project A) solution in Visual Studio.
Right click on solution -> Add Existing Project -> then select the .csproj file of your external library (project B).
Again in visual studio right click on (project A) -> Add -> Project Refference... -> and then add checkmark on your external library which you want to debug (project B).
Finally place brake-points in (project A) where your external library (project B) is called and run with F5.
[according to Martin Beckett, the guy who send me this answer ]
You can debug into an external library.
In the project settings tab look for 'visual studio directories' in the 'source code' field include the path to the openCV sources. Then make sure that the .pdb files for each of the debug dll are in the same directory as the dll.
NuGet references
Assume the
-Project_A (produces project_a.dll)
-Project_B (produces project_b.dll)
and Project_B references to Project_A by NuGet packages then
just copy project_a.dll , project_a.pdb to the folder Project_B/Packages.
In effect that should be copied to the /bin.
Now debug Project_A. When code reaches the part where you need to call dll's method or events etc while debugging, press F11 to step into the dll's code.
I was having a similar issue as my breakpoints in project(B) were not being hit. My solution was to rebuild project(B) then debug project(A) as the dlls needed to be updated.
Visual studio should allow you to debug into an external library.
The quickest way to do this on a one-off basis is to open the Proj B file directly in the Visual Studio instance in which you are editing and launching Project A (File => Open => File). You don't need to add the file to the solution. Just having it open in the editor will let you create your breakpoints directly in the Project B file.

Resources