LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2004, 12:37 PM   #1
isl01jbe
LQ Newbie
 
Registered: May 2004
Distribution: Slackware
Posts: 11

Rep: Reputation: 0
c++ programming: including headers from external libraries


I'm pretty new to c++ and although i'm beginning to understand the language itself quite well i still have some problems with the following..

I'm trying to create a simple xml reader using the libxml c++ wrapper library libxml++. To include those classes i use the following include statement:

#include "libxml++.h"

and when compiling i use:

g++ -o test test.cpp -I /usr/include/libxml++-2.6/libxml++/

and the directory contains the needed libraries.

Even if i by mere chance would get this to work, I still don't know the theory requiered to make the most of it.. Can you point me in the right direction.. I guess there must be a good HOWTO somewhere on the internet, i just haven't been able to find it

Generally speaking, when trying to utilize external libraries, how should one go about including the headers?

/Jonas
 
Old 06-19-2004, 12:51 PM   #2
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
Well, to start off with, the argument to g++ is "-I/some/include/path not" "-I /some/include/path".

Allot of libraries have there own configuration script. For example, with SDL, you go like this to get the right paths and library links:

g++ `sdl-config --cflags --libs` -o mysdlprog mysdlprog.cpp

Gtk has a similar program called "gtk+-2.0-config"... I think thats what it is anyway.
All these scripts do is print the flags for gcc to stdout. Try it, at the commandline just type "sdl-config --cflags" and push enter, you'll see what I mean. If the library doesn't have a script like this, then you have to rely on the person compiling it to have the right paths set. So you usually just link "-lsomelib" and the person compiling will have to make sure the paths point to "libsomelib.so".

You should still try to use system defualts however, that way you will have a better chance of it compiling without any headaches on more systems. Example, instead of "#include <gl.h>" for OpenGL, you should always "#include <GL/gl.h>", since that is the standard for OpenGL.
 
Old 06-19-2004, 01:42 PM   #3
isl01jbe
LQ Newbie
 
Registered: May 2004
Distribution: Slackware
Posts: 11

Original Poster
Rep: Reputation: 0
Problem solved.

Thanks for the help. It's working perfectly now.
 
Old 07-20-2004, 08:06 AM   #4
Hyakutake
Member
 
Registered: Apr 2004
Location: Portugal
Distribution: Slackware
Posts: 154

Rep: Reputation: 19
Hi, i'm new to linux and opengl.
I've been trying to compile a program i made with sdl and opengl (don't know if it works or not).
to compile I use:

gcc program.c `sdl-config --cflags --libs`

but it gives an error in all of the opengl lines of code. i think it is bad referenced libraries. (Sorry not to post the error messages, i'm not at home)

should i add something like `gl-config` or something like that ??
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Qt headers and libraries not found c-- Ubuntu 12 03-03-2009 07:16 PM
QT Libraries & Headers inescapeableus Linux - Software 9 05-03-2005 01:14 AM
Including Libraries Quest101 Programming 1 01-01-2005 01:22 PM
C Programming examples including linking with Pascal chris.hicks Programming 0 11-22-2003 04:28 PM
QT-1.3 (headers and libraries) not found. p_reah Linux - Software 2 04-17-2003 07:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration