2 projects dependency in same solution causes unresolved symbol [duplicate] - c++

I started with learning C++ a few days ago and I would like to get some data to make it more funny. I found a powerful C++ library called Unirest that can help me to get data from many APIs and after practice the basics :)
I don't know how to include libraries into my project. I fond some videos about how to do it so I just created libs folder (like i always do when I'm programming in PHP) and I copied library files. After I included header file UNIRest.h into my source and added the libs directory into VS+ Directories option in Project Properties - Configuration Properties - VC+ Directories. Everything is still OK. But when I opened the header file UNIRest.h the problem appeared:
#import "UNIHTTPRequest.h"
#import "UNIHTTPRequestWithBody.h"
#import "HttpRequest/UNISimpleRequest.h"
#import "HttpRequest/UNIBodyRequest.h"
#import "HttpResponse/UNIHTTPBinaryResponse.h"
#import "HttpResponse/UNIHTTPJsonResponse.h"
#import "HttpResponse/UNIHTTPStringResponse.h"
All of those macros are underlined and compilation failed with message:
fatal error C1083: Cannot open type library file: 'libs\unirest\unihttprequest.h': Error loading type library/DLL.
Could you please help me? Hope it's not just a stupid question because I tried to make it works whole afternoon :(

Typically you need to do 5 things to include a library in your project:
1) Add #include statements necessary files with declarations/interfaces, e.g.:
#include "library.h"
2) Add an include directory for the compiler to look into
-> Configuration Properties/VC++ Directories/Include Directories (click and edit, add a new entry)
3) Add a library directory for *.lib files:
-> project(on top bar)/properties/Configuration Properties/VC++ Directories/Library Directories (click and edit, add a new entry)
4) Link the lib's *.lib files
-> Configuration Properties/Linker/Input/Additional Dependencies (e.g.: library.lib;
5) Place *.dll files either:
-> in the directory you'll be opening your final executable from or into Windows/system32

In code level also, you could add your lib to the project using the compiler directives #pragma.
example:
#pragma comment( lib, "yourLibrary.lib" )

Related

Using crypto++ library with MSVS 2013 [duplicate]

I started with learning C++ a few days ago and I would like to get some data to make it more funny. I found a powerful C++ library called Unirest that can help me to get data from many APIs and after practice the basics :)
I don't know how to include libraries into my project. I fond some videos about how to do it so I just created libs folder (like i always do when I'm programming in PHP) and I copied library files. After I included header file UNIRest.h into my source and added the libs directory into VS+ Directories option in Project Properties - Configuration Properties - VC+ Directories. Everything is still OK. But when I opened the header file UNIRest.h the problem appeared:
#import "UNIHTTPRequest.h"
#import "UNIHTTPRequestWithBody.h"
#import "HttpRequest/UNISimpleRequest.h"
#import "HttpRequest/UNIBodyRequest.h"
#import "HttpResponse/UNIHTTPBinaryResponse.h"
#import "HttpResponse/UNIHTTPJsonResponse.h"
#import "HttpResponse/UNIHTTPStringResponse.h"
All of those macros are underlined and compilation failed with message:
fatal error C1083: Cannot open type library file: 'libs\unirest\unihttprequest.h': Error loading type library/DLL.
Could you please help me? Hope it's not just a stupid question because I tried to make it works whole afternoon :(
Typically you need to do 5 things to include a library in your project:
1) Add #include statements necessary files with declarations/interfaces, e.g.:
#include "library.h"
2) Add an include directory for the compiler to look into
-> Configuration Properties/VC++ Directories/Include Directories (click and edit, add a new entry)
3) Add a library directory for *.lib files:
-> project(on top bar)/properties/Configuration Properties/VC++ Directories/Library Directories (click and edit, add a new entry)
4) Link the lib's *.lib files
-> Configuration Properties/Linker/Input/Additional Dependencies (e.g.: library.lib;
5) Place *.dll files either:
-> in the directory you'll be opening your final executable from or into Windows/system32
In code level also, you could add your lib to the project using the compiler directives #pragma.
example:
#pragma comment( lib, "yourLibrary.lib" )

Dlib Error: error C1083: Cannot open include file:'type_safe_union/type_safe_union_kernel.h'

I'd like to use the image processing package of Dlib (C++ library) in Visual Studio 2013.
I created an empty project and added "dlib-18.16\dlib\all\source.cpp" to my Source Files in the Solution Explorer. Then, I added the path to dlib-18.16 to my Include Directories in VC++ Directories and I also added the path to dlib-18.16\dlib to my Additional Include Directories in C/C++ General of Visual Studio.
I can run the file matrix_ex.cpp which is one of the examples of Dlib, but I can't run the file face_detection_ex.cpp because of the error " Cannot open include file:'type_safe_union/type_safe_union_kernel.h' " which is actually caused by the line #include <dlib/image_processing/frontal_face_detector.h>
How can I resolve this issue? Why the program finds some header files but it can't find the others while they are all located in the same folder?
You need to add the dlib folder itself to the Include Directories in VC++ Directories, you instead added the folder above it.
By extension that would mean your include directive needs to be #include <image_processing/frontal_face_detector.h>.
Let me list a hypothetical example to explain better. You downloaded dlib-18.16.tar.bz2 and extracted it to c:\projects. This creates a folder named c:\projects\dlib-18.16. Within VC++ Directories you added c:\projects\dlib-18.16 to the Include Directories.
However this isn't correct, you should remove that directory and instead add c:\projects\dlib-18.16\dlib as that is the include directory for the project.
That will cause #include <type_safe_union/type_safe_union_kernel.h> to load C:\projects\dlib-18.16\dlib\type_safe_union\type_safe_union_kernel.h as well as similar internal links between files.

