How to set up library with project file for C++ [message #1765382] |
Thu, 08 June 2017 22:13  |
Eclipse User |
|
|
|
Hello,
I've been stuck on this problem for a while and have been madly searching every website and YouTube tutorial I can find for answers.
I have created a very basic (dynamic) library in Eclipse's C++ IDE called TestLibrary which includes a Greetings class (greetings.cpp and greetings.h) that should print to the console "hello" or "goodbye" based on the function that's called.
I cannot link these files to the project as I have seen in many tutorials that basically all say to go into the project file's properties and include paths under the compiler and linker sections.
The farthest I've gotten is getting no errors about including these file paths but not being able to use an object from the library appropriately. I can print normally to the console if there is no object created, but if I create an object, nothing will print, not even a generic std::cout call. I cannot get this far unless I use a dynamic library.
Any help would be greatly appreciated.
|
|
|
|
|
|
Re: How to set up library with project file for C++ [message #1767102 is a reply to message #1765865] |
Fri, 30 June 2017 20:53  |
Eclipse User |
|
|
|
Thank you so much for your help, David, and I apologize for the late reply. Your explanation was very clear and helped me pinpoint the fact that I was missing the linking step. Additionally, I now understand the entire process much better. That project now runs perfectly.
I am now working with a git project that uses the program_options library; I'm not sure if you are familiar with this one. In this new project, I have added the program_options library in a similar fashion to how you described adding a normal library. I have found that I do not have control over linking libraries for projects imported from git (I'm not sure why this is. I am unable to see the Tools tab under Properties > C/C++ Build > Settings). I did as much of the other steps as I could, and I had no linking errors in one of two files in my project directory. The second project, however, said it did not know how to include "C:\boost\program_options.hpp" and would not produce any output after building and running the project. I narrowed down the problem to be in the actual program_options.hpp file (http://www.boost.org/doc/libs/1_55_0/boost/program_options.hpp), where that file itself says it can't locate any of the files it is trying to include (e.g. options_description.hpp, positional_options.hpp, etc). Do you know why this might be or how I could fix it? I've seen that program_options must be "built separately"; maybe that has something to do with it?
Thank you!
|
|
|
Powered by
FUDForum. Page generated in 0.04641 seconds