🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.misc
Article #2062

Re: Understanding gcc/unix

#2062
From: Juha Laiho
Date: Fri, 24 Mar 2006 18:41
48 lines
3010 bytes
Jan Danielsson <jan.danielsson@gmail.com> said:
>   I'm having some trouble understanding how to do basic things like
>compiling and linking. I have written several programs which use
>standard libraries, but as soon as I try to use custom libraries, I run
>into problems.

>   I compile (and link) with this:
>
>$ gcc -L/usr/pkg/lib -lapr-0 -I/usr/pkg/include aprtest.c

Fishy.. you pretty much should be getting linker errors from that;
the "-lapr-0" should be specified after your source files, not
before.

>   This produces an a.out file. But when I try to run ./a.out, I get this:
>
>$ ./a.out
>Shared object "libapr-0.so.0" not found
>
>   However:
>
>$ locate libapr-0.so.0
>/usr/pkg/lib/libapr-0.so.0
>/usr/pkg/lib/libapr-0.so.0.9.7
>
>   In OS/2, I would simply fix my LIBPATH. But I have no idea what I
>need to do in NetBSD to make it work. Any tips?

One-shot fix is that you add the directory into LD_LIBRARY_PATH
environment variable. I guess there's some place in NetBSD where
you could also make a permanent, global, change to the library
search path, but don't know what that would be.

>   Also, I would like to know how to make my program as portable as
>possible in unix:ish environments (with regards to the build system -- I
>already know how to write portable code). I mean, if I write a makefile
>which refers to /usr/pkg/lib/libapr-0.so, that won't be very portable. I
>assume this is what the normally-required "./configure" is for. So what
>is "./configure"?

Google for autoconf and automake (autotools might also be a viable
search term). There's quite a huge infrastructure of things behind
"configure" scripts.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
Technical Details
Message-ID: <e01egs$7ad$4@ichaos2.ichaos-int>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.volia.net!news.banetele.no!uio.no!newsfeed.kolumbus.fi!newsfeed3.funet.fi!newsfeeds.funet.fi!fi.sn.net!newsfeed2.fi.sn.net!feeder2.news.jippii.net!reader1.news.jippii.net!53ab2750!not-for-mail
References: <4423fd5b$1@griseus.its.uu.se>

Show Full Headers
Complete Article Headers
X-Google-Thread: f72b0,2e62ec248b0c5e44
X-Google-Thread: f65d0,2e62ec248b0c5e44
X-Google-Attributes: gidf72b0,gidf65d0,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.volia.net!news.banetele.no!uio.no!newsfeed.kolumbus.fi!newsfeed3.funet.fi!newsfeeds.funet.fi!fi.sn.net!newsfeed2.fi.sn.net!feeder2.news.jippii.net!reader1.news.jippii.net!53ab2750!not-for-mail
From: Juha Laiho <Juha.Laiho@iki.fi>
Newsgroups: comp.unix.misc,gnu.gcc
Subject: Re: Understanding gcc/unix
Lines: 48
Message-ID: <e01egs$7ad$4@ichaos2.ichaos-int>
References: <4423fd5b$1@griseus.its.uu.se>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Date: Fri, 24 Mar 2006 18:41:32 +0000 (UTC)
NNTP-Posting-Host: 85.76.4.218
X-Complaints-To: newsmaster@saunalahti.com
X-Trace: reader1.news.jippii.net 1143225817 85.76.4.218 (Fri, 24 Mar 2006 20:43:37 EET)
NNTP-Posting-Date: Fri, 24 Mar 2006 20:43:37 EET
Organization: Saunalahti Customer