Windows下Eclipse+Cygwin无法找到本地链接库问题求助
Hey there! I’ve run into this exact linker quirk with GCC on Cygwin before, so let’s get this sorted out for you.
The Root Cause
The error boils down to how GCC’s -l flag works. When you use -l<library-name>, GCC automatically looks for files named lib<library-name>.a or lib<library-name>.lib (depending on the platform). Your current flag -llibpdcurses.lib tells GCC to search for liblibpdcurses.lib.lib—which obviously doesn’t exist!
Step-by-Step Fixes
Correct the library link flag
Head to your Eclipse project settings: Cygwin C++ Linker -> Libraries. Remove the existing-llibpdcurses.libentry and replace it with just-lpdcurses. This tells GCC to look forlibpdcurses.lib(orlibpdcurses.a, the standard static library extension on Cygwin) in your specified search path.Clean up your library path
While you mentioned slash direction doesn’t matter, it’s safer to use consistent forward slashes to avoid unexpected parsing issues. Update your-Lpath to:-L/cygdrive/c/Users/Katha/eclipse-workspace/Sheet3(Note: I removed the backslash before
Katha—that was likely a typo that could cause path resolution problems.)Double-check the library file exists
Make sure the filelibpdcurses.lib(orlibpdcurses.a) is actually located in/cygdrive/c/Users/Katha/eclipse-workspace/Sheet3. Double-check the filename for typos—even a single wrong character will break the link.
Extra Tip
If your library file is named pdcurses.lib (without the lib prefix), you can tell GCC to use the exact filename by using -l:pdcurses.lib (the colon tells GCC not to add the lib prefix or suffix). But this is less common on Cygwin, so -lpdcurses should work if your library follows the standard naming convention.
After making these changes, clean your project (Project -> Clean...) and rebuild it—this should resolve the linker error.
内容的提问来源于stack exchange,提问作者Duplikathi

