0

I am trying to link an application with gc on Ubuntu 18.04. ld cannot find the libjasper library. I installed it manually with these commands:

sudo apt update 

sudo apt install libjasper1 libjasper-dev

but got this error:

/usr/bin/ld: cannot find -llibjasper

I tried this command to add the library but didn't work:

gcc -o cnn connected_layer.c connected_layer.h convolutional_layer.c convolutional_layer.h image.c image.h maxpool_layer.c maxpool_layer.h network.c network.h tests.c -Wall `pkg-config --cflags --libs opencv` -flto -ffast-math -L /usr/lib/x86_64-linux-gnu -l libjasper
alk
  • 69,737
  • 10
  • 105
  • 255
I. Bou
  • 1
  • 1
  • 1

1 Answers1

1

Replace

 -l libjasper

by

 -l jasper

lib is just a mandatory suffix to library files, which is ignored when specifying the name to the linker.

alk
  • 69,737
  • 10
  • 105
  • 255
  • I found two libraries using "locate jasper" in the terminal: – I. Bou Jan 25 '19 at 11:37
  • /usr/include/jasper /usr/lib/x86_64-linux-gnu/libjasper.a Which one should I use ? – I. Bou Jan 25 '19 at 11:38
  • 1
    If everything installed well, just use `-l japser`. – alk Jan 25 '19 at 11:40
  • @I.Bou "Which one should I use". The first is the directory where library's header files are, for use by the compiler. The second is the *library*, for use by the linker. You compile, then link. Both are used. – Mike Kinghan Jan 25 '19 at 16:43