Linker error when using cuSolver [duplicate]

I started with learning C++ a few days ago and I would like to get some data to make it more funny. I found a powerful C++ library called Unirest that can help me to get data from many APIs and after practice the basics :)
I don't know how to include libraries into my project. I fond some videos about how to do it so I just created libs folder (like i always do when I'm programming in PHP) and I copied library files. After I included header file UNIRest.h into my source and added the libs directory into VS+ Directories option in Project Properties - Configuration Properties - VC+ Directories. Everything is still OK. But when I opened the header file UNIRest.h the problem appeared:
#import "UNIHTTPRequest.h"
#import "UNIHTTPRequestWithBody.h"
#import "HttpRequest/UNISimpleRequest.h"
#import "HttpRequest/UNIBodyRequest.h"
#import "HttpResponse/UNIHTTPBinaryResponse.h"
#import "HttpResponse/UNIHTTPJsonResponse.h"
#import "HttpResponse/UNIHTTPStringResponse.h"
All of those macros are underlined and compilation failed with message:
fatal error C1083: Cannot open type library file: 'libs\unirest\unihttprequest.h': Error loading type library/DLL.
Could you please help me? Hope it's not just a stupid question because I tried to make it works whole afternoon :(
Typically you need to do 5 things to include a library in your project:
1) Add #include statements necessary files with declarations/interfaces, e.g.:
#include "library.h"
2) Add an include directory for the compiler to look into
-> Configuration Properties/VC++ Directories/Include Directories (click and edit, add a new entry)
3) Add a library directory for *.lib files:
-> project(on top bar)/properties/Configuration Properties/VC++ Directories/Library Directories (click and edit, add a new entry)
4) Link the lib's *.lib files
-> Configuration Properties/Linker/Input/Additional Dependencies (e.g.: library.lib;
5) Place *.dll files either:
-> in the directory you'll be opening your final executable from or into Windows/system32
In code level also, you could add your lib to the project using the compiler directives #pragma.
example:
#pragma comment( lib, "yourLibrary.lib" )

Visual Studio Additional Include Paths?

I'm working on an existing Visual Studio 12 "Solution" from another team..
In one of its "project"s,, there's a header file that includes a file from another static library projecet..
So Lets say the solution structure looks something like this:
Project A (Static Library Project)
\__ someFile.h
Project B (Static Library Project)
\__ someLibrary.h
In someFile.h,
...
#include "someLibrary.h"
...
and this loads the library successfully.. BUT this is strange because the path to someLibrary.h is NOT SPECIFIED anywhere in Project A's settings!!
I've checked Configuration Properties => VC++ Directories => Include Directories but path to someLibrary.h is NOT specified here..
Since Project A is a static library with NO cpp files (has only header files), It does not have a Configuration Properties => C++ => Additional Include Directory Option at all... (It only has the Librarian option)
And of course someLibrary.h is not in the same directory as someFile.h.
Finally, in Project A's Common Properties, Project B is not referenced either...
So my question is : How the hell does someFile.h know where someLibrary.h is?
How is it including it??
Is there any other places in project settings/etc where additional include directory can be specified..?
UPDATE:
when I right click on the #include statement and click "Open Document 'someLibrary.h'",
I do see a following VS error box:
File 'someLibrary.h' not found in current source file's directory or in build system paths.
Nevertheless,, there is NO build error, and Project A uses someLibrary.h with no problem!!

unable to link FMOD library to VS2010 project

I am trying to link FMOD to my project, which I did very easily in the past in Visual Studio 2008.... So I have placed the fmodex_vc.lib and the fmodex.dll file in my project directory, added them to my project's solution explorer, then created a SoundMgr.h file which includes the fmod.h file
#include "include\fmod\fmod.h"
Where fmod has been placed in the include\fmod folder and opens ok if i right click on the above code and click "Open Document"...
But if I try to write any code at all, including a simple "using namespace FMOD" it tells me that it FMOD is undeclared or unidentified.... am I missing any step?
EDIT:
What the class looks like so far is:
#pragma once
#include "main.h"
#include "include\fmod\fmod.hpp"
#include "include\fmod\fmod_errors.h"
#include "include\fmod\fmod.h"
class SoundMgr{
void init();
};
void SoundMgr::init(){
FSOUND_Init (44100, 32, 0);
}
And the error is:
Error 1 error C3861: 'FSOUND_Init': identifier not found
And that's for any line of the sample code that I try import from this quick guide:
GameDev FMOD quick guide
I tried adding the library as an additional dependency in the Input section of the Properties/Linker and I get
1. fatal error LNK1181: cannot open input file 'fmodex_vc.lib'
Any of these errors ring a bell?
Don't you want fmod.hpp to get the c++ features?
you can include the headers path in C/C++ > General and library path to Linker properties and include the dll's in you project. In this case you have the files in you release/debug dir
Right so I eventually fixed it by removing the Additional Dependency in the Input section of the Linker and instead adding Include and Library directories in in Configuration Properties\VC++ directories.... Most articles I found advise to use the actual full path to the FMOD installation folder, but since I want this project to be portable and self contained, i created a "lib" and "include" folder in my project and put those files in them... (used the directories "\lib" and "\include" in the project properties which I am assuming links to the project folder, have never done this before but am hoping it won't cause dependency issues if I compile this on a different machine)...