How to # enable third-party libraries

I created and installed a library called OhNet . After make install corresponding frame header files were installed under usr/local/include/ohNet . Now I want to use the library in my C ++ project (I use eclipse), but when I try to include some header files, eclipse cannot find the files. As far as I know, eclipse should look for header files in these directories (/ usr / include, / usr / local / include, ...) by default .... What do I need to do to use the library? I am new to C ++ and have not used third-party sources before.

Thanks.

- EDIT-- I just want to write a simple helloworld program to make sure that I have enabled the framework correctly. For this, I want to set the OpenHome::Net::DvDeviceStdStandard . see link ohNet C ++

Now I can include the header file using: #include <ohNet/OpenHome/Net/Core/DvDevice.h> This works great. But how can I create an object of type OpenHome::Net::DvDeviceStdStandard ? Now? Eclipse says that this type cannot be resolved. :(

 #include <iostream> #include <ohNet/OpenHome/Net/Core/DvDevice.h> using namespace std; int main() { OpenHome::Net::DvDeviceStdStandard device; //type cannot be resolved cout << "!!!Hello World!!!" << endl; return 0; } 
+4
source share
2 answers
  • Use the -I compiler option to point to a third-party library directory ( -I/usr/local/include/ohNet )
  • Use #include "[whatever you need from oHNet].h" in your header files and compilation units as needed ( Note: you may need to set relative prefixes for subdirectors in the third party, including the path tree here!)
  • Use the -L linker option to specify the path to the capabilities of third-party libraries ( -L/usr/local/lib possible)
  • Use the -L linker option to specify any specific 3rd libraries you need ( -l[oHNet] possible)

Look in the directories what was actually installed there to understand what to place for [whatever you need from oHNet].h and [oHNet] , s.th. e.g. liboHNet.a for the latter.

You have not tagged the [tag: Eclipse CDT] tag here, but go to the Project-> Properties-> C ++ Builder-> Settings Dialog and find C / C ++ Includes and Linker Options.

+6
source

You will need to put the header files that you want to use in your project folder, and then use #include in your .cpp file as you would for any other header files.

0
source

Source: https://habr.com/ru/post/1493728/


All Articles