WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] Developping under TCE - Using curl within QTCreator  (Read 4582 times)

Offline barbudor

  • Newbie
  • *
  • Posts: 17
[SOLVED] Developping under TCE - Using curl within QTCreator
« on: October 01, 2011, 01:37:04 PM »
Hi

While I am not a newbie C/C++ developper, my past experience was not much linux  ;)
I am now trying to do some dev under TCE using QTcreator as my IDE because I found it quite friendly and quite similar to some tools I've already used.
I had no problem to write and debug 80% of my app but now I want to add curl to do connect my app to a web server.

Context:
- TCE 3.8.4
- Extensions loaded : curl.tcz, curl-dev.tcz, libssh2.tcz, libssh2-dev.tcz, openssl-0.9.8.tcz, openssl-0.9.8-dev.tcz

I am trying to build the basic simple.c (http://curl.haxx.se/libcurl/c/simple.html) sample code

If I build the sample code by default, I will get some link error because curl functions are not found.
So I added "LIBS+=/usr/local/lib/libcurl.a" the qmake arguments
I now have more errors than before :
Code: [Select]
Running build steps for project curl-test...
Starting: "/usr/local/bin/make" clean -w
make: Entering directory `/home/tc/dev/curl-test/debug'
rm -f main.o
rm -f *~ core *.core
make: Leaving directory `/home/tc/dev/curl-test/debug'
The process "/usr/local/bin/make" exited normally.
Configuration unchanged, skipping qmake step.
Starting: "/usr/local/bin/make" -w
make: Entering directory `/home/tc/dev/curl-test/debug'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DDEBUG=1 -D_DEBUG=1 -I/tmp/tcloop/qt-4.x-dev/usr/local/mkspecs/linux-g++ -I../curl-test -I/usr/local/include -I. -I../curl-test -I. -o main.o ../curl-test/main.cpp
g++ -Wl,-rpath,/usr/local/lib -o curl-test main.o    -L/usr/local/lib /usr/local/lib/libcurl.a -lpthread
/usr/local/lib/libcurl.a(timeval.o): In function `curlx_tvnow':
timeval.c:(.text+0x89): undefined reference to `clock_gettime'
/usr/local/lib/libcurl.a(ssluse.o): In function `Curl_ossl_version':
ssluse.c:(.text+0xc): undefined reference to `SSLeay'
/usr/local/lib/libcurl.a(ssluse.o): In function `Curl_ossl_data_pending':
ssluse.c:(.text+0x252): undefined reference to `SSL_pending'
/usr/local/lib/libcurl.a(ssluse.o): In function `x509_name_oneline':
ssluse.c:(.text+0x387): undefined reference to `BIO_s_mem'
ssluse.c:(.text+0x38f): undefined reference to `BIO_new'
ssluse.c:(.text+0x3b6): undefined reference to `X509_NAME_print_ex'
ssluse.c:(.text+0x3d8): undefined reference to `BIO_ctrl'
ssluse.c:(.text+0x401): undefined reference to `BIO_free'
.... (cut) ...

I have added libssl.a and libssh2.a but still no luck :

Code: [Select]
Running build steps for project curl-test...
Configuration unchanged, skipping qmake step.
Starting: "/usr/local/bin/make" -w
make: Entering directory `/home/tc/dev/curl-test/debug'
g++ -Wl,-rpath,/usr/local/lib -o curl-test main.o    -L/usr/local/lib /usr/local/lib/libcurl.a /usr/local/lib/libssl.a /usr/local/lib/libssh2.a -lpthread
/usr/local/lib/libcurl.a(timeval.o): In function `curlx_tvnow':
timeval.c:(.text+0x89): undefined reference to `clock_gettime'
/usr/local/lib/libcurl.a(ssluse.o): In function `Curl_ossl_version':
ssluse.c:(.text+0xc): undefined reference to `SSLeay'
/usr/local/lib/libcurl.a(ssluse.o): In function `x509_name_oneline':
ssluse.c:(.text+0x387): undefined reference to `BIO_s_mem'
ssluse.c:(.text+0x38f): undefined reference to `BIO_new'
ssluse.c:(.text+0x3b6): undefined reference to `X509_NAME_print_ex'
ssluse.c:(.text+0x3d8): undefined reference to `BIO_ctrl'
ssluse.c:(.text+0x401): undefined reference to `BIO_free'

Could someone let me know what I am doing wrong ?

Thanks for your help.

br

Barbudor
« Last Edit: October 02, 2011, 02:25:52 AM by barbudor »
tinycore 3.8.3 on HP Thin Client T5300 (Transmeta Crusoe@533MHz, 56MB RAM, 2GB Compact Flash)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Developping under TCE - Using curl within QTCreator
« Reply #1 on: October 01, 2011, 09:15:10 PM »
Hi barbudor
Did you run the various  curl-config  commands as suggest here:
http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
Probably not a problem but in the line:
Quote
g++ -c -pipe -g -Wall -W -D_REENTRANT -DDEBUG=1 -D_DEBUG=1 -I/tmp/tcloop/qt-4.x-dev/usr/local/mkspecs/linux-g++ -I../curl-test -I/usr/local/include -I. -I../curl-test -I. -o main.o ../curl-test/main.cpp
you have  -I.  and  -I../curl-test  listed twice.
The link you posted points to a  C  file but you are using  g++, shouldn't it be  gcc?
In your link command you list:
Quote
-L/usr/local/lib
which tells the linker where to look for libraries. You probably don't need paths for:
Quote
/usr/local/lib/libcurl.a /usr/local/lib/libssl.a /usr/local/lib/libssh2.a
however, I think you may have to change them to:
Code: [Select]
-lcurl -lssl -lssh2Hope some of this helps.
« Last Edit: October 01, 2011, 09:34:44 PM by Rich »

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Developping under TCE - Using curl within QTCreator
« Reply #2 on: October 01, 2011, 11:07:10 PM »
OK, in an attempt to troubleshoot this I'd like to suggest to (initially) reduce the challenge to it's most primitive form. I did this by using:
    tce-load -wi compiletc curl curl-dev
    gcc -o simple -lcurl simple.c

I then did a test to check that the code actually establishes a HTTP connection:
    tce-load -wi tcpdump
    sudo tcpdump -i eth0 & PID=$! ; ./simple ; sudo kill $PID
(which showed in my case that 17 packets were captured).

So to me that means your issue is with the IDE you choose, or probably more the project definition in question. Since this has nothing to do with TC I doubt that this is the correct forum here to seek advice for that class of problem.


Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: Developping under TCE - Using curl within QTCreator
« Reply #3 on: October 02, 2011, 12:43:10 AM »
If you must use static libraries, you indeed need to specify library deps yourself. clock_gettime for example would be in librt (-lrt).
The only barriers that can stop you are the ones you create yourself.

Offline barbudor

  • Newbie
  • *
  • Posts: 17
Re: Developping under TCE - Using curl within QTCreator
« Reply #4 on: October 02, 2011, 02:25:30 AM »
Hi

As pointed by Maro, this is mostly a IDE configuration error as I can successfully compile also using the command line.

The interesting point I see is that you only refer to curl, without the extension and you do not refer to ssl or ssh2.

Which finally let me understand that the solution was just to add "LIBS+=-lcurl" to my project

Thanks guys
tinycore 3.8.3 on HP Thin Client T5300 (Transmeta Crusoe@533MHz, 56MB RAM, 2GB Compact Flash)