[C/C++] How to add external library to Visual Studio 2010 (pgrflycapture, pointgrey)

ichigokurosaki
ichigokurosaki used Ask the Experts™
on
I usually use to compile my C/C++ files under Linux by using g++ and by adding libraries reference from command line.

At the moment, i have to compile and build a Visual Studio 2010 Premium project and I do not know how to add external libraries because I never used it.

I have to compile a PointGrey project in order to acquire images from my pointgrey firewire camera and i'm trying to compile a working project downloaded from the pointgrey website.

The problem is that VS gives me this error:
1>LINK : fatal error LNK1104: cannot open file 'pgrflycapture.lib'

Cpp source file are in:
C:\Program Files\Point Grey Research\FlyCapture2\include
C:\Program Files\Point Grey Research\FlyCapture2\include\FC1
C:\Program Files\Point Grey Research\FlyCapture2\include\C

Library file are in:
C:\Program Files\Point Grey Research\FlyCapture2\lib
C:\Program Files\Point Grey Research\FlyCapture2\lib\FC1
C:\Program Files\Point Grey Research\FlyCapture2\lib\C

So, in VS, I modified the configuration in this way:

In Additional Include Directories (C/C++, General tab), I added:
C:\Program Files\Point Grey Research\FlyCapture2\lib\C;C:\Program Files\Point Grey Research\FlyCapture2\lib\FC1;C:\Program Files\Point Grey Research\FlyCapture2\lib;C:\Program Files\Point Grey Research\FlyCapture2\include\FC1;..\..\include;%(AdditionalIncludeDirectories)

In Additional Dependencies, there was already specified: pgrflycapture.lib

Can you help me to understand how to add the library reference, please?

I've attached some screenshots.
VS1.PNG
VS2.PNG
VS3.PNG
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012
Commented:
We, "Additional Include Directories" is the wrong pace for the library paths, these need to be added under "Configuration Properties|Linker|Additional Library Directories", then your above setup should work

A neat alternative to the above is using #pragma in your source code, e.g.

#ifdef _WIN32
#pragma comment(lib,"mylib.lib")
#pragma comment(linker,"/LIBPATH:[PATH]")
#endif

Open in new window

Author

Commented:
Thanks a lot, jkr, as always your suggestion was correct!

Now, VS is able to find the libraries!

Unfortunately, it gives me this error:

1> File not found - MultipleCameraWriteToDiskEx.exe
1>  0 File copiati
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "xcopy /f/y "C:\Users\Rocco\Downloads\MultipleCameraWritetoDiskEx\Debug\MultipleCameraWriteToDiskEx.exe" ..\..\bin
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 4.
1>
1>Build FAILED.

Why this happens?
VS seems to be a little bit difficult to use for me!
I feel more comfortable with unix :(

Author

Commented:
I solved it!

It's was a path problem!

Thanks a lot, jkr!

Author

Commented:
perfect suggestion like always!
jkr
Top Expert 2012

Commented:
Thank you ;o)

Good that you sorted the last issue out.
jkr
Top Expert 2012

Commented:
Oh, one little correction, make that

#ifdef _MSC_VER // MS copilers only!
#pragma comment(lib,"mylib.lib")
#pragma comment(linker,"/LIBPATH:[PATH]")
#endif

Open in new window


instead...

Author

Commented:
Thanks again! :)

I'll add this tip to my notes in order to remember it! :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial