How to link my c++ project with external library?

Hi,

My project needs to use some external libraries such as GDAL and OpenCV,so how to compile in order to link these libraries?

PS:My project is in C++ and Windows.

Thanks,
Nic

Hi Nic,

While another user on this forum may be able to help, I’d suggest contacting the project’s themselves on how to build.

Note that on Windows, we have deprecated support for C++ and will no longer ship a Windows C++ compiler as of the 2016 release.

On Linux, we have updated our C++ compiler to be g++ compatible so you should be able to follow the same build instructions for using pgc++ as you would g++.

  • Mat

Hi Mat,

Thanks for your reply!

In some other compiler like Visual Studio,we can set the configuration by providing the Include and the Lib dir to link external lib.

So,my problem is how can I do this in PGI?I have ever seen the command -I and -L,but I don’t know how to use it.

PS:I’m looking forward to having that Windows C++ complier,so when would the 2016 release really release?

Thanks,
Nic

So,my problem is how can I do this in PGI?I have ever seen the command -I and -L,but I don’t know how to use it.

If you’re compiling from the command line, then you would just use the “-L” and “-l” flags. Though, “-l” will append a “lib” before the library name, for example “-lfoo” will search for a library name “libfoo.lib”. On Windows, libraries often don’t have “lib” prefixes, so you would just add the library directly to the link line, “foo.lib”, instead of adding “-l”.

From within PVF (Portland Visual Fortran), open the project properties page and look for the “Linker” pages. Under the “General” tab, you can add additional library search directories. Under the “Input” tab, you can add additional dependent libraries. Also, you can manually add “-L” and “-l” flag under the “Command Line” tab.

I’m looking forward to having that Windows C++ complier, so when would the 2016 release really release?

We’ll stop shipping pgcpp in the first release of 2016. I don’t have a firm date to share as of yet. You will still be able to use the 2015 PGI C++ compilers, but they will no longer be supported.

  • Mat

I have been trying to compile opencv using PGI on Ubuntu,there has been Cmakelists in opencv packages,then how can I compile opencv with PGI?Can I use cmake to generate a makefile and use PGI to compile it?I also want to know how to launch PVF to add the libraries?I have installed the PGI FORTRAN/C/C++ workstation on my computer.I’m looking forward to your reply,thanks!

there has been Cmakelists in opencv packages,then how can I compile opencv with PGI? Can I use cmake to generate a makefile and use PGI to compile it?

Yes, but you have to configure your CMake to use PGI. The easiest thing to do is build your own CMake using PGI as the compilers

I also want to know how to launch PVF to add the libraries?

PVF is a Visual Studio product so is only available on Windows.

  • Mat