Re: getting libcurl to run with C in codeblocks (mingw-32)

2016-12-02 Thread Greg Saunders
On Thu, Dec 1, 2016 at 11:29 PM, Ray Satiro via curl-library <
curl-library@cool.haxx.se> wrote:

No, that is not expected. I imagine you have some incorrect settings. You
> should just have one compiler flags entry. I would delete the two you have
> and start from scratch. There could be instructions on the internet that
> contradict this but here's what worked for me in Code::Blocks:
>
> Build options > Compiler settings > Compiler Flags > New Flag:
>
> Name: curl static
> Compiler flags: -DCURL_STATICLIB
> Linker flags: -lcurl -lcrypt32 -lwldap32 -lws2_32
> Leave everything else as the default
>
> Build options > Linker settings: There should be no curl entry in  'Link
> libraries'
>
> Build options > Search directories > Compiler: C:\foo\curl-7.51.0\include
>
> Build options > Search directories > Linker: C:\foo\curl-7.51.0\lib
>

That worked great- THANKS again!

greg
---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Re: getting libcurl to run with C in codeblocks (mingw-32)

2016-12-01 Thread Ray Satiro via curl-library

On 12/1/2016 6:11 PM, Greg Saunders wrote:
Wow!  THANKS for taking the time for such a detailed explanation.  
That helped tremendously.


I downloaded curl-7.51.0.zip from https://curl.haxx.se/download.html 
and it all worked beautifully.  And I did need


mingw32-make.exe mingw32 CFG=sspi-winssl

so thanks for your forethought in that.

I switched over to libcurl.a, and tried to add the CURL_STATICLIB 
compiler flag, but the .exe still requires libcurl.dll - is that expected?


Please stop top-posting it makes the conversation hard to follow [1].

No, that is not expected. I imagine you have some incorrect settings. 
You should just have one compiler flags entry. I would delete the two 
you have and start from scratch. There could be instructions on the 
internet that contradict this but here's what worked for me in Code::Blocks:


Build options > Compiler settings > Compiler Flags > New Flag:

Name: curl static
Compiler flags: -DCURL_STATICLIB
Linker flags: -lcurl -lcrypt32 -lwldap32 -lws2_32
Leave everything else as the default

Build options > Linker settings: There should be no curl entry in  'Link 
libraries'


Build options > Search directories > Compiler: C:\foo\curl-7.51.0\include

Build options > Search directories > Linker: C:\foo\curl-7.51.0\lib

Now when you build if you look at the verbose output in the build log it 
should look like this:


mingw32-gcc.exe -Wall -DCURL_STATICLIB -g -IC:\foo\curl-7.51.0\include 
-c C:\foo\testproj\Test\main.c -o obj\Debug\main.o
mingw32-g++.exe -LC:\foo\curl-7.51.0\lib -o bin\Debug\Test.exe 
obj\Debug\main.o  -lcurl -lcrypt32 -lwldap32 -lws2_32


If it still won't work then include the build log output in your reply.

[1]: https://curl.haxx.se/mail/etiquette.html#Do_Not_Top_Post

---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Re: getting libcurl to run with C in codeblocks (mingw-32)

2016-12-01 Thread Greg Saunders
Ray-

Wow!  THANKS for taking the time for such a detailed explanation.  That
helped tremendously.

I downloaded curl-7.51.0.zip from https://curl.haxx.se/download.html and it
all worked beautifully.  And I did need

mingw32-make.exe mingw32 CFG=sspi-winssl

so thanks for your forethought in that.

I switched over to libcurl.a, and tried to add the CURL_STATICLIB compiler
flag, but the .exe still requires libcurl.dll - is that expected?

Compiler flags are:

[image: Inline image 2]







On Thu, Dec 1, 2016 at 1:37 PM, Ray Satiro via curl-library <
curl-library@cool.haxx.se> wrote:

> On 12/1/2016 12:09 PM, Greg Saunders wrote:
>
> Thanks, Daniel- that got me going in the right direction and I was able to
> get it running.  There were lots of little gotchas and false starts, so to
> help others here are the steps I used, along with errors I encountered
> along the way:
>
>1. download curl from https://github.com/curl/curl (note that this has
>to be set up as a git repository locally rather than just downloading the
>files, otherwise step #2 below will not work)
>2. run buildconf.bat
>3. run mingw32-make.exe mingw32
>4. create new C project in codeblocks (main.c)
>5. copy contents curl/docs/examples/url2file.c
>
>intro main.c for my test program
>6. run program- gives error: "curl/curl.h: No such file or directory"
>7. Under "Project/Build Options/Search directories/Compiler tab" add
>relative path to "myCurlGitDownload\curl\include\" (the .h files).
>8. run program - gives error: "undefined reference to
>`curl_global_init'"
>9. Under "Project/Build Options/Linker Settings", add "libcurldll.a"
>(from curl/lib/ folder)
>10. run program - gives error: "The program can't start because
>libcurl.dll is missing... "
>11. Under "Project/Build Options/Search directories/Linker", add
>relative path to "myCurlGitDownload\curl\lib\"
>12. run program - it works!
>
> There is only one minor problem left:  when I compile the code and then
> try to run the standalone .exe, it complains that "The program can't start
> because libcurl.dll is missing from your computer."
>
> If I copy libcurl.dll to the same directory as the .exe it works fine, but
> I would rather bundle the libcurl.dll into the .exe.
>
> I did try adding the CURL_STATICLIB compiler flag as described on
> https://curl.haxx.se/docs/faq.html#Link_errors_when_building_libcur, but
> that did not make any difference.
>
> From searching on other sites, sounds like I might need a .lib file rather
> than a .dll if I want to bundle it into the executable, but I did not see
> any .lib files in the distribution.  Is there a way to Make those?
>
>
> mingw32 users are also able to use the better maintained autotools style
> scripts ./buildconf && ./configure from MSYS (sometimes included with
> mingw) to build using the mingw gcc. The m32 makefiles you used are fine
> but they don't detect or enable anything extra by default, you are expected
> to specify it in a configuration using the CFG variable. You can open up
> the lib/Makefile.m32 or src/Makefile.m32 to see how it works and is
> documented. If I were you I'd use at least Windows SSL, SSPI and IDN
> options, like this
>
> mingw32-make.exe mingw32-clean
> mingw32-make.exe mingw32 CFG=sspi-winidn-winssl
>
> If your mingw is too old the import for WinIDN may not be available:
> ld.exe: cannot find -lnormaliz
> so skip it:
>
> mingw32-make.exe mingw32-clean
> mingw32-make.exe mingw32 CFG=sspi-winssl
>
> At this point you will end up with a libcurldll.a (import library for the
> dll) and a libcurl.a (static library). Your question about why staticlib
> doesn't do anything is because you explicitly specified the DLL library.
> Typically this is how you would build the example simple.c using the DLL:
>
> gcc -Wall -Wextra -o simple simple.c -I ../../include -L ../../lib
> -lcurldll
>
> static libraries it's complicated though because you have to know at link
> time all the dependencies. In the case of Windows SSL and SSPI and IDN it
> (usually) looks like this:
>
> gcc -DCURL_STATICLIB -Wall -Wextra -o simple simple.c -I ../../include -L
> ../../lib -lcurl -lcrypt32 -lnormaliz -lwldap32 -lws2_32
>
> *Please note the repo master branch is for development and should not be
> used for production.* What that means is if you are going to release your
> software you should instead build it with the latest curl release. On the
> download page [1] you can find the official release source and also some
> contributed builds. Sign up for release announcements [2]. It is also
> possible to build the latest release from the repo by checking out the
> latest release tag (git checkout). You can find the latest release tag by
> going to https://github.com/curl/curl/releases/latest or you can automate
> it in a script like
>
> curl -fLsS --proto =https https://api.github.com/repos/
> cur

Re: getting libcurl to run with C in codeblocks (mingw-32)

2016-12-01 Thread Ray Satiro via curl-library

On 12/1/2016 12:09 PM, Greg Saunders wrote:
Thanks, Daniel- that got me going in the right direction and I was 
able to get it running.  There were lots of little gotchas and false 
starts, so to help others here are the steps I used, along with errors 
I encountered along the way:


 1. download curl from https://github.com/curl/curl (note that this
has to be set up as a git repository locally rather than just
downloading the files, otherwise step #2 below will not work)
 2. run buildconf.bat
 3. run mingw32-make.exe mingw32
 4. create new C project in codeblocks (main.c)
 5. copy contents curl/docs/examples/url2file.c

intro main.c for my test program
 6. run program- gives error: "curl/curl.h: No such file or directory"
 7. Under "Project/Build Options/Search directories/Compiler tab" add
relative path to "myCurlGitDownload\curl\include\" (the .h files).
 8. run program - gives error: "undefined reference to `curl_global_init'"
 9. Under "Project/Build Options/Linker Settings", add "libcurldll.a"
