I'm having some problems statically linking ncurses to one of my programs
Here's a really simple sample program:
#include<ncurses.h>
int main(){
initscr();
printw("Hello world\n");
refresh();
getch();
endwin();
return 0;
}
When I compile it with
gcc -static -lncurses hello_curses.c -o curses
I get these errors:
/tmp/ccwHJ6o1.o: In function `main':
curses_hello.c:(.text+0x5): undefined reference to `initscr'
curses_hello.c:(.text+0x14): undefined reference to `printw'
curses_hello.c:(.text+0x1b): undefined reference to `stdscr'
curses_hello.c:(.text+0x20): undefined reference to `wrefresh'
curses_hello.c:(.text+0x27): undefined reference to `stdscr'
curses_hello.c:(.text+0x2c): undefined reference to `wgetch'
curses_hello.c:(.text+0x31): undefined reference to `endwin'
collect2: ld returned 1 exit status
I'm a little confused why this isn't working. What am I missing here?
You need to pass -l options at the end of the command line:
gcc -static hello_curses.c -o curses -lncurses
When the compiler encounters -lfoo, it links in all the symbols from foo that have been requested by a previous file. If you put -lfoo at the beginning, no symbol has been requested yet, so no symbol gets linked.
Edit:
I think the real problem is that you need to specify your -l option at the end of the command. I just tried it the way you had it and reproduced your error. If I put -l:libncurses.a at the end of the line then it works. All without the -static option BTW.
I think what is happening is that you have a dynamic library for ncurses but you have used the -static option which means to not use any dynamic libraries. I suspect you do not actually have a static version of the ncurses library i.e. one ending with a .a suffix.
If you want to link with the static version (.a) of ncurses rather than the dynamic version (.so) then temporarily remove the symlink for libncurses.so so that the linker picks up the .a file instead. Alternatively copy the .a file somewhere else and add that to an earlier search path.
Alternatively if your linker supports it (eg. ld) then you could specify -l:libncurses.a instead of -lncurses.
I just spent a few hours on an ARM processor, trying to get it to work, as the accepted answer didn't work for me.
Here are my findings:
Apparently
gcc -static hello_curses.c -o curses -lncurses
works on an x64 processor, but not on an ARM processor.
When I tried with the above line, I still got all the "undefined reference errors" (and a lot more) of the OP.
You need to also link against libtinfo.a, and note that sequence matters.
This is the correct command line that works:
gcc -static hello_curses.c -o curses -lncurses -ltinfo
If you mix up the sequence, then it won't work...
gcc -static hello_curses.c -o curses -ltinfo -lncurses
undefined reference to `unctrl'
Of course this also works if you use the :lib syntax
This compiles
gcc -static hello_curses.c -o curses -l:libncursesw.a -l:libtinfo.a
This does not compile
gcc -static hello_curses.c -o curses -l:libtinfo.a -l:libncursesw.a
Oh how I like gcc...
This program should never have been allowed to graduate from kindergarden
(.text+0x2a8): undefined reference to cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioninit_pair': (.text+0x2ac): undefined reference to
cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioninit_pair': (.text+0x50a): undefined reference to tparm'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioninit_pair': (.text+0x518): undefined reference to
_nc_putp'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioninit_color': (.text+0x552): undefined reference to
cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioninit_color': (.text+0x556): undefined reference to
cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioninit_color': (.text+0x5e4): undefined reference to
tparm'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioninit_color': (.text+0x5f2): undefined reference to
_nc_putp'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioncan_change_color': (.text+0x740): undefined reference to
cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioncan_change_color': (.text+0x744): undefined reference to
cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functionhas_colors': (.text+0x768): undefined reference to
cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functionhas_colors': (.text+0x76c): undefined reference to
cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In functioncolor_content': (.text+0x7c2): undefined reference to
cur_term'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):(.text+0x7c6):
more undefined references tocur_term' follow
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In function _nc_do_color': (.text+0x8de): undefined reference to
tparm'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In function _nc_do_color': (.text+0x8e6): undefined reference to
tputs'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In function _nc_do_color': (.text+0x958): undefined reference to
tputs'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In function set_foreground_color': (.text+0x62): undefined reference
totputs'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_color.o):
In function set_background_color': (.text+0xa2): undefined reference
totputs'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_hline.o):
In function whline': (.text+0xec): undefined reference toacs_map'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_hline.o):
In function whline': (.text+0xf0): undefined reference toacs_map'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_add_wch.o):
In function wadd_wch': (.text+0x4fe): undefined reference to
TABSIZE'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_add_wch.o):
In function wadd_wch': (.text+0x502): undefined reference to
TABSIZE'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_add_wch.o):
In function wecho_wchar': (.text+0x6d8): undefined reference to
TABSIZE'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_add_wch.o):
In function wecho_wchar': (.text+0x6dc): undefined reference to
TABSIZE'
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../arm-linux-gnueabihf/libncursesw.a(lib_wunctrl.o):
In function wunctrl': (.text+0x30): undefined reference tounctrl'
collect2: error: ld returned 1 exit status
Related
This question already has answers here:
Statically link ncurses to program
(3 answers)
Closed 1 year ago.
I'm trying ncurses C library for the first time in a little test program and every time I try to output the executable file using gcc it gives me an error.
Here is the test program:
#include <ncurses.h>
int main() {
initscr();
printw("--------\n| test |\n--------\n\n");
refresh();
printw("\npress any key to exit...");
refresh();
getch();
endwin();
return 0;
}
Here are the gcc commands and their output:
$ gcc -Wall -lncurses -c tests.c
$ gcc tests.o -o tests
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.o: warning: relocation against `stdscr' in read-only section `.text'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.o: in function `main':
tests.c:(.text+0x5): undefined reference to `initscr'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x16): undefined reference to `printw'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x1d): undefined reference to `stdscr'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x25): undefined reference to `wrefresh'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x36): undefined reference to `printw'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x3d): undefined reference to `stdscr'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x45): undefined reference to `wrefresh'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x4c): undefined reference to `stdscr'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x54): undefined reference to `wgetch'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests.c:(.text+0x59): undefined reference to `endwin'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
I tried to find a solution but didn't find any, so any help is appreciated.
Note: Does the fact that I'm using Wayland display server with no X client has something to do with the error ?
The libraries have to be added at the end of the command line as they are searched for symbols only one-time and the linking is done in the order specified.
gcc tests.o -o tests -lncurses
I have created an assembly code from a C project, but when i run it I get this compilation error:
Compilation Error
/usr/bin/x86_64-linux-gnu-ld: warning: cannot find entry symbol _start;
defaulting to 00000000004000b0
/tmp/tmpM7HOI5/squares.o: In function `main':
main.c:(.text+0x2e): undefined reference to `malloc'
main.c:(.text+0x43): undefined reference to `perror'
main.c:(.text+0x4d): undefined reference to `exit'
main.c:(.text+0x54): undefined reference to `stdin'
main.c:(.text+0x68): undefined reference to `fgets'
main.c:(.text+0xb5): undefined reference to `atoi'
main.c:(.text+0x12d): undefined reference to `free'
main.c:(.text+0x14d): undefined reference to `malloc'
main.c:(.text+0x158): undefined reference to `stdin'
main.c:(.text+0x16c): undefined reference to `fgets'
main.c:(.text+0x17f): undefined reference to `strtok'
main.c:(.text+0x18f): undefined reference to `atoi'
main.c:(.text+0x1b5): undefined reference to `strtok'
main.c:(.text+0x1c5): undefined reference to `atoi'
main.c:(.text+0x1ef): undefined reference to `strtok'
main.c:(.text+0x1ff): undefined reference to `atoi'
main.c:(.text+0x229): undefined reference to `strtok'
main.c:(.text+0x239): undefined reference to `atoi'
main.c:(.text+0x25e): undefined reference to `free'
main.c:(.text+0x2f6): undefined reference to `printf'
It seems that all library calls become undefined.
To compile I used:
gcc -std=c99 -Wall -O2 -lm -S main.c
Your GCC command only generates assembly code, but your error list is for a linker invocation.
I suspect the -lm option is causing the compiler driver to invoke the linker - it is not necessary to specify a library if you are generating only assembly for a single translation unit.
The linker is complaining about the lack of the C standard library and crt0.0 C runtime-start-up.
Remove the unnecessary -lm option - you are not intending to link, so teh library is irrelevant.
Your -lm links to the math library. Similarly, you need -lc to link to the C library.
My OS is ubuntu 14.04 32bit and my source program test.c is :
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("test.");
return;
}
I compile it with command :
gcc -S test.c
which output as a test.s file. I assemble it with command :
as -o test.o test.s
then I want to link it with c standard library statically. I searched for libc.a file , located it at /usr/lib/i386-linux-gnu/libc.a. so I tried to link it with command:
ld test.o /usr/lib/i386-linux-gnu/libc.a
but comes out with a lot of error message:
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048210
/usr/lib/i386-linux-gnu/libc.a(backtrace.o): In function `backtrace_helper':
(.text+0x20): undefined reference to `_Unwind_GetIP'
/usr/lib/i386-linux-gnu/libc.a(backtrace.o): In function `backtrace_helper':
(.text+0x45): undefined reference to `_Unwind_GetGR'
/usr/lib/i386-linux-gnu/libc.a(backtrace.o): In function `backtrace_helper':
(.text+0x50): undefined reference to `_Unwind_GetCFA'
/usr/lib/i386-linux-gnu/libc.a(backtrace.o): In function `__backtrace':
(.text+0xb1): undefined reference to `_Unwind_Backtrace'
/usr/lib/i386-linux-gnu/libc.a(iofclose.o): In function `_IO_new_fclose':
(.text+0x1b1): undefined reference to `_Unwind_Resume'
/usr/lib/i386-linux-gnu/libc.a(iofclose.o):(.eh_frame+0x167): undefined reference to `__gcc_personality_v0'
/usr/lib/i386-linux-gnu/libc.a(iofflush.o): In function `_IO_fflush':
(.text+0xd7): undefined reference to `_Unwind_Resume'
/usr/lib/i386-linux-gnu/libc.a(iofflush.o):(.eh_frame+0xdf): undefined reference to `__gcc_personality_v0'
/usr/lib/i386-linux-gnu/libc.a(iofputs.o): In function `_IO_fputs':
(.text+0xf9): undefined reference to `_Unwind_Resume'
/usr/lib/i386-linux-gnu/libc.a(iofputs.o):(.eh_frame+0xdf): undefined reference to `__gcc_personality_v0'
/usr/lib/i386-linux-gnu/libc.a(iofwrite.o): In function `_IO_fwrite':
(.text+0x139): undefined reference to `_Unwind_Resume'
/usr/lib/i386-linux-gnu/libc.a(iofwrite.o):(.eh_frame+0xdf): undefined reference to `__gcc_personality_v0'
/usr/lib/i386-linux-gnu/libc.a(iogetdelim.o): In function `_IO_getdelim':
(.text+0x285): undefined reference to `_Unwind_Resume'
/usr/lib/i386-linux-gnu/libc.a(iogetdelim.o):(.eh_frame+0xdf): undefined reference to `__gcc_personality_v0'
/usr/lib/i386-linux-gnu/libc.a(wfileops.o): In function `_IO_wfile_underflow':
(.text+0x5fc): undefined reference to `_Unwind_Resume'
/usr/lib/i386-linux-gnu/libc.a(wfileops.o):(.eh_frame+0x137): undefined reference to `__gcc_personality_v0'
/usr/lib/i386-linux-gnu/libc.a(fileops.o): In function `_IO_new_file_underflow':
(.text+0x40b): undefined reference to `_Unwind_Resume'
/usr/lib/i386-linux-gnu/libc.a(fileops.o):(.eh_frame+0x1b3): undefined reference to `__gcc_personality_v0'
/usr/lib/i386-linux-gnu/libc.a(strtof_l.o): In function `____strtof_l_internal':
(.text+0xbc6): undefined reference to `__divdi3'
/usr/lib/i386-linux-gnu/libc.a(strtof_l.o): In function `____strtof_l_internal':
(.text+0xc08): undefined reference to `__moddi3'
/usr/lib/i386-linux-gnu/libc.a(strtof_l.o): In function `____strtof_l_internal':
(.text+0x249d): undefined reference to `__divdi3'
/usr/lib/i386-linux-gnu/libc.a(strtod_l.o): In function `____strtod_l_internal':
(.text+0xcc9): undefined reference to `__divdi3'
/usr/lib/i386-linux-gnu/libc.a(strtod_l.o): In function `____strtod_l_internal':
(.text+0xd0b): undefined reference to `__moddi3'
...
...
My question is, why these error messages ? I'm trying to learn how the compiling system works, so instead of knowing how to solve this problem I 'm more desiring to know how it comes this way. It seems that the static C library depends on other libraries, why and what are those libraries ?
EDIT:
I'm doing this because I want to know how things work so I'd rather avoid the gcc script.
You also need crt0 startup object files (in addition of static libc.a), which notably are defining the _start entry point (in your ELF executable) and contain ABI specific (prologue and epilog) code to call your main (and finally process atexit(3) registered handlers and stdio flushing). The low-level libgcc is also needed. Details are complex and implementation specific. To understand them, compile your test code as
gcc -v -static test.c -o mytest
(avoid calling an executable test because it would collide with /usr/bin/test or with the builtin of your shell)
In practice, better at least link with gcc
If you are curious, take advantage that Linux is mostly free software and study the source code (e.g. of GCC, of the C standard library, of binutils, etc...). You might find musl-libc interesting.
I'd rather avoid the gcc script
Technically, gcc is not a script but a driver program (see gcc/gcc.c in the source code of GCC). But it will run ld which indeed runs some linker scripts. The actual compilation is done by cc1 which is started by the gcc program.
You must also link the gcc intrinsic library. The easiest way to do this is to use the gcc front-end to compile and link with the -static option:
gcc -static -o test test.c
If you insist on compiling from assembly, you can do this:
gcc -static -o test test.s
Static linking may not be supported on your system.
EDIT: giving gcc the -v option will tell you what commands it executes.
I am trying to install a program that consist of a folder with some C files. I run the makefile but i get the following error:
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1128: undefined reference to `tgoto'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1129: undefined reference to `tputs'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1138: undefined reference to `tputs'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1145: undefined reference to `tputs'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1154: undefined reference to `tputs'
readline/libreadline.a(display.o): In function `delete_chars':
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1182: undefined reference to `tgoto'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1183: undefined reference to `tputs'
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/display.c:1189: undefined reference to `tputs'
readline/libreadline.a(signals.o): In function `cr':
/home/silviu/Desktop/tipsy-2.2.3d/code/readline/signals.c:301: undefined reference to `tputs'
collect2: error: ld returned 1 exit status
Do you know how can I solve it? (on Ubuntu)
You have used tputs in c program so you must have use #include <curses.h> and #include <term.h>. Undefined reference is linker error. In Makefile while compiling c program you should link -lcurses or -lncurses. Add similar line to your Makefile. compile with appropriate linking library.
For example
gcc file.c -o output_file -lcurses -ltermcap
or
gcc file.c -o output_file -lcurses -ltermcap
I have been searching for a couple of hours and found several threads with the same problem and tried all their suggestions.
My curl.h is in C:\MinGW\msys\1.0\curl-7.29.0\include\curl and I've included it at compile time but for some reason gcc claims it can't find it:
gcc -o curl.exe curl.c -IC:/MinGW/msys/1.0/local/ -IC:/MinGW/msys/1.0/curl-7.29.0/lib/.libs/ -IC:/MinGW/msys/1.0/curl-7.29.0/include/curl -IC:/MinGW/msys/1.0/OpenSSL-Win32/ -lcurl -lws2_32
and the result:
curl.c:4:32: fatal error: curl/curl.h: No such file or directory
UPDATE: (With the suggestion from H2CO3)
$ gcc -o curl.exe curl.c -IC:/MinGW/msys/1.0/local -IC:/MinGW/msys/1.0/curl-7.29.0/lib/.libs/ -IC:/MinGW/msys/1.0/curl-7.29.0/include/ -IC:/MinGW/msys/1.0/OpenSSL-Win32/include/ -lws2_32
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0xa8): undefined reference to `_imp__curl_global_init'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0xe6): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x124): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x162): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x169): undefined reference to `_imp__curl_easy_init'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x183): undefined reference to `_imp__curl_slist_append'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x1b8): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x211): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x237): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x245): undefined reference to `_imp__curl_easy_perform'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x25e): undefined reference to `_imp__curl_easy_strerror'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x288): undefined reference to `_imp__curl_easy_cleanup'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x296): undefined reference to `_imp__curl_formfree'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x2a4): undefined reference to `_imp__curl_slist_free_all'
collect2: ld returned 1 exit status
If I try to compile with -lcurl it says ..... ld.exe: cannot find -lcurl is this because it can't find the dll?
You're including <curl/curl.h>, and not <curl.h>. So you have to tell the compiler to look for header files in the include directory, and not in include/curl:
gcc -IC:\MinGW\msys\1.0\curl-7.29.0\include etc. etc.
This might be beyond the scope of what you're doing, but, I found it best to install a version of cURL(libcurl) into the MinGW/MSYS environment. After installed, any program can be compiled to use it with the typical <curl/curl.h> and -lcurl conventions since it's installed where GCC would expect it. I documented my process here.