LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 03-12-2004, 07:15 AM   #1
davee
Member
 
Registered: Oct 2002
Location: Ayrshire, Scotland
Distribution: Suse(home) RHEL (Work)
Posts: 263

Rep: Reputation: 30
How to include library directories?


I'm trying a simple QT tutorial. When I try and compile my helloworld app, it has trouble including the .h files (see below). Where and how do I include the directory containing these (I think it's /opt/kde3/qt/include)...

dave@davee:~/qt> qmake -project
dave@davee:~/qt> qmake
dave@davee:~/qt> make
g++ -c -pipe -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -fPIC -DNO_DEBUG -Wall -W -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -fPIC -DNO_DEBUG -DQT_NO_DEBUG -I/usr/lib/qt3//mkspecs/default -I. -I. -I/usr/include -I/include -o main.o main.cpp
main.cpp:1:26: qapplication.h: No such file or directory
 
Old 03-12-2004, 08:50 AM   #2
cjp
Member
 
Registered: Dec 2003
Location: the Netherlands
Distribution: SuSE 9.0
Posts: 54

Rep: Reputation: 15
I don't know much about qmake & QT, but I know that make uses a file called Makefile. Try to find the -I. -I/usr/include etc. arguments in Makefile, and add "-I/opt/kde3/qt/include". That should work, but I'm not sure if Makefile is auto-generated by qmake. If that is the case, then you should check qmake's input files / configuration to make sure that it also writes this argument in newly-written Makefiles
 
Old 03-12-2004, 08:56 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,305

Rep: Reputation: 175Reputation: 175
from man make

Code:
     -Idir
          Append  directory  dir  to  the  list  of   directories
          searched for include files.
try adding -I blah/blah/include it to your CFLAGS variable.
 
Old 03-12-2004, 08:56 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,305

Rep: Reputation: 175Reputation: 175
oops! i mean 'man gcc'
 
Old 03-12-2004, 10:00 AM   #5
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
You seem to be under the impression that libraries and .h files are the same thing. Your title mentions library directories, then you ask about the directory containing .h files in the text.

A library and a .h file are NOT the same. A library contains object code that has the actual implementation of things. A .h file simply DECLARES the implementation of those things, it doesn't implement them.

So... even if you get your INCLUDE paths working, the next thing you will probably run into is linker errors because you don't have the LIBRARY paths setup. To tell the linker about a LIBRARY, you use -llibraryname and possibly -L/path/to/library if it is not in your search paths.

Sorry, if you are already aware of the distinction, but it was always a bit of a pet peeve of mine when people in my C++ classes in college would say they included a library, when what they really did was to include a header file... I think the confusion might have come from the fact that the standard C/C++ libraries are usually included by default so they never had to deal with actual libraries before.

Last edited by deiussum; 03-12-2004 at 10:03 AM.
 
Old 04-04-2004, 05:53 PM   #6
woodywellhung
Member
 
Registered: Feb 2004
Location: Lincoln, UK
Distribution: red hat 9
Posts: 67

Rep: Reputation: 15
and dont forget that -llibraryname is not the actual filename either.

i.e. if you want to link a file called libMylib.a

you would actually use

gcc -l Mylib
 
Old 04-05-2004, 03:20 AM   #7
cjp
Member
 
Registered: Dec 2003
Location: the Netherlands
Distribution: SuSE 9.0
Posts: 54

Rep: Reputation: 15
Quote:
you would actually use

gcc -l Mylib
Without the space between -l and Mylib. So, you should do this:

gcc -lMylib
 
Old 04-05-2004, 06:41 AM   #8
woodywellhung
Member
 
Registered: Feb 2004
Location: Lincoln, UK
Distribution: red hat 9
Posts: 67

Rep: Reputation: 15
Quote:
Without the space between -l and Mylib. So, you should do this:
-lMylib
should be fine with or without the space but I was taught that not having one is depreciated.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to rsync ex/include select specific directories ? dtimms Linux - Software 1 01-11-2005 06:16 AM
not able to include archived C library into my program gauravsahni Programming 4 11-15-2004 03:30 AM
Where to find/How to change .h include directories for g++ sfcesario Linux - Software 1 01-31-2004 11:12 AM
include a library in program calble Programming 1 10-09-2003 01:59 PM
Include and library path problem sadeer Linux - Software 1 11-07-2002 03:35 AM


All times are GMT -5. The time now is 06:46 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration