You are not logged in.

#1 2010-01-12 21:12:09

Neheb
Member
From: Norway
Registered: 2009-05-23
Posts: 39

C/C++ detecting available libraries

Anyone know if there is a way in C/C++ to check if a particular library (in this case glu) is used to compile?

Offline

#2 2010-01-12 21:56:56

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,398
Website

Re: C/C++ detecting available libraries

autoconf/automake?

Offline

#3 2010-01-12 23:33:17

Neheb
Member
From: Norway
Registered: 2009-05-23
Posts: 39

Re: C/C++ detecting available libraries

I was thinking about in the source files, with #ifdef or something like it

Offline

#4 2010-01-13 06:29:53

caelestis
Member
Registered: 2009-04-04
Posts: 88

Re: C/C++ detecting available libraries

Includes with quotes around them? Linker flags? Include directories?

...

Offline

#5 2010-01-13 20:58:47

e_tank
Member
Registered: 2006-12-21
Posts: 80

Re: C/C++ detecting available libraries

autoconf/automake can do just that, ie check which libraries are available prior to compiling and generate a header file with defines that you include in your source files so you can use #ifdef lib_X.

i don't have much experience with autoconf/automake so i'm not sure how to accomplish this but i know i've seen it done in projects i've tinkered with.  i would assume cmake can do this as well, although i've never used it other than to build some software from source i've heard it's much easier to pick up than autoconf/automake, so you may want to look into that first.

Offline

#6 2010-01-14 07:49:21

PJ
Member
From: Sweden
Registered: 2005-10-11
Posts: 602

Re: C/C++ detecting available libraries

SCons can detect libraries.

Offline

#7 2010-01-16 14:48:35

Lexion
Member
Registered: 2008-03-23
Posts: 510

Re: C/C++ detecting available libraries

If the libraries use define gaurds, then you can do an #ifdef __FOO_H or whatever it is. Autoconf does do what you want, but you can probably put a similar check in a makefile.


urxvtc / wmii / zsh / configs / onebluecat.net
Arch will not hold your hand

Offline

#8 2010-01-24 13:57:58

Mad Fish
Member
Registered: 2009-09-22
Posts: 295

Re: C/C++ detecting available libraries

Use CMake and it's find_package().

Offline

#9 2010-01-24 14:37:27

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: C/C++ detecting available libraries

You can't tell at compile time what is going to happen at link time. You also can't find out at compile time if a particular set of header files is around. It's too bad C/C++ doesn't have some kind of "conditional" include that says to include a file if it exists. You just have to use configure or CMake to find out before the user compiles your code.

Offline

Board footer

Powered by FluxBB