Kirjoittaja Aihe: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!  (Luettu 4419 kertaa)

Turzt

  • Käyttäjä
  • Viestejä: 6
    • Profiili
Olen jonkin aikaa jo tehnyt C++-ohjelmaa jossa yksinkertaista SDL-grafiikka (vain viivoja, ympyröitä ja tekstiä (SFont)). Aikaisemmin kaikki sujui hyvin mutta yht'äkkiä SDL lakkasi toimimasta. Kokeilin jopa kääntää sen uudelleen mutta ei auttanut. SDL kääntyy hyvin, samoin ohjelmat kääntyvät mutta ajon aikana tulee virhe. Testiohjelma on:

Koodia: [Valitse]

#include <SDL.h>

int main(void)
{
  if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    printf("ERROR at SDL_init: %s\n", SDL_GetError());
    return 1;
  }

  SDL_Surface *screen;

  screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_ANYFORMAT);

  if (screen == NULL) {
    printf("ERROR: screen init\n");
    return 1;
  }

  return 0;
}

Eli jo inittiin tyssää. Virheeksi tulee:
ERROR at SDL_init: No available video device

Kääntörivi: g++ -Wall `sdl-config --cflags --libs` -o sdltest sdltest.cc

Käytännössä ei mielestäni ole siinä välissä tehnyt mitään radikaalia kun SDL lakkasi toimimasta. Asensin totem-xinen ja jotain jotta voin katsoa DVD-elokuvia Totem playerilla.
- Koneeni n. neljä vuotta vanha AMD Athlon 2500, näytönohjain Radeon 9600 Excalibur.
- Ubuntu 7.10
- SDL 1.2.12, SDL_image-1.2.6, SDL_mixer-1.2.8

SDL asennettu ensin kääntämällä sorsat (SDL, SDL_image, SDL_mixer). Toimi mukavasti kunnes lakkasi toimimasta. Sen jälkeen poistin ne make uninstall ja kokeilin uudelleen. Näiden jälkeen vielä kokeilin sudo apt-get install libsdl-dev
Onko jollain ideoita mikä mättää tai miten lähteä liikkeelle selvittämään asioita?
SDL:n configure sanoo ajettaessa tällaista: (jos se vaikka paljastaisi jotain)

Koodia: [Valitse]
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking whether byte ordering is bigendian... no
checking for a sed that does not truncate output... /bin/sed
checking for egrep... grep -E
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for f77... no
checking for xlf... no
checking for frt... no
checking for pgf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for f90... no
checking for xlf90... no
checking for pgf90... no
checking for epcf90... no
checking for f95... no
checking for fort... no
checking for xlf95... no
checking for ifc... no
checking for efc... no
checking for pgf95... no
checking for lf95... no
checking for gfortran... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether  accepts -g... no
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
appending configuration tag "F77" to libtool
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ANSI C... (cached) none needed
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... yes
checking for windres... no
checking for linux-gnu-windres... no
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for working volatile... yes
checking for ANSI C header files... (cached) yes
checking for sys/types.h... (cached) yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for stdlib.h... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking stdarg.h usability... yes
checking stdarg.h presence... yes
checking for stdarg.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for memory.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking ctype.h usability... yes
checking ctype.h presence... yes
checking for ctype.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for size_t... yes
checking for int64_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for working memcmp... yes
checking for working strtod... yes
checking for malloc... yes
checking for calloc... yes
checking for realloc... yes
checking for free... yes
checking for getenv... yes
checking for putenv... yes
checking for unsetenv... yes
checking for qsort... yes
checking for abs... yes
checking for bcopy... yes
checking for memset... yes
checking for memcpy... yes
checking for memmove... yes
checking for strlen... yes
checking for strlcpy... no
checking for strlcat... no
checking for strdup... yes
checking for _strrev... no
checking for _strupr... no
checking for _strlwr... no
checking for strchr... yes
checking for strrchr... yes
checking for strstr... yes
checking for itoa... no
checking for _ltoa... no
checking for _uitoa... no
checking for _ultoa... no
checking for strtol... yes
checking for strtoul... yes
checking for _i64toa... no
checking for _ui64toa... no
checking for strtoll... yes
checking for strtoull... yes
checking for atoi... yes
checking for atof... yes
checking for strcmp... yes
checking for strncmp... yes
checking for _stricmp... no
checking for strcasecmp... yes
checking for _strnicmp... no
checking for strncasecmp... yes
checking for sscanf... yes
checking for snprintf... yes
checking for vsnprintf... yes
checking for iconv... yes
checking for sigaction... yes
checking for setjmp... yes
checking for nanosleep... yes
checking for libiconv_open in -liconv... no
checking for pow in -lm... yes
checking for GCC -fvisibility=hidden option... yes
checking for dlopen... yes
checking for dlopen in -lc... no
checking for dlopen in -ldl... yes
checking for dlvsym in -ldl... yes
checking for yasm... no
checking to see if  supports unquoted-sections... no
checking for nasm... no
checking altivec.h usability... no
checking altivec.h presence... no
checking for altivec.h... no
checking for Altivec with GCC -maltivec option... no
checking for Altivec with GCC -faltivec option... no
checking for OSS audio support... yes
checking for dmedia audio support... no
checking for ALSA CFLAGS...
checking for ALSA LDFLAGS...  -lasound -lm -ldl -lpthread
checking for libasound headers version >= 0.9.0... not present.
checking for snd_ctl_open in -lasound... no
checking for artsc-config... no
checking for esd-config... no
checking for ESD - version >= 0.2.8... no
*** The esd-config script installed by ESD could not be found
*** If ESD was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the ESD_CONFIG environment variable to the
*** full path to esd-config.
checking for pkg-config... /usr/bin/pkg-config
checking for PulseAudio 0.9 support... no
checking audio/audiolib.h usability... no
checking audio/audiolib.h presence... no
checking for audio/audiolib.h... no
checking for AuOpenServer in -laudio... no
checking nas/audiolib.h usability... no
checking nas/audiolib.h presence... no
checking for nas/audiolib.h... no
checking for AuOpenServer in -lnas... no
checking for NAS audio support... no
checking for X... no
checking for framebuffer console support... yes
checking for getpagesize... yes
checking for directfb-config... no
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for DirectFB 0.9.15 support... no
checking for PlayStation 2 GS support... no
checking for SVGAlib (1.4.0+) support... no
checking for libVGL support... no
checking for wscons support... no
checking for OpenGL (GLX) support... yes
checking for Linux 2.4 unified input interface... yes
checking for Touchscreen library support... no
checking for hid_init in -lusbhid... no
checking usb.h usability... no
checking usb.h presence... no
checking for usb.h... no
checking libusb.h usability... no
checking libusb.h presence... no
checking for libusb.h... no
checking for hid_init in -lusb... no
checking for usbhid... no
checking for pthreads... yes
checking for recursive mutexes... yes
checking for pthread semaphores... yes
checking linux/version.h usability... yes
checking linux/version.h presence... yes
checking for linux/version.h... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sdl-config
config.status: creating SDL.spec
config.status: creating SDL.qpg
config.status: creating sdl.pc
config.status: creating include/SDL_config.h
config.status: executing default commands
Generating dependencies for ./src/SDL.c
ja paljon lisää generating depencies -rivejä...

