Include C++ library source in Netbeans project? - c++

Is there a "good" way to directly include a library's source in a Netbeans project?
When I try to do it, I add the include directory in the Linker options and src in the source directories but I get a ton of "undefined reference" errors unless I add the folder into the project using right click>add existing items from folder.
Is there a better way to do this without having all the the code in the project ?
Thanks a lot in advance for your answers

Try doing this:
Select Tools->Libraries from the menu, create a new library there, then on right side click "add Jar/folder" to insert your folder.

Related

What is the C++ Source Directories project property good for in Visual Studio? [duplicate]

Sorry for the basic question but I can't find an answer that works.
I have VS 2017 Professional 15.6.6
I just want to add source files to Intellisense's database, so that when I e.g. right-click on a symbol and choose "Go To Definition" the appropriate source will open in the editor.
The source in question is in a static .lib that I am linking with my .exe Project.
If I add the source as another Project in the same solution as my .exe project, Intellisense picks it up (whether or not I actually build the Project with the source). But I would like to just add a directory to what Intellisense sees without changing my Solution.
I tried adding the directory to Project --> Properties --> VC++ Directories --> Source Directories. That did not work. What is the purpose of this "Source Directories" setting?
I tried adding the directory to Solution --> Properties --> Debug Source Files. That also did not work. What is the purpose of this "Debug Source Files" setting?
I've done it by adding the source to the solution but disable the project from being compiled. I'm sure there is a better solution for this. I hope that someone else have found it and want to share it with us.

How do add include path to Eclipse project (C++, open folder mode)

I created a project by opening an already existing folder. There are some include files I need to add, otherwise Eclipse won't find references. If I right-click on the folder, I don't see the usual option I would see with a regular project. Is there a way to tell Eclipse where to look for w.r.t. include files?
What do you see then if you do not see the usual option? There is also a way to set paths in eclipse preferences, not just the project preferences. Did you try it?

Eclipse CDT: nothing could be resolved?

I have a very strange error/bug here:
From one hour to the next, Eclipse isn't able to resolve any of the symbol. E.g.:
std, list, [own objects], or functions like: size(), append(), cout and so on ...
I already rebuild and /refreshed the indexer over the whole project and tried to clean it too. But without any effort. The only thing new I did was yesterday: I added Doxygen support to my project.
I have no idea where this comes from. I think sending all the source code is way too big, it has to be a general Eclips-Error, since I was working like this for weeks.
Eclipse version: Kepler Service Release 2
Has anyone an idea?
UPDATE
Thank you for your Support and pardon me I have switched my whole system, thus I can't reproduce your suggestions anymore.
there are two ways:
use system's default lib: when you create the project using "New Project", you can select the "Toolchain for Indexer Setting". For example, I am using Eclipse in Linux so I just choose "Linux GCC". And after the project is created, all the headers will be automatically included for you.
use you own version of the lib: you need to tell Eclipse the paths to search for the include. Right click the project name, select "C/C++ General" -> "Paths and Symbols" -> "GNU C++". And you can add your paths there.
Most likely you have some system-specific include directories missing in your settings which makes it impossible for indexer to correctly parse iostream, thus the errors. Selecting Index -> Search For Unresolved Includes in the context menu of the project will give you the list of unresolved includes which you can search in /usr/include and add containing directories to C++ Include Paths and Symbols in Project Properties.
On my system I had to add /usr/include/c++/4.6/x86_64-linux-gnu for bits/c++config.h to be resolved and a few more directories.
Don't forget to rebuild the index (Index -> Rebuild) after adding include directories.

setup include path in eclipse CDT in mac os (headers from framework)