(from curl/lib/ folder)
10. run program - gives error: "The program can't start because
libcurl.dll is missing... "
11. Under "Project/Build Options/Search directories/Linker", add
relative path to "myCurlGitDownload\curl\lib\"
12. run program - it works!

There is only one minor problem left:  when I compile the code and 
then try to run the standalone .exe, it complains that "The program 
can't start because libcurl.dll is missing from your computer."


If I copy libcurl.dll to the same directory as the .exe it works fine, 
but I would rather bundle the libcurl.dll into the .exe.


I did try adding the CURL_STATICLIB compiler flag as described on 
https://curl.haxx.se/docs/faq.html#Link_errors_when_building_libcur, 
but that did not make any difference.


From searching on other sites, sounds like I might need a .lib file 
rather than a .dll if I want to bundle it into the executable, but I 
did not see any .lib files in the distribution.  Is there a way to 
Make those?




mingw32 users are also able to use the better maintained autotools style 
scripts ./buildconf && ./configure from MSYS (sometimes included with 
mingw) to build using the mingw gcc. The m32 makefiles you used are fine 
but they don't detect or enable anything extra by default, you are 
expected to specify it in a configuration using the CFG variable. You 
can open up the lib/Makefile.m32 or src/Makefile.m32 to see how it works 
and is documented. If I were you I'd use at least Windows SSL, SSPI and 
IDN options, like this


mingw32-make.exe mingw32-clean
mingw32-make.exe mingw32 CFG=sspi-winidn-winssl

If your mingw is too old the import for WinIDN may not be available:
ld.exe: cannot find -lnormaliz
so skip it:

mingw32-make.exe mingw32-clean
mingw32-make.exe mingw32 CFG=sspi-winssl

At this point you will end up with a libcurldll.a (import library for 
the dll) and a libcurl.a (static library). Your question about why 
staticlib doesn't do anything is because you explicitly specified the 
DLL library. Typically this is how you would build the example simple.c 
using the DLL:


gcc -Wall -Wextra -o simple simple.c -I ../../include -L ../../lib -lcurldll

static libraries it's complicated though because you have to know at 
link time all the dependencies. In the case of Windows SSL and SSPI and 
IDN it (usually) looks like this:


gcc -DCURL_STATICLIB -Wall -Wextra -o simple simple.c -I ../../include 
-L ../../lib -lcurl -lcrypt32 -lnormaliz -lwldap32 -lws2_32


*Please note the repo master branch is for development and should not be 
used for production.* What that means is if you are going to release 
your software you should instead build it with the latest curl release. 
On the download page [1] you can find the official release source and 
also some contributed builds. Sign up for release announcements [2]. It 
is also possible to build the latest release from the repo by checking 
out the latest release tag (git checkout). You can find the latest 
release tag by going to https://github.com/curl/curl/releases/latest or 
you can automate it in a script like


curl -fLsS --proto =https 
https://api.github.com/repos/curl/curl/releases/latest | jq --raw-output 
".tag_name | select(type == \"string\")"



[1]: https://curl.haxx.se/download.html
[2]: https://cool.haxx.se/mailman/listinfo/curl-announce

---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Re: getting libcurl to run with C in codeblocks (mingw-32)

2016-12-01 Thread Greg Saunders
Thanks, Daniel- that got me going in the right direction and I was able to
get it running.  There were lots of little gotchas and false starts, so to
help others here are the steps I used, along with errors I encountered
along the way:

   1. download curl from https://github.com/curl/curl (note that this has
   to be set up as a git repository locally rather than just downloading the
   files, otherwise step #2 below will not work)
   2. run buildconf.bat
   3. run mingw32-make.exe mingw32
   4. create new C project in codeblocks (main.c)
   5. copy contents curl/docs/examples/url2file.c
   
   intro main.c for my test program
   6. run program- gives error: "curl/curl.h: No such file or directory"
   7. Under "Project/Build Options/Search directories/Compiler tab" add
   relative path to "myCurlGitDownload\curl\include\" (the .h files).
   8. run program - gives error: "undefined reference to `curl_global_init'"
   9. Under "Project/Build Options/Linker Settings", add "libcurldll.a"
   (from curl/lib/ folder)
   10. run program - gives error: "The program can't start because
   libcurl.dll is missing... "
   11. Under "Project/Build Options/Search directories/Linker", add
   relative path to "myCurlGitDownload\curl\lib\"
   12. run program - it works!

There is only one minor problem left:  when I compile the code and then try
to run the standalone .exe, it complains that "The program can't start
because libcurl.dll is missing from your computer."

If I copy libcurl.dll to the same directory as the .exe it works fine, but
I would rather bundle the libcurl.dll into the .exe.

I did try adding the CURL_STATICLIB compiler flag as described on
https://curl.haxx.se/docs/faq.html#Link_errors_when_building_libcur, but
that did not make any difference.

>From searching on other sites, sounds like I might need a .lib file rather
than a .dll if I want to bundle it into the executable, but I did not see
any .lib files in the distribution.  Is there a way to Make those?

Thanks again for all the help,

Greg


On Thu, Dec 1, 2016 at 7:40 AM, Daniel Stenberg  wrote:

> On Wed, 30 Nov 2016, Greg Saunders wrote:
>
>   1. downloaded curl from https://github.com/curl/curl
>>   2. ran buildconf.bat (successfully)
>>   3. created new C project in codeblocks (main.c)
>>
>
> You seem to have skipped step 2a: build the library (and curl)
>
> It might work with just 'make mingw32' in the source tree root.
>
>
> --
>
>  / daniel.haxx.se
> ---
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  https://curl.haxx.se/mail/etiquette.html
---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Re: getting libcurl to run with C in codeblocks (mingw-32)

2016-12-01 Thread Daniel Stenberg

On Wed, 30 Nov 2016, Greg Saunders wrote:


  1. downloaded curl from https://github.com/curl/curl
  2. ran buildconf.bat (successfully)
  3. created new C project in codeblocks (main.c)


You seem to have skipped step 2a: build the library (and curl)

It might work with just 'make mingw32' in the source tree root.


--

 / daniel.haxx.se
---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Re: getting libcurl to run with C in codeblocks (mingw-32)

2016-12-01 Thread Greg Saunders
Thanks, Thomas - but I think it is different on Windows vs Linux.  I don't
have the UNIX commands (make etc), I have only buildconf.bat.

I tried running that with "buildconf CC=i686-w64-mingw32-gcc ./configure
--prefix=`pwd`/../local/win33"

but that gives me an error:  "Unknown argument CC"

I think my biggest problem at this point is that I don't have the "curl"
library to link to under Linker settings, but there was no curl.a or curl.o
or curl.lib file in the distribution, and I can't figure out how to make
any of those files.

Still stuck :-(

thx
greg


On Thu, Dec 1, 2016 at 3:37 AM, Thomas Glanzmann 
wrote:

> Hello Greg,
>
> > I've spent a few hours trying to run libcurl in codeblocks (GNU GCC
> > mingw-32 Compiler),
>
> I'm building on Debian Linux for Windows. However maybe my instructions
> help you:
>
> apt-get install git make gcc libx11-dev mingw-w64 libtool
> git clone https://github.com/curl/curl
> cd curl
> ./buildconf CC=i686-w64-mingw32-gcc ./configure
> --prefix=`pwd`/../local/win32
> make -j
> make install
>
> Afterwards I'm building using:
>
> `local/win32/bin/curl-config --cc --cflags --libs` -g -s -static -o my.exe
> my.c -Wall -fno-strict-aliasing -lcurl -lwinmm -lcrypt32 -lwldap32 -lws2_32
> -lwinhttp -lole32 -lcredui
>
> Cheers,
> Thomas
> ---
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  https://curl.haxx.se/mail/etiquette.html
---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Re: getting libcurl to run with C in codeblocks (mingw-32)

2016-12-01 Thread Thomas Glanzmann
Hello Greg,

> I've spent a few hours trying to run libcurl in codeblocks (GNU GCC
> mingw-32 Compiler),

I'm building on Debian Linux for Windows. However maybe my instructions
help you:

apt-get install git make gcc libx11-dev mingw-w64 libtool
git clone https://github.com/curl/curl
cd curl
./buildconf CC=i686-w64-mingw32-gcc ./configure --prefix=`pwd`/../local/win32
make -j
make install

Afterwards I'm building using:

`local/win32/bin/curl-config --cc --cflags --libs` -g -s -static -o my.exe my.c 
-Wall -fno-strict-aliasing -lcurl -lwinmm -lcrypt32 -lwldap32 -lws2_32 
-lwinhttp -lole32 -lcredui

Cheers,
Thomas
---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html