# OT: compilation probs (later extension)

**URL:** <https://www.ruby-forum.com/t/ot-compilation-probs-later-extension/68586>\
**Category:** Ruby\
**Created:** [September 13, 2006, 7:33pm UTC](https://www.ruby-forum.com/t/ot-compilation-probs-later-extension/68586 "2006-09-13T19:33:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugh\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hugh\_S](https://www.ruby-forum.com/u/Hugh_S)\
**Post date:** [September 13, 2006, 7:33pm UTC](https://www.ruby-forum.com/t/ot-compilation-probs-later-extension/68586/1 "2006-09-13T19:33:58Z")

</div>

This is somewhat OT for Ruby-Talk, but I want to build this against  
Ruby later, and Ruby is built with GCC. I suppose I could make  
another one built with Sun’s cc, put it somewhere else, but I’d  
consider that a violation of DRY.

Anyway, my question which I’ve been wrestling with for over a week, and  
which help from the gcc-help list hasn’t solved for me, is:

Compiling my application (which uses FFTW 3.1) with the Sun cc works,  
and I get an executable, but compiling it with gcc I get errors of  
the form:

```
    [...]

```

gcc -R/usr/local/lib -g -I/usr/local/include -z verbose -z rescan  
-L/progs/SUNWspro/lib:/usr/local/lib:/usr/local/lib/sparcv9:/usr/lib:/usr/share/lib:/usr/dt/lib:/usr/openwin/lib:/opt/panorama/lib:/opt/sfw/lib  
-lfftw3 -lm -ll -lpng -lz -o fsv fsv.o fft\_2d\_filter.o y.tab.o   
lex.yy.o  
fft\_2d\_filter.o: In function `fft_2d_forward': /home/hgs/fsv/fft_2d_filter.c:30: undefined reference to`fftw\_plan\_dft\_r2c\_2d’  
/home/hgs/fsv/fft\_2d\_filter.c:31: undefined reference to `fftw_execute' fft_2d_filter.o: In function`fft\_2d\_inverse’:  
[…]  
collect2: ld returned 1 exit status  
gmake: \*\*\* [fsv] Error 1

The fftw3 library exists, as do the png libraries, I recently tried  
adding  
the -R option into the build of fftw3 so that the paths to the libraries  
would get built in, but I get the same errors anyway.

I thought my libraries might be in the wrong order, and putting -lz  
after  
-lpng got rid of the errors like:

/usr/local/lib/gcc/sparc-sun-solaris2.9/4.1.0/…/…/…/libpng.so:  
undefined reference to `deflate' /usr/local/lib/gcc/sparc-sun-solaris2.9/4.1.0/../../../libpng.so: undefined reference to`inflate’  
[…]

I don’t really know how to get that right in future. I tried using  
lorder and tsort but that produces a huge amount of output (in  
/usr/local/lib):

bash-2.05$ ls lib{fftw\*,z\*,png\*} | xargs lorder | tsort |wc  
/usr/ccs/bin/nm: libfftw3.la: invalid file type  
352 352 3946  
bash-2.05$

Can anyone help me out with this, or have I entered a really obscure  
area of C programming?

Sorry for the OT nature of this, but I want to get to the bottom of  
this, or I’m just “programming by coincidence”. The difference  
between witchcraft and science… There is no fftw3 list, which is  
hardly an excuse.

```
    Thank you,
    Hugh
```

---

<div class="post-metadata">

**Author:** ![Hugh\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hugh\_S](https://www.ruby-forum.com/u/Hugh_S)\
**Post date:** [September 13, 2006, 8:26pm UTC](https://www.ruby-forum.com/t/ot-compilation-probs-later-extension/68586/2 "2006-09-13T20:26:03Z")

</div>

Hi,

At Thu, 14 Sep 2006 02:32:33 +0900,  
Hugh S. wrote in [ruby-talk:214307]:

> gcc -R/usr/local/lib -g -I/usr/local/include -z verbose -z rescan -L/progs/SUNWspro/lib:/usr/local/lib:/usr/local/lib/sparcv9:/usr/lib:/usr/share/lib:/usr/dt/lib:/usr/openwin/lib:/opt/panorama/lib:/opt/sfw/lib -lfftw3 -lm -ll -lpng -lz -o fsv fsv.o fft\_2d\_filter.o y.tab.o   
> lex.yy.o  
> fft\_2d\_filter.o: In function `fft_2d_forward': /home/hgs/fsv/fft_2d_filter.c:30: undefined reference to`fftw\_plan\_dft\_r2c\_2d’  
> /home/hgs/fsv/fft\_2d\_filter.c:31: undefined reference to `fftw_execute' fft_2d_filter.o: In function`fft\_2d\_inverse’:  
> […]  
> collect2: ld returned 1 exit status  
> gmake: \*\*\* [fsv] Error 1

Move -l options after \*.o.
