开发者

Executing code examples from the Leptonica image processing library

I am trying to compile then execute the Leptonica example program 开发者_如何学Gocolorquant_reg.c

Facts:

  • OS: Ubuntu

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

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

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

  • Expected result: An executable I could use to color quantize a .tif file of mine.

  • 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 do I go about and compile this program?

  • Question 2: Is the undefined reference popping up because of me missing to include something further?

cheers


Here's what I've done:

  • 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
  • optionally, edit /home/misha/Desktop/stackoverflow/colorquant_reg.c to your liking -- it's not part of the library anymore. So I guess this is where you can add your new headers, etc.

Then, from /home/misha/Desktop/stackoverflow, I can compile the file using this 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 just for convenience -- we can now use $LIBLEPT to refer to the long pathname. The second line is what does the compilation:

  • -I tells the compiler where to look for the include files
  • -L tells the compiler where to look for the library files (for the linker)
  • -llept tells the linker to link with leptonica (it will look for liblept.so
  • -o specifies the output file, which now lives in ~/Desktop/stackoverflow/colorquant_reg.out
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