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.:confused: |
Re: Library help
Quote:
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 |
Also, this thread is more suitable in the programming forum of LQ.
Dear moderator, can you plase move this thread to the programming forum? |
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. |
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. |
Re: ok
Quote:
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 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. |
wow
this is getting kind of sad
|
Re: wow
Quote:
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 |
grr
no wonder no one uses linux!
even though its good its a complete nightmare to use |
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. |
Re: grr
Quote:
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. |
All times are GMT -5. The time now is 02:13 PM. |