NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Custom pet projects compiling for NetBSD n00bs
On 08/01/2021 13:03, Lord Vader wrote:
I'm trying to compile my pet C project under NetBSD (using 9.1 in i386
flavour).
Specifically, I need libpng and libconfig. Both are installed using
pkg_add, both seem to have .so and includes under /usr/pkg path.
Then, when I try to compile my code simply as gcc -c filename.c
filename.o, it fails at #include <png.h>.
Further examination of gcc with `gcc -xc -E -v -` shows it doesn't have
default include path that point into /usr/pkg/include
I managed to add them via -I or via CPATH env var, then I've managed to
do the same for linking via -L or LIBRARY_PATH, then I even got the
executable. Which again was unable to find .so under the /ust/pkg/lib ,
unless I also use LD_LIBRARY_PATH for running it.
I have experience with different linux distros, including ubuntu and
gentoo where everything seems to work off-the-box (provided I `apt
install` or `emerge` appropriate packages), but here I fail and probably
I do smth terribly wrong.
Any suggestions?
That's because linux dumps everything in /usr/lib whereas only system
libraries live there on NetBSD.
The linker option you need is -rpath=/usr/pkg/lib.
So you can do:
cc -o myprojects myfile.o -L/usr/pkg/lib -Wl,-rpath=/usr/pkg/lib -lpng
-lconfig
You can specify a path in /etc/ld.so.conf but using rpath is how pkgsrc
packages normally do this.
Mike
Home |
Main Index |
Thread Index |
Old Index