RWAP / PrinterToPDF

Project for converting captured printer data files to PDF format
GNU General Public License v3.0
85 stars 19 forks source link

Problem compiling PrinterConvert.c #1

Closed Mike-DE-RE closed 7 years ago

Mike-DE-RE commented 7 years ago

Hi Rich.

Thank you very much for this project. I tried to play with it a bit, but cannot compile the file. I had to install SDL devel and amend

include "SDL.h"

to

include "/usr/include/SDL/SDL.h"

Trying to compile now I get

PrinterConvert.c: In function ‘putpixel’: PrinterConvert.c:335: warning: comparison between pointer and integer PrinterConvert.c: In function ‘putpixelbig’: PrinterConvert.c:379: error: ‘display’ undeclared (first use in this function) PrinterConvert.c:379: error: (Each undeclared identifier is reported only once PrinterConvert.c:379: error: for each function it appears in.)

Did I miss something? How can I get that to work?

Regards

Michael

RWAP commented 7 years ago

OK - I have corrected the issue on line 379 (SDL_Surface *display; was declared too late in the file)

I wonder if line 335 (now line 337) should be if (*p == 255) {

I think it should but I am still making a few mistakes in C !

Mike-DE-RE commented 7 years ago

Oops!

gcc PrinterConvert.c -o example PrinterConvert.c: In function ‘putpixel’: PrinterConvert.c:337: warning: comparison between pointer and integer /tmp/ccqU6iOK.o: In function _tiff_delta_printing': PrinterConvert.c:(.text+0xeba): undefined reference toclock_gettime' PrinterConvert.c:(.text+0xeea): undefined reference to clock_gettime' PrinterConvert.c:(.text+0xf70): undefined reference toclock_gettime' PrinterConvert.c:(.text+0xfa0): undefined reference to clock_gettime' PrinterConvert.c:(.text+0x100b): undefined reference toclock_gettime' /tmp/ccqU6iOK.o:PrinterConvert.c:(.text+0x103b): more undefined references to c lock_gettime' follow /tmp/ccqU6iOK.o: In functionprint_character': PrinterConvert.c:(.text+0x4b3d): undefined reference to SDL_UpdateRect' /tmp/ccqU6iOK.o: In functionmain': PrinterConvert.c:(.text+0x5971): undefined reference to initialize' PrinterConvert.c:(.text+0x5a44): undefined reference toSDL_Init' PrinterConvert.c:(.text+0x5aed): undefined reference to SDL_SetVideoMode' PrinterConvert.c:(.text+0x5b27): undefined reference toSDL_WM_SetCaption' PrinterConvert.c:(.text+0x5b59): undefined reference to SDL_UpdateRect' PrinterConvert.c:(.text+0x9c15): undefined reference toSDL_UpdateRect' PrinterConvert.c:(.text+0x9c58): undefined reference to `SDL_UpdateRect' collect2: ld returned 1 exit status

Do I have to install other SDL libs?

I think it should but I am still making a few mistakes in C !

Better than I could. ;-)

RWAP commented 7 years ago

Are you compiling this on Linux or Windows?

clock_gettime is a standard Linux library - this does not appear to be available under Windows - but a function to provide this appears at http://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows

Again, on Linux, we only needed to call SDL.h - I am not sure what SDL libs you would need to install on Windows....

I have at least corrected the warning on line 337 now.

Mike-DE-RE commented 7 years ago

No, I am not on Windows. ;-)

Pure Linux.

RWAP commented 7 years ago

Hmm - according to http://stackoverflow.com/questions/2418157/ubuntu-linux-c-error-undefined-reference-to-clock-gettime-and-clock-settim you might not have glibc v2.17 (which has clock_gettime() built in)

It also looks as though you have SDL v2.0+ which lacks the commands we used (from SDL v1.2) so that would explain the other SDL_xxx errors - see https://wiki.libsdl.org/MigrationGuide

Perhaps you could look for SDL v1.2 for now - probably because the Raspberry Pi we have developed the code for does not have v2.0+ yet

Mike-DE-RE commented 7 years ago

I will check that tomorrow and let you know.

Have a nice evening.

Michael

Mike-DE-RE commented 7 years ago

The system on which I am trying this is a little older, so it should compile PrinterConvert.c.

Here is what I find:

you might not have glibc v2.17

rpm -qa | grep "glibc" glibc-2.8-14.2 glibc-locale-2.8-14.2 glibc-i18ndata-2.8-14.2 glibc-devel-2.8-14.2

the commands we used (from SDL v1.2)

rpm -qa | grep "SDL" SDL_net-1.2.7-99.1 SDL_image-1.2.6-101.1 SDL_mixer-1.2.8-100.1 SDL-devel-1.2.13-51.1 SDL-1.2.13-51.1 SDL_ttf-2.0.9-99.1 SDL_perl-2.1.3-27.1

So as far as I see there should be not problem.

Mike-DE-RE commented 7 years ago

When using

gcc PrinterConvert.c -o test -lSDL

the list of errors is shortens:

PrinterConvert.c: In function ‘putpixel’: PrinterConvert.c:337: warning: comparison between pointer and integer /tmp/cc318gGr.o: In function _tiff_delta_printing': PrinterConvert.c:(.text+0xeba): undefined reference toclock_gettime' PrinterConvert.c:(.text+0xeea): undefined reference to clock_gettime' PrinterConvert.c:(.text+0xf70): undefined reference toclock_gettime' PrinterConvert.c:(.text+0xfa0): undefined reference to clock_gettime' PrinterConvert.c:(.text+0x100b): undefined reference toclock_gettime' /tmp/cc318gGr.o:PrinterConvert.c:(.text+0x103b): more undefined references to clock_gettime' follow /tmp/cc318gGr.o: In functionmain': PrinterConvert.c:(.text+0x5971): undefined reference to `initialize' collect2: ld returned 1 exit status

Mike-DE-RE commented 7 years ago

Using your latest code I get

gcc PrinterConvert.c -o example -lSDL

/tmp/ccbSvAbS.o: In function _tiff_delta_printing': PrinterConvert.c:(.text+0xec3): undefined reference toclock_gettime' PrinterConvert.c:(.text+0xef3): undefined reference to clock_gettime' PrinterConvert.c:(.text+0xf79): undefined reference toclock_gettime' PrinterConvert.c:(.text+0xfa9): undefined reference to clock_gettime' PrinterConvert.c:(.text+0x1014): undefined reference toclock_gettime' /tmp/ccbSvAbS.o:PrinterConvert.c:(.text+0x1044): more undefined references to `clock_gettime' follow collect2: ld returned 1 exit status

RWAP commented 7 years ago

Dare I ask what changed on your system since yesterday (to remove the SDL_xx errors?)

The clock_gettime needs glibc v2.17 so you will need to update that to the latest version

Mike-DE-RE commented 7 years ago

gcc PrinterConvert.c -o example -lSDL -lrt

solved above problems, see

http://stackoverflow.com/questions/2418157/ubuntu-linux-c-error-undefined-reference-to-clock-gettime-and-clock-settim

Mike-DE-RE commented 7 years ago

Dare I ask what changed on your system since yesterday (to remove the SDL_xx errors?)

-lSDL

The clock_gettime needs glibc v2.17 so you will need to update that to the latest version

-lrt

... still learning! ;-)

Mike-DE-RE commented 7 years ago

... and I have to set

include "/usr/include/SDL/SDL.h"

otherwise I get a lot of errors:

PrinterConvert.c:6:17: error: SDL.h: Datei oder Verzeichnis nicht gefunden PrinterConvert.c:90: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘’ token PrinterConvert.c:284: error: expected ‘)’ before ‘’ token PrinterConvert.c: In function ‘putpixelbig’: PrinterConvert.c:387: error: ‘display’ undeclared (first use in this function) PrinterConvert.c:387: error: (Each undeclared identifier is reported only once PrinterConvert.c:387: error: for each function it appears in.) PrinterConvert.c: In function ‘erasesdl’: PrinterConvert.c:451: error: ‘display’ undeclared (first use in this function) PrinterConvert.c: In function ‘print_character’: PrinterConvert.c:1590: error: ‘display’ undeclared (first use in this function) PrinterConvert.c: In function ‘main’: PrinterConvert.c:1915: error: ‘SDL_INIT_VIDEO’ undeclared (first use in this function) PrinterConvert.c:1925: error: ‘display’ undeclared (first use in this function) PrinterConvert.c:1925: error: ‘SDL_HWSURFACE’ undeclared (first use in this function)

RWAP commented 7 years ago

Great - I have added a note to the readme.md file (and PrinterConvert.c vis-a-vis the sdl.h file)

It obviously depends on the version of gcc and Linux being used!