Compiling with cairo (closed)

8 posts / 0 new
Last post
YesCop
YesCop's picture
Offline
Last seen: 3 years 7 months ago
Joined: 2011-05-17 15:07
Compiling with cairo (closed)

Hi,
It may be a dumb question for someones here. I tested various things but I don't knwow how to compile a very simple program using Cairo.
This program has a few lines and one only include .
I tested what follows with no success.

gcc -o test test.c
gcc -o stroke -I/SDK/local/newlib/include/cairo -I/SDK/local/common/include/cairo -L/SDK/local/newlib/lib -lcairo stroke.c

In my configuration, there is no cairo include in newlib but I put it because pkg-confif told me :
pkg-config --cflags --libs cairo
-I/SDK/local/newlib/include/cairo -L/SDK/local/newlib/lib -lcairo

Any ideas ?

YesCop

PS: I examined a little sdk and I think some files are missing or may be they are at wrong places.
May I wait for sdk 4.1.3?

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
Well there are a few things

Well there are a few things you are doing wrong. First you don't need to add /SDK/local/newlib/lib to the library search path unless your SDK installation is broken in some way. Second link libraries should come after the files or libraries that depends on them (since you have listed -lcairo before stroke.c it means that nothing from libcairo will be linked into your program). Third libcairo depends on various other libraries that you haven't linked with.

This is the Makefile that I use for libsvgtiny/libcairo program:

  1. CC := ppc-amigaos-gcc -mcrt=newlib
  2. RM := rm -f
  3.  
  4. CFLAGS := -O2 -Wall -I/SDK/local/common/include/libxml2 -I/SDK/local/common/include/cairo
  5. LDFLAGS := -use-dynld
  6. LIBS := -lsvgtiny -lxml2 -lcairo -lpixman-1 -lpng12 -lz -lfreetype -lfontconfig -lexpat -lpthread -lauto
  7.  
  8. showsvg: showsvg.o
  9. $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
  10.  
  11. clean:
  12. $(RM) showsvg showsvg.o

A modified version to compile your stroke.c program could probably be something like:

  1. CC := ppc-amigaos-gcc -mcrt=newlib
  2. RM := rm -f
  3.  
  4. CFLAGS := -O2 -Wall -I/SDK/local/common/include/cairo
  5. LDFLAGS := -use-dynld
  6. LIBS := -lcairo -lpixman-1 -lpng12 -lz -lfreetype -lfontconfig -lexpat -lpthread
  7.  
  8. stroke: stroke.o
  9. $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
  10.  
  11. clean:
  12. $(RM) stroke stroke.o
YesCop
YesCop's picture
Offline
Last seen: 3 years 7 months ago
Joined: 2011-05-17 15:07
Hi Salass, Yes I knew that

Hi Salass,

Yes I knew that the order of the libraries are false but I had tempted so much things...
I tested your makefile but I obtain the same errors in link stage :

ld: warning: libpng.so, needed by /SDK/local/newlib/lib/libcairo.so, not found (try using -rpath or -rpath-link)
ld: warning: libz.so, needed by /SDK/local/newlib/lib/libcairo.so, not found (try using -rpath or -rpath-link)

Of course the sobjs are in /sdk/local/newlib/lib, may I precise that these are links to SOBJS: assign. I don't use libpng12 but libpng (link to version 15).

I tried to use -rpath with directories but I have an error "directories don't exist..."
I google to find clue in vain. So I come back here.
I hope you could find a solution.
"You are my only hope", well that remembers me something...

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
IIRC it says the same things

IIRC it says the same things for me as well. Note that they're just warnings, not errors, so it still produces the executable, which still works at least for me. You should link with libpng12 and not any newer version as this is the version that libcairo expects and IIRC only version it will work with.

YesCop
YesCop's picture
Offline
Last seen: 3 years 7 months ago
Joined: 2011-05-17 15:07
Well, I didn't tell you all

Well, I didn't tell you all the thruth !!
I have an error after the warning :
/SDK/local/newlib/lib/libcairo.so: undefined reference to `png_set_gray_1_2_4_to_8'
make: *** [stroke] Error 1

Could you tell me where I vould find libpng12 or could you send to me ?
In aminet there is a version containing only the static version and on os4depot, the link is broken (from sbojs link).

Thanks

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
If you have the latest OS4.1

If you have the latest OS4.1 version installed you should have libpng12.so in SOBJS:. Also there should be a soft link to it in SDK:local/newlib/lib (if there isn't just copy the file there from SYS:SObjs).

The undefined reference is because cairo uses a function that was removed from newer libpng versions.

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
There's also an updated

There's also an updated libpng12.so in NetSurf archive:
http://aminet.net/package/comm/www/netsurf

YesCop
YesCop's picture
Offline
Last seen: 3 years 7 months ago
Joined: 2011-05-17 15:07
Salass, Well now it compiles

Salass,

Well now it compiles with always the warnings.
I closed the thread and open a new one.

Log in or register to post comments