LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-13-2005, 11:12 AM   #1
fisban
Newbie
 
Registered: Mar 2005
Posts: 12

Rep: Reputation: 0
Unhappy Library help


Ok Im having problems loading libraries into my programs using #include <libhere> with all non-standard libraries (like stdlib). Problem libs include sdl/libsdl and ncurses.
Im using simplymepis with the kde desktop.
 
Old 04-14-2005, 04:31 AM   #2
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Re: Library help

Quote:
Originally posted by fisban
Ok Im having problems loading libraries into my programs using #include <libhere> with all non-standard libraries (like stdlib). Problem libs include sdl/libsdl and ncurses.
Im using simplymepis with the kde desktop.
What exactly is your problem. The include command does not load a library. It includes a header file.
If you have a header file in /usr/include/something/name.h

You may include it with #include <something/name.h>
If the header is not under a standard include path, you may need to use the -I option in gcc
If you have a header is /my_headers/header.h

you need to #include <header.h>
and on compilation gcc -I/my_headers/

But by including a header you will only have the definition of a function. That does not mean that that your executables will be linked against the library were the body those functions is implemented. You need the -l (tha's a small L not a 1) to use those functions. So to develop with ncurses library you need to include <curses.h> and link the programs against libncurses.so with -lncurses (you always ommit the lib and the extension). If you get undefined reference errors , the -l is your problem.

Hope it helps

Last edited by perfect_circle; 04-14-2005 at 04:34 AM.
 
Old 04-14-2005, 04:43 AM   #3
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Also, this thread is more suitable in the programming forum of LQ.
Dear moderator, can you plase move this thread to the programming forum?
 
Old 04-14-2005, 10:06 AM   #4
MA_D
Member
 
Registered: Apr 2005
Location: Iowa
Distribution: Archlinux/RHEL/FreeBSD
Posts: 41

Rep: Reputation: 15
I'd guess you are either
1.) Forgetting that you include c libraries this way <library.h>, the key being the .h part that you disclude for ansi c++ libs.
2.) The headers aren't in /usr/include, so you have to tell g++/gcc/make where your other include dirs are. I forget how to do this, but it's not too bad.
 
Old 04-15-2005, 10:37 AM   #5
fisban
Newbie
 
Registered: Mar 2005
Posts: 12

Original Poster
Rep: Reputation: 0
ok

ive tried all the stuff you said already and it hasnt helped my. The program will not compile because the function from the librarys (non-standard) are "undefined". for example say i included sdl_initiate() during compile time gcc says something like sdl_initiate() funtion undefined.
im beginning to think asking for help from anyone is a waste of time.
 
Old 04-15-2005, 03:07 PM   #6
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Re: ok

Quote:
Originally posted by fisban
ive tried all the stuff you said already and it hasnt helped my. The program will not compile because the function from the librarys (non-standard) are "undefined". for example say i included sdl_initiate() during compile time gcc says something like sdl_initiate() funtion undefined.
im beginning to think asking for help from anyone is a waste of time.
This is a typical SDL compilation line:
Code:
gcc -DPACKAGE=\"parallax-4\" -DVERSION=\"1.0.0\"  -I. -I.     -g -O2 -I/usr/include/SDL -D_REENTRANT -c `test -f parallax4.c || echo './'`parallax4.c
gcc  -g -O2 -I/usr/include/SDL -D_REENTRANT   -o parallax4  parallax4.o  -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
DO you use -lSDL ?
Is libSDL installed?

Try to compile an SDL demo from http://olofson.net/examples.html
If it compiles you are just forgettimg something
Look at the makefiles of the demos.

Last edited by perfect_circle; 04-15-2005 at 03:09 PM.
 
Old 04-18-2005, 10:22 AM   #7
fisban
Newbie
 
Registered: Mar 2005
Posts: 12

Original Poster
Rep: Reputation: 0
wow

this is getting kind of sad
 
Old 04-18-2005, 11:23 AM   #8
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Re: wow

Quote:
Originally posted by fisban
this is getting kind of sad
What do you mean?
THats what Makefiles are for, try something like
gcc -g -O2 -I/usr/include/SDL -L/usr/lib -lSDL -lpthread your_filename.c
or
gcc -g -O2 -I/usr/local/include/SDL -L/usr/local/lib -lSDL -lpthread your_filename.c

Last edited by perfect_circle; 04-18-2005 at 11:28 AM.
 
Old 04-18-2005, 08:12 PM   #9
fisban
Newbie
 
Registered: Mar 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Exclamation grr

no wonder no one uses linux!
even though its good its a complete nightmare to use
 
Old 04-18-2005, 08:33 PM   #10
MA_D
Member
 
Registered: Apr 2005
Location: Iowa
Distribution: Archlinux/RHEL/FreeBSD
Posts: 41

Rep: Reputation: 15
Everything is a bugger to develop for. Unless you are writing PASCAL's or something else with a very complete library.
Makefiles can be a bit of a pain, but I recommend getting a program like anjuta or kdevelop to help you manage them easily. And read up on using things like pkg-config; it's not that hard once you learn it.

The same things happen on all systems; some just automate more of it for certain things.

Oh, I guess Java has the most complete library.
 
Old 05-13-2005, 02:25 PM   #11
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Re: grr

Quote:
Originally posted by fisban
no wonder no one uses linux!
even though its good its a complete nightmare to use
This is rediculous.. if you are asking for help, perhaps you should listen to what people tell you.

Are you linking in the libraries when you compile the program? Do you even know what we mean by linking in the libraries?

I am well aware you use makefiles to include things like -lSDL to your compile line... but did you write a makefile to do that?

I assure you this is not a linux problem, it is a user problem.
 
  


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
Which library ? wood@addanc Programming 3 02-20-2005 02:14 PM
adding a bulit in library to my library lg3 Linux - Software 1 10-17-2004 08:19 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM
what is the function library of the basic graphics library in rethat9.0? zerwolve Red Hat 0 04-29-2004 09:18 PM
library.. johnyy Linux - Software 2 06-23-2003 10:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:55 AM.

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