KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Please bear with me. I really want to know as I am curious about the answer: Is there an intelligent way to know the name of the library to link to at compile time? Allow me to give you an example that illustrates perfectly the reason for my question. I am a C++ newbie. I am learning about compiling, linking and libraries like boost. I just discovered boost/filesystem and wanted to try it. Having had troubles compiling, I used the following minimalist code: // file boost_example.cpp #include "boost/filesystem.hpp" #include <iostream> int main() { std::cout<<"Hello"; return 0; } I tried to compile it, but being a newbie, I made a newbie mistake: I forgot to link to the proper library! g++ boost_example.cpp -o run To be precise, I experienced the problem explained in this chapter of this fine book . I knew I had boost installed (I was told to install it to compile another project). I tried to copy from the Makefile of that other project, but the following didn't work: g++ boost_example.cpp -o run -lbooster g++ boost_example.cpp -o run -lboost Trying to make an educated guess from the #include line in the code, I tried the following to no avail: g++ boost_example.cpp -o run -lboost_filesystem By that time, I had started to search the web frantically. I hate search engines because most of the time, you don't find what you're looking. I found the following but they didn't help but to waste my time: Boost library link problem under kubuntu C++/Boost linker errors Since
Tags (comma-separated)
Save Edits
Cancel