Reputation: 79
I'm having a problem with creating a Makefile in C++. I need to link the readline library with my code but I keep getting this error.
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lreadline collect2: error: ld returned 1 exit status make: *** [Makefile:5: tokenizer] Error 1
I currently have my readline folder, which I have downloaded from the GNU Readline library site, in cygwin64/usr/include folder.
In my tokenizer.cpp code, I also have #include <readline/readline.h>
, but I previously kept getting an error which was fixed by putting my readline folder in the directory it is in right now, so I assumed this was the correct place to put it until this error came up.
In my cygwin/usr directory, I don't have a lib directory in it, so I'm not sure if moving or copying my readline folder to another directory would fix the problem. Aside from that, I'm not really sure what else could be wrong aside from my Makefile itself
CC=gcc
tokenizer : tokenizer.cpp
$(CC) -o $@ -g $< -lreadline.c
Any help or suggestions would be greatly appreciated!
Upvotes: 1
Views: 1562
Reputation: 8496
Use cygcheck
to find the package containing the proper import library (ending in dll.a
for shared ones)
$ cygcheck -p usr/lib/libreadline.dll.a
Found 3 matches for usr/lib/libreadline.dll.a
...
libreadline-devel-7.0.3-3 - libreadline-devel: GNU readline and history libraries (development)
Use setup to install the libreadline-devel
Upvotes: 2