SiegeLord / RustAllegro

A Rust wrapper and bindings of Allegro 5 game programming library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to pass custom directory with libraries?

CapSel opened this issue · comments

I have allegro installed in ~/libs/root/ directory - not as a system library. I've few other libraries there.
I already passed ALLEGRO_INCLUDE_DIR=/home/capsel/libs/root/include. I can't find a way to pass /home/capsel/libs/root/lib as a directory with libraries - similar to CFLAGS="-L/home/capsel/libs/root/lib".

Is there a way to do it?

The way I do it in my projects is that for the final binary I have a build script, like so:

use std::env::var;

fn main()
{
	if let Ok(path) = var("ALLEGRO_LINK_PATH")
	{
		println!("cargo:rustc-flags=-L {}", path);
	}
}

I suppose it may make sense to put this feature inside RustAllegro instead. I'll think about it.

How about using pkg-config?
Allegro library installs *.pc files (you probably are aware of that), there is pkg_config crate in rust.

Also I've found out that allegro libraries installed with cmake+make install have different naming scheme than in your build.rs - debug should go before static, and there is "-5" postfix in pkg_config files.

Also I've found out that allegro libraries installed with cmake+make install have different naming scheme than in your build.rs - debug should go before static

Thanks for that, it is now fixed.

I decided to add that ALLEGRO_LINK_DIR environment variable. The pkg-config idea is good, but it doesn't work on Windows which is where these things are most useful to begin with. I'll file an issue for pkg-config though.