1

I'd like to develop code using .wav format and for that reason I need libsndfile1. I installed this using sudo apt-get install libsndfile1-dev, I included header in my program. I'm trying to compile it with this command: g++ -g -Wall -std=c++17 -lsndfile(...). Do you know why I can't compile it?

g++ -g -Wall -std=c++17 -lsndfile  -o AudioEntropy obj/main.o obj/AudioEntropy.o
obj/AudioEntropy.o: In function `SndfileHandle::SNDFILE_ref::~SNDFILE_ref()':

/usr/local/include/sndfile.hh:163: undefined reference to `sf_close'
obj/AudioEntropy.o: In function `SndfileHandle::SndfileHandle(char const*, int, int, int, int)':

/usr/local/include/sndfile.hh:181: undefined reference to `sf_open'
obj/AudioEntropy.o: In function `SndfileHandle::read(short*, long)':

/usr/local/include/sndfile.hh:332: undefined reference to `sf_read_short'
obj/AudioEntropy.o: In function `SndfileHandle::write(short const*, long)':

/usr/local/include/sndfile.hh:348: undefined reference to `sf_write_short'
collect2: error: ld returned 1 exit status

Makefile:22: recipe for target 'AudioEntropy' failed

make: *** [AudioEntropy] Error 1
Stargateur
  • 24,473
  • 8
  • 65
  • 91
kubi1000
  • 45
  • 5
  • The `-lstdfile` option should take care of these undefined references, but it is usually better put add `-l*` options after the `*.o`. Try moving that to the end of the command: `g++ -g -Wall -std=c++17 -o AudioEntropy obj/main.o obj/AudioEntropy.o -lsndfile`. – rodrigo Oct 27 '17 at 22:00
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Mike Kinghan Oct 28 '17 at 16:47
  • [Your linkage consumes libraries before the object files that refer to them](https://stackoverflow.com/a/43305704/1362568) – Mike Kinghan Oct 28 '17 at 16:49

0 Answers0