AnsweredAssumed Answered

Linker Error "cannot find -l<lib_name>"

Question asked by LPCware Support on Mar 31, 2016

Sometimes when you build a project, you may encounter a link error of the form "cannot find -l<lib_name>". Typical examples of the actual error message seen are:


cannot find -lCMSISv1p30_LPC11xx

cannot find -lLPC11xx_Lib


This error is telling you that the linker has been unable to find a specific library archive that is required in order to build your project. Often this library is contained in a library project that should be in the same workspace as the project that you are trying to build. Typically the reason why such a library cannot be found the linker is one of the following:


Library project does not exist


The required library project has not been imported into the current workspace (though often this will cause compile step errors that requested header files cannot be found). In this case import the appropriate library project - typically from within the examples subdirectory of your LPCXpresso IDE installation


Library not built / No project reference to library project


If your application project does not have a "project reference" set up to the library project, this will prevent the automatic building of the library project when your application project is built. Thus unless you had already built the library project manually, the actual library archive will not exist when the link step of your application project takes place.


For more details of setting links up between projects, see the FAQ "Creating and Linking to Library Projects".


Build configurations do not match


When you build your application project and it is linked to a library project, typically a build of the application project will require the library archive from the library project that has been built for the same build configuration (typically either Debug or Release). If this does not yet exist, then the project reference between your project and the library project will trigger a build. However this will only work if the build configurations of the two projects match (ie both set to Debug, or both set to Release). If this is not the case, then you will need to change the build configuration of one of the projects to match the other.


For more details please see the FAQ "How do I switch between Debug and Release builds?".