Jump to content
  • Advertisement
Sign in to follow this  
matrisking

Amateur library include question

This topic is 4614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write programs using a library I have downloaded and installed. However, although I have "#include"ed the libraries (ie. #include <ga/ga.h>) just like some examples I've seen, it still doesnt find the library. I think it's because in the makefile for the examples they somehow point to my /usr/local/lib and /usr/local/include directories... or something. I don't really get makefiles or including libraries, so I'm having a tough place trying to start. So the question is: How do I get my program to "see" these libraries? Do I have to do it in a makefile, or can you specify a path in the program itself? Thanks!

Share this post


Link to post
Share on other sites
Advertisement

A couple quick questions will help us give you a hand: Are you getting compiler errors or linker errors? Can it not find the .h files or the .lib files? Also what compiler/IDE are you using?

Typically there is a setting in your development environment where you can set a list of directories for the compiler and linker to search. It's been way too long since I've used makefiles to remember where you can reference search directories. :)

Share this post


Link to post
Share on other sites
In Linux (I'm guessing from the paths in your example) and similar environments the options you need to pass to your compiler to make it work often come from another program.

For example, to use libpng, you could add `pkg-config libpng --cflags` to the options to your compiler when compiling, and `pkg-config libpng --libs` when linking.

Sometimes a library will also come with a libname-config script too, which works much the same as above.

The best place to find the answer is to check the documentation that came with the library, it probably says how to use it.

Share this post


Link to post
Share on other sites
You downloaded a library that does not provide precompiled binaries. You need to compile them yourself. In this case, the author only provides makefiles(useful on *nix variants, not so much on Windows).

However, I spent 3 seconds on the library's webpage and found this which appears to be readymade project files for a couple major compilers.
Enjoy.

This is, of course, assuming that you're using Windows and getting confused about exactly how makefiles work and why they aren't working and oh god I've included the header file but nothing is happening!

Don't panic, this happens to all Windows programmers who start digging around in open source libraries for the first time.

Share this post


Link to post
Share on other sites
haha actually I'm using linux. I've installed the library and as far as I know it copied everything to the right directories... I just don't know what they are and how to use them. I've looked at the sample programs (in fact, its what I've been basing my work on so far just to get things to compile/work. I'm using g++ to compile it and it gives me a TON of compile errors. As if its looking for functions used by the library and not finding them.

The examples use #include <ga/ga.h> and such and they work fine, but when I do it things seem to go awry, as if the program I'm using doesn't know where to find ga.h, but theirs does somehow (once again, probably because they do something in the makefile to point to the library, but not sure on that)

Share this post


Link to post
Share on other sites
Quote:
Original post by matrisking
haha actually I'm using linux. I've installed the library and as far as I know it copied everything to the right directories... I just don't know what they are and how to use them. I've looked at the sample programs (in fact, its what I've been basing my work on so far just to get things to compile/work. I'm using g++ to compile it and it gives me a TON of compile errors. As if its looking for functions used by the library and not finding them.

The examples use #include <ga/ga.h> and such and they work fine, but when I do it things seem to go awry, as if the program I'm using doesn't know where to find ga.h, but theirs does somehow (once again, probably because they do something in the makefile to point to the library, but not sure on that)


Have you read the documentation?

Share this post


Link to post
Share on other sites
Quote:
Original post by matrisking
Yup, as far as I know nothing on there corresponds to my issue. Hm.....


Well, without providing any sort of error messages or specifics, we're all sort of stuck guessing at what is wrong. I'm going to bet that you are downloading galib, #include'ing the header, and getting puzzled because things don't work.

This is, to repeat, because galib does not ship with precompiled binaries. You need to either:
a)build the source to create it's binary
or
b)include all of galib's source files and headers into your own project

If you simply try to #include the header, it will not work because there are no function definitions to match the declarations in the header.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!