for example I need to include a header
#include <OpenGL/glext.h>
while it is actually a header file glext.h under OpenGL.framework/Headers/.
Therefore it is no way to give eclipse a physical path about "OpenGL/glext.h", and I always get unresolved inclusion warning.
I can still build and run them (with managed makefile project) but it is impossible to browse the functions or definitions from those "resolved" header files.
is there any solution?
While not ideal, my solution to this has been to create a folder "/Developer/Framework Headers" (though the name isn't important), and link from e.g. "/System/Library/Frameworks/Foo.framework/Headers" to "Foo" under said folder. Then in Eclipse I add "/Developer/Framework Headers" to a project's includes.
I say not ideal because apart from having to create links for the frameworks you need and add an include to each project, Eclipse seems to have trouble in certain cases such as nested frameworks (e.g. CoreGraphics beneath ApplicationServices), but YMMV.
Yes there is one. Right click on the project in "Project Explore" window and click on the "property". In there Open "C/C++ General" column and choose "Path and symbols". Now you see all of the include library path for this project. If your using C then add the OpenGL library into GNU C, or if you use C++ then add it into GNU C++. Unfortunately you have to do this for every new project. I have been searching for a while how to do this by default but nothing really useful. Hope this help you get rid of those annoying yellow wave lines.
Since current Eclipse CDT releases don't perform sub-framework header inclusion correctly, you can avoid sub-framework problems (like those generated by the CoreServices header files) by creating symbolic links to the include directories of each sub-framework. I elaborated on this subject, which stems from danhan answer on this question, in this blog post.
In order to automate this process, I've created a Z shell script which automates this process and creates the symlink to the specified frameworks' header directory, together with the links to the include directory of each one of their sub-frameworks. The script can be found in this GitHub repository.
Hope this helps.

DLL References in Visual C++

I have had C++ experience but not MSVC.
What I am trying to do is incorporate a .dll from an open source project into my project. The code is available and I have built it. I have the .dll as well as the .lib which as I understand it is required for C++ projects.
Now unfortunately there is no simple "Add Reference", drop my .dll into an include directory and add that to my solution. I have edited the project property pages, the C/C++ Additional Include Directories option as well as adding the .lib as an additional linker dependency. I have created an include directory for the dll and lib inside my solution tree.
My problem is when I try to include the header files from the documentation, VS output spits out error messages. Now I realize that I am using the dll/lib combo and that the .h files are not present in my solution so how do I add the proper includes? I am using QT toolkit also which is working but how I add the other header / dll from the open source library eludes me.
Can someone please point me in the right direction.
You need to do a couple of things to use the library:
Make sure that you have both the *.lib and the *.dll from the library you want to use. If you don't have the *.lib, skip #2
Put a reference to the *.lib in the project. Right click the project name in the Solution Explorer and then select Configuration Properties->Linker->Input and put the name of the lib in the Additional Dependencies property.
You have to make sure that VS can find the lib you just added so you have to go to the Tools menu and select Options... Then under Projects and Solutions select VC++ Directories,edit Library Directory option. From within here you can set the directory that contains your new lib by selecting the 'Library Files' in the 'Show Directories For:' drop down box. Just add the path to your lib file in the list of directories. If you dont have a lib you can omit this, but while your here you will also need to set the directory which contains your header files as well under the 'Include Files'. Do it the same way you added the lib.
After doing this you should be good to go and can use your library. If you dont have a lib file you can still use the dll by importing it yourself. During your applications startup you can explicitly load the dll by calling LoadLibrary (see: http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx for more info)
Cheers!
EDIT
Remember to use #include < Foo.h > as opposed to #include "foo.h". The former searches the include path. The latter uses the local project files.
The additional include directories are relative to the project dir. This is normally the dir where your project file, *.vcproj, is located. I guess that in your case you have to add just "include" to your include and library directories.
If you want to be sure what your project dir is, you can check the value of the $(ProjectDir) macro. To do that go to "C/C++ -> Additional Include Directories", press the "..." button and in the pop-up dialog press "Macros>>".
You mention adding the additional include directory (C/C++|General) and additional lib dependency (Linker|Input), but have you also added the additional library directory (Linker|General)?
Including a sample error message might also help people answer the question since it's not even clear if the error is during compilation or linking.