Executing code samples from the Leptonica Image Processing Library

I am trying to compile and then run the sample program Leptonica colorquant_reg.c

Data:

  • OS: Ubuntu

  • Location: leptonlib-1.67/src/colorquant_reg.c

    (I moved it to src , since now I did not tell how to tell the compiler that the missing library file allheaders.h is in /src , and not in the original location colorquant_reg.c leptonlib-1.67/prog )

  • What I tried: gcc -I. colorquant_reg -o out gcc -I. colorquant_reg -o out

  • Expected Result: An executable file that I could use to color-quantize the .tif file.

  • Error:

     /temp/cckdQZcM.o: In function main': colorquant_reg.c:(.text+0x37: undefined reference to regTestSetup colorquant_reg.c:(.text+0xa5: undefined reference to regTestCleanup /tmp/cckdQZcM.o: In function TestImage' colorquant_reg.c:(.text+0xe0: undefined reference to pixRead 
  • Question 1: How can I compile this program?

  • Question 2: Is the link undefined due to the fact that I am absent to include something else?

amuses

+4
source share
1 answer

Here is what I did:

  • Download http://www.leptonica.com/source/leptonlib-1.67.tar.gz
  • Extract it to /home/misha/src
  • ./configure; make
  • copy prog/colorquant_reg.c to /home/misha/Desktop/stackoverflow
  • if desired, edit /home/misha/Desktop/stackoverflow/colorquant_reg.c as you wish - this is no longer part of the library. Therefore, I assume that here you can add your new headers, etc.

Then, from /home/misha/Desktop/stackoverflow , I can compile the file using the following command:

 export LIBLEPT=/home/misha/src/leptonlib-1.67/ gcc colorquant_reg.c -I$LIBLEPT/src -L$LIBLEPT/src/.libs -llept -o colorquant_reg.out 

The first line is for convenience only - now we can use $LIBLEPT to indicate a long path. The second line is what compilation does:

  • -I tells the compiler where to look for included files
  • -L tells the compiler where to look for library files (for the linker)
  • -llept tells the linker the link with leptonica (it will look for liblept.so
  • -o indicates the output file, which is now located in ~/Desktop/stackoverflow/colorquant_reg.out
+6
source

Source: https://habr.com/ru/post/1340076/


All Articles