pulis

  • Käyttäjä
  • Viestejä: 242
    • Profiili
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #1 : 11.01.08 - klo:16.24 »
enpä tiedä-- koodissa ei mitään vikaa.
kokeile vaikka tarkistaa näyttiksen ajurit ja xorg.conf ??

peran

  • Vieras
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #2 : 11.01.08 - klo:20.01 »
Taitaa järjestelmääsi nähden olla kuun asento väärä tai auringonpilkut häiritsevät järjestelmäsi toimintaa.

Boottaamistakin kannattaa harkita, josko kuu menisi oikeaan asentoon.

Turzt

  • Käyttäjä
  • Viestejä: 6
    • Profiili
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #3 : 15.01.08 - klo:13.10 »
Tuskin pystyy minun koneen buuttaamisella ohjaamaan kuun asentoa. Minun muutaman vuoden vanhassa koneessa ei ole vielä niin voimallisia ominaisuuksia. Pitänee kysyä engelsmannien foorumilta josko siellä olisi joku törmännyt vastaavaan ongelmaan.

larpa

  • Vieras
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #4 : 15.01.08 - klo:14.02 »
Juu, itekkin yrittelin käännellä samantyylistä SDL juttua, mutta ei onnistunu.
Tuntuu, että SDL:lle pitää tehdä jotain erityistä, että sen saa kunnolla toimimaan  ??? .
Ohjelmointi gurut voivat tietenkin sanoa: et vain osaa  :-[

olasirtep

  • Käyttäjä
  • Viestejä: 91
    • Profiili
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #5 : 15.01.08 - klo:16.38 »
Pitipä itse kokeilla ja toimi seuraavasti:
Koodia: [Valitse]
#include <SDL/SDL.h>

int main(void)
{
  if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    printf("ERROR at SDL_init: %s\n", SDL_GetError());
    return 1;
  }

  SDL_Surface *screen;

  screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_ANYFORMAT);

  if (screen == NULL) {
    printf("ERROR: screen init\n");
    return 1;
  }

  return 0;
}

Kääntämistä varten asennettuna paketit build-essential ja libsdl1.2-dev. Käänsin ohjelman komennolla
Koodia: [Valitse]
g++ -o sdl_test sdl_test.cc -lSDL
"The Internet is running too slow. Could you reboot it please?"

larpa

  • Vieras
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #6 : 16.01.08 - klo:14.39 »
Juu, kyllä tuo toimii...
Se tuossa sdl-kääntämisessä on, että pitää muistaa tuo -lSDL.

larpa

  • Vieras
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #7 : 18.01.08 - klo:00.26 »
offtopic:
Mitä seuraava tarkoittaa?

g++ -o peli peli.cpp -lSDL
chmod +x peli
./peli
Segmentation fault (core dumped)
--------------------
Aiempi käännös meni ihan ok, nyt hieman lisää koodia.
« Viimeksi muokattu: 18.01.08 - klo:00.29 kirjoittanut larpa »

tn

  • Käyttäjä
  • Viestejä: 472
    • Profiili
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #8 : 18.01.08 - klo:15.30 »
Mitä seuraava tarkoittaa?
...
Segmentation fault (core dumped)

Mitä luultavimmin sitä, että yrität käsitellä ohjelmassa varaamatonta (tai jo vapautettua) muistialuetta / jotain osoitinta ei ole alustettu.

Turzt

  • Käyttäjä
  • Viestejä: 6
    • Profiili
Vs: SDL antaa virheilmoituksen C++-ohjelmaa ajettaessa!
« Vastaus #9 : 19.01.08 - klo:15.57 »
Edelleenkään ei toimi. Uskoisin kyllä että itse kirjaston asennus on onnistunut mutta jossain muissa näyttö/grafiikka yms asetuksissa on jotain pielessä. Mitähän tuo SDL_Init(SDL_INIT_VIDEO) oikein käytännössä sitten tekee kun se kerran toteaa ettei ole availablena video deviceä. Eli mitä se oikein käytännössä etsii? Onko joku tutustunut SDL:n sielunelämään?