Question

I have done the following:

  1. Create new c project (Makefile Project with Existing Code)
  2. Added a build variable that my Makefile complained about
  3. Now my source .c file complains about #include files because it does not know where the lib folder is,I tried adding lib folder to library path (DID NOT WORK).

How can I link my project to an external lib folder so that my .c source file can read the .h files needed for the #include?

I added the library path to Paths and Symbols->Includes BUT when I go back to the project it only shows the root folder and nothing inside it. Do I also have to add each individual .so lib file?

Was it helpful?

Solution 2

ok so I figured it out:

(1) At the start I had a source.c and a MAKEFILE (2) Create new c project (Makefile Project with Existing Code) (3) MAKEFILE complained about a variable so I added it to environment variable (4) #include files complained so I added external library like so (a) I located my library path and found that there is a folder before /lib called include (b) The include folder had a list of header files (c) So I added the path to the include folder NOT the lib folder under paths and symbols include

WORKED LIKE A CHARM!

OTHER TIPS

Answered here : How do you add libraries to Eclipse CDT? (No such file or directory)

@cyfur01 has the best answer :

What to add depends on what you are trying to include. In the case of Boost, there are a number of header-only libraries, and there are some libraries that require linking in static/shared-object libraries (e.g., serialization). Header-Only Libraries

For header-only libraries, you just need to include the base directory of all the header files. With gcc, you add the directory using the -I flag (e.g., -I C:/path/to/boost_52_0). With a managed makefile project in Eclipse, you can accomplish the same using Properties > C/C++ Build

Settings > Tool Settings > GCC C++ Compiler > Directories Static/Shared-Object Libraries

For static/shared-object libraries, you have to specify two options:

-l --> The name of the library, less the 'lib' prefix and the file suffix (e.g., libboost_serialization.dll -> boost_serialization
-L --> The directory to look for the library file in. This is only needed if the library is on a non-standard path.

As @Chris pointed out, for a managed makefile project, both of these options can be set through Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Linker > Libraries

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top