Hi,
I have a weird problem…
I installed SDL 1.1.8 and wrote the following program:
—[CUT]—
// main.cpp
#include <stdio.h>
#include <stdlib.h>
#include “SDL.h”
int main()
{
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, “Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
printf(“blabla\n”);
return 0;
}
—[CUT]—
and the following makefile:
—[CUT]—
all: test
CPPFLAGS = -g -I/usr/include/SDL
LIBFLAGS = -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
test: main.o
g++ $(CPPFLAGS) $(LIBFLAGS) -o test main.o
%.o: %.cpp
g++ $(CPPFLAGS) -c $*.cpp
clean:
rm -f *.o
—[CUT]—
Typing make produces this:
g++ -g -I/usr/include/SDL -c main.cpp
g++ -g -I/usr/include/SDL -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
-o test main.o
main.o: In function main': /home/jakob/tmp2/main.cpp:9: undefined reference to
SDL_Init’
/home/jakob/tmp2/main.cpp:11: undefined reference to SDL_GetError' /home/jakob/tmp2/main.cpp:14: undefined reference to
SDL_Quit’
collect2: ld returned 1 exit status
make: *** [test] Error 1
Why is that?? I have tried everything, changing the order of the
$(LIBFLAGS) and adding “-L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi
-lSM -lICE -ldl -lpthread”…
Please help…–
Jakob Frandsen
Try using these lines instead and see what you get.
CPPFLAGS = -g sdl-config --cflags
LIBFLAGS = -L/usr/lib -Wl,-rpath,/usr/lib sdl-config --libs
You can run the sdl-config command by hand on a command line to see what
it is actually adding to your build lines.
JoshOn Tue, Mar 20, 2001 at 07:47:19AM -0800, Jakob Frandsen wrote:
CPPFLAGS = -g -I/usr/include/SDL
LIBFLAGS = -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
Jakob Frandsen wrote:
Hi,
I have a weird problem…
I installed SDL 1.1.8 and wrote the following program:
—[CUT]—
// main.cpp
#include <stdio.h>
#include <stdlib.h>
#include “SDL.h”
int main()
{
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, “Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
printf(“blabla\n”);
return 0;
}
—[CUT]—
and the following makefile:
—[CUT]—
all: test
CPPFLAGS = -g -I/usr/include/SDL
^^^^^^^^^^^^^^^^^
LIBFLAGS = -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
^^^^^^^^^^
Per default, SDL is installed in /usr/local/lib. You can change it to
LIBFLAGS = $(shell sdl-config --libs)
and see if it works.
Regards, Sven
Jakob Frandsen wrote:
I have a weird problem…
I installed SDL 1.1.8 and wrote the following program:
Same version I’m using.
I have the following includes – you shouldn’t need SDL_image
unless you’re using the SDL Image library. I’m not sure why
I have the SDL Endian include.
#include <SDL.h>
#include <SDL_endian.h>
#include <SDL_image.h>
—[CUT]—
[… code snips omitted …]
—[CUT]—
The Makefile looks right to me, comparing with what I’m
using.
Typing make produces this:
g++ -g -I/usr/include/SDL -c main.cpp
g++ -g -I/usr/include/SDL -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
-o test main.o
main.o: In function main': /home/jakob/tmp2/main.cpp:9: undefined reference to
SDL_Init’
/home/jakob/tmp2/main.cpp:11: undefined reference to SDL_GetError' /home/jakob/tmp2/main.cpp:14: undefined reference to
SDL_Quit’
collect2: ld returned 1 exit status
make: *** [test] Error 1
Why is that?? I have tried everything, changing the order of the
$(LIBFLAGS) and adding “-L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi
-lSM -lICE -ldl -lpthread”…
So far, the only thing I can think of is maybe the libraries aren’t
actually where they belong. Mine are in /usr/lib and include:
libSDL-1.1.so.0
libSDL-1.1.so.0.5.3
libSDL.a
libSDL.la
libSDL.so
libSDLmain.a
(some of which are probably from earlier versions, but you should
have something like this there).
Just in case, here’s the text from my makefile, which does work:#
INCLUDE = -I/usr/include/ -I/usr/include/SDL
LIBS = -L/usr/lib/ -lSDL -lSDL_image -lSGE -lpthread
automanga: automanga2.cpp
g++ $(INCLUDE) $(LIBS) automanga2.cpp -o automanga
blits: blits.c seesdl.c seesdl.h
g++ $(INCLUDE) $(LIBS) blits.c seesdl.c -o blits
–
Terry Hancock
@Terry_Hancock
Hi,
I have a weird problem…
I installed SDL 1.1.8 and wrote the following program:
—[CUT]—
// main.cpp
#include <stdio.h>
#include <stdlib.h>
#include “SDL.h”
Where is the SDL.h file located? You may want to try
#include <SDL.h>
or
#include <SDL/SDL.h>
instead of `#include “SDL.h”’ if you do not know specifically where the SDL
header files went.
An error such as this could make the following errors:On Tue, 20 Mar 2001, you wrote:
g++ -g -I/usr/include/SDL -c main.cpp
g++ -g -I/usr/include/SDL -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
-o test main.o
main.o: In function main': /home/jakob/tmp2/main.cpp:9: undefined reference to
SDL_Init’
/home/jakob/tmp2/main.cpp:11: undefined reference to SDL_GetError' /home/jakob/tmp2/main.cpp:14: undefined reference to
SDL_Quit’
collect2: ld returned 1 exit status
make: *** [test] Error 1
–
Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >
The FAQ recommends people include “SDL.h” as opposed to <SDL.h> or
<SDL/SDL.h> since it is supposed to be more portable.–
Olivier A. Dagenais - Software Architect and Developer
“Samuel Hart” wrote in message
news:01032011551202.00770 at CX114229-D…
On Tue, 20 Mar 2001, you wrote:
Hi,
I have a weird problem…
I installed SDL 1.1.8 and wrote the following program:
—[CUT]—
// main.cpp
#include <stdio.h>
#include <stdlib.h>
#include “SDL.h”
Where is the SDL.h file located? You may want to try
#include <SDL.h>
or
#include <SDL/SDL.h>
instead of `#include “SDL.h”’ if you do not know specifically where the
SDL
header files went.
An error such as this could make the following errors:
g++ -g -I/usr/include/SDL -c main.cpp
g++ -g -I/usr/include/SDL -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
-o test main.o
main.o: In function main': /home/jakob/tmp2/main.cpp:9: undefined reference to
SDL_Init’
/home/jakob/tmp2/main.cpp:11: undefined reference to SDL_GetError' /home/jakob/tmp2/main.cpp:14: undefined reference to
SDL_Quit’
collect2: ld returned 1 exit status
make: *** [test] Error 1
–
Sam “Criswell” Hart AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >
Hi,
CPPFLAGS = -g sdl-config --cflags
LIBFLAGS = -L/usr/lib -Wl,-rpath,/usr/lib sdl-config --libs
You can run the sdl-config command by hand on a command line to see what
it is actually adding to your build lines.
I already tried this…
$ sdl-config --libs
-L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
$ sdl-config --cflags
-I/usr/include/SDL -D_REENTRANT
And to no avail…
I moved the $(LIBFLAGS) to the end of the linker line though and it gave
a buttload of undefined references from the object files within libSDL…
too many to list here.–
Jakob Frandsen
Hi,
I installed SDL 1.1.8 and wrote the following program:
Same version I’m using.
Excellent.
The Makefile looks right to me, comparing with what I’m
using.
So far, the only thing I can think of is maybe the libraries aren’t
actually where they belong. Mine are in /usr/lib and include:
libSDL-1.1.so.0
libSDL-1.1.so.0.5.3
libSDL.a
libSDL.la
libSDL.so
libSDLmain.a
Mine are there too…
Just in case, here’s the text from my makefile, which does work:
INCLUDE = -I/usr/include/ -I/usr/include/SDL
LIBS = -L/usr/lib/ -lSDL -lSDL_image -lSGE -lpthread
Great, thanks… but they reveal no libSDL_image.a file or libSGE.a
file, and from your listing of SDL libraries above, I don’t understand
how it compiles on your machine…
Would it be too much to ask if you would paste my files into files on
your machine and run make to see if it compiles?–
Jakob Frandsen
g++ -g -I/usr/include/SDL -c main.cpp
g++ -g -I/usr/include/SDL -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
-o test main.o
since linking processes the arguments from left to right, you must
put the libraries after your own objects (main.o in this case)
Mattias Engdeg?rd wrote:
g++ -g -I/usr/include/SDL -c main.cpp
g++ -g -I/usr/include/SDL -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
-o test main.o
since linking processes the arguments from left to right, you must
put the libraries after your own objects (main.o in this case)
Yep, realized that, so I tried it and it gives me a heapload of
unresolved dependencies for X11, Xdga, esd, and lots more… way too
much to list here…–
Jakob Frandsen
Please help…
I fixed the problem by installing 1.1.7 instead… serves me right for
installing the latest unstable release I guess… :)–
Jakob F