<div dir="ltr">Ok it's getting stranger and stranger.<br>I tried to comment or delete the av_calloc calls in rematrix.c, and it gave the same error.<div>Now, i'm not an expert programmer, but if I change the line that the compiler says causes the problem,</div><div>the output should change. I can only think now, that the problem is inside libswresample.a  </div><div class="gmail_extra"><br><div class="gmail_quote">2015-08-08 16:42 GMT+02:00 Davide Caresia <span dir="ltr"><<a href="mailto:caresia.davide@gmail.com" target="_blank">caresia.davide@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">No luck even with that order. <div><br></div><div><span class=""><div>"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf</div><div>make[1]: ingresso nella directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"</div><div>"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/audiosync</div><div>make[2]: ingresso nella directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"</div><div>mkdir -p build/Debug/GNU-Linux-x86</div><div>rm -f "build/Debug/GNU-Linux-x86/dataReader.o.d"</div><div>g++    -c -g -MMD -MP -MF "build/Debug/GNU-Linux-x86/dataReader.o.d" -o build/Debug/GNU-Linux-x86/dataReader.o dataReader.cpp</div><div>mkdir -p dist/Debug/GNU-Linux-x86</div></span><div>g++ -o dist/Debug/GNU-Linux-x86/audiosync build/Debug/GNU-Linux-x86/dataReader.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/tansforms.o build/Debug/GNU-Linux-x86/tognuplot.o  -lavformat -lavcodec -lswresample -lavutil -lz -lm -llzma -lfftw3</div><span class=""><div>/usr/local/lib/libswresample.a(rematrix.o): nella funzione "swri_rematrix_init":</div><div>/home/davide/Documenti/Tesi/Libraries/ffmpeg/ffmpeg-2.7.2/libswresample/rematrix.c:365: riferimento non definito a "av_calloc"</div><div>/home/davide/Documenti/Tesi/Libraries/ffmpeg/ffmpeg-2.7.2/libswresample/rematrix.c:377: riferimento non definito a "av_calloc"</div><div>/home/davide/Documenti/Tesi/Libraries/ffmpeg/ffmpeg-2.7.2/libswresample/rematrix.c:389: riferimento non definito a "av_calloc"</div><div>/usr/local/lib/libswresample.a(resample.o): nella funzione "resample_init":</div><div>/home/davide/Documenti/Tesi/Libraries/ffmpeg/ffmpeg-2.7.2/libswresample/resample.c:220: riferimento non definito a "av_calloc"</div><div>collect2: error: ld returned 1 exit status</div><div>nbproject/Makefile-Debug.mk:65: set di istruzioni per l'obiettivo "dist/Debug/GNU-Linux-x86/audiosync" non riuscito</div><div>make[2]: *** [dist/Debug/GNU-Linux-x86/audiosync] Errore 1</div><div>make[2]: uscita dalla directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"</div><div>nbproject/Makefile-Debug.mk:62: set di istruzioni per l'obiettivo ".build-conf" non riuscito</div><div>make[1]: *** [.build-conf] Errore 2</div><div>make[1]: uscita dalla directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"</div><div>nbproject/Makefile-impl.mk:39: set di istruzioni per l'obiettivo ".build-impl" non riuscito</div><div>make: *** [.build-impl] Errore 2</div><div><br></div></span><div>BUILD FAILED (exit value 2, total time: 381ms)</div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><br></div></div></blockquote></div></div></div></div></blockquote><div><br></div><div>To remind the problem:</div><div><br></div><div style="font-size:12.8000001907349px">I'm trying to set-up a function, using the ffmpeg c api 2.7.2, to re-sample a stream (AVStream format) to fixed (1channel - u8 sample) format.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">I'm using ffmpeg libswresample library, but when I try to compile, I get a linker error that is strictly connected to swresample functions.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Let me post the code:</div><div style="font-size:12.8000001907349px">----------------------------</div><div style="font-size:12.8000001907349px"><div>double *resample8(AVFrame *frame, int size, AVCodec* codec){</div><div>    </div><div>    /* initialization of the output array */</div><div>    double *out = new double[size];</div><div><span style="white-space:pre-wrap">    </span></div><div>    /* create resampling context */</div><div>    struct SwrContext *resampleContext;</div><div>    resampleContext = swr_alloc();</div><div>    if (!resampleContext) {</div><div><span style="white-space:pre-wrap">      </span>fprintf(stderr, "Could not allocate resampler context\n");</div><div><span style="white-space:pre-wrap">     </span>return NULL;</div><div>    }</div><div>    </div><div>    /* set options */</div><div>    av_opt_set_int(resampleContext, "in_channel_layout", *(codec->channel_layouts), 0);</div><div>    av_opt_set_sample_fmt(resampleContext, "in_sample_fmt", *(codec->sample_fmts), 0);</div><div><br></div><div>    av_opt_set_int(resampleContext, "out_channel_layout", AV_CH_LAYOUT_MONO, 0);</div><div>    av_opt_set_sample_fmt(resampleContext, "out_sample_fmt", AV_SAMPLE_FMT_U8, 0);</div><div>    </div><div>    /* initialize the resampling context */</div><div>    if (swr_init(resampleContext) < 0) {</div><div><span style="white-space:pre-wrap">   </span>fprintf(stderr, "Failed to initialize the resampling context\n");</div><div><span style="white-space:pre-wrap">      </span>return NULL;</div><div>    }</div><div>    </div><div>    return NULL;</div><div>    </div><div>}</div></div><div style="font-size:12.8000001907349px">------------------------------------</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Here is the inclusion:</div><div style="font-size:12.8000001907349px">------------------------------------</div><div style="font-size:12.8000001907349px"><div>#ifdef __cplusplus</div><div>extern "C"</div><div>{</div><div>#endif // __cplusplus</div><div>    #include <libavcodec/avcodec.h></div><div>    #include <libavformat/avformat.h></div><div>    #include <libavutil/avutil.h></div><div>    #include <libavutil/opt.h></div><div>    #include <libavutil/channel_layout.h></div><div>    #include <libavutil/samplefmt.h></div><div>    #include <libswresample/swresample.h></div><div>#ifdef __cplusplus</div><div>} // end extern "C".</div><div>#endif // __cplusplus</div></div><div style="font-size:12.8000001907349px">----------------------------------</div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap"> </span></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">And here is the error I get, compiling with netbeans 8.0.2, g++ 4.9.2-10ubuntu13</div><div style="font-size:12.8000001907349px">(additional g++ commands: -lavcodec -lavformat -lavutil -lswresample -lfftw3 -lm)</div><div style="font-size:12.8000001907349px">----------------------------------    <br></div><div style="font-size:12.8000001907349px"><div>"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf</div><div>make[1]: ingresso nella directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"</div><div>"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/audiosync</div><div>make[2]: ingresso nella directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"</div><div>mkdir -p build/Debug/GNU-Linux-x86</div><div>rm -f "build/Debug/GNU-Linux-x86/main.o.d"</div><div>g++    -c -g -MMD -MP -MF "build/Debug/GNU-Linux-x86/main.o.d" -o build/Debug/GNU-Linux-x86/main.o main.cpp</div><div>mkdir -p dist/Debug/GNU-Linux-x86</div><div>g++ -o dist/Debug/GNU-Linux-x86/audiosync build/Debug/GNU-Linux-x86/dataReader.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/tansforms.o build/Debug/GNU-Linux-x86/tognuplot.o  -lavcodec -lavformat -lavutil -lswresample -lfftw3 -lm</div><div>build/Debug/GNU-Linux-x86/dataReader.o: nella funzione "resample8(AVFrame*, int, AVCodec*)":</div><div>/home/davide/Documenti/Tesi/audiosync-fin/audiosync/dataReader.cpp:285: riferimento non definito a "av_opt_set_sample_fmt"</div><div>/home/davide/Documenti/Tesi/audiosync-fin/audiosync/dataReader.cpp:288: riferimento non definito a "av_opt_set_sample_fmt"</div><div>/usr/local/lib/libswresample.so: riferimento non definito a "av_calloc@LIBAVUTIL_54"</div><div>collect2: error: ld returned 1 exit status</div><div>nbproject/Makefile-Debug.mk:65: set di istruzioni per l'obiettivo "dist/Debug/GNU-Linux-x86/audiosync" non riuscito</div><div>make[2]: *** [dist/Debug/GNU-Linux-x86/audiosync] Errore 1</div><div>make[2]: uscita dalla directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"</div><div>nbproject/Makefile-Debug.mk:62: set di istruzioni per l'obiettivo ".build-conf" non riuscito</div><div>make[1]: *** [.build-conf] Errore 2</div><div>make[1]: uscita dalla directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"</div><div>nbproject/Makefile-impl.mk:39: set di istruzioni per l'obiettivo ".build-impl" non riuscito</div><div>make: *** [.build-impl] Errore 2</div><div><br></div><div>BUILD FAILED (exit value 2, total time: 5s)</div></div><div style="font-size:12.8000001907349px">------------------------------------------------------------</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">here is the linker configuration <a href="https://drive.google.com/file/d/0B2l6FPXN1f-EaEJfNmV2cjVUemM/view?usp=sharing" target="_blank">https://drive.google.com/file/d/0B2l6FPXN1f-EaEJfNmV2cjVUemM/view?usp=sharing</a></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">I searched for any clue about the linker error, and I found that it could be caused by multiple versions of ffmpeg installed. I removed ubuntu (I'm using 15.04) base installation of ffmpeg and installed ffmpeg 2.7.2 from the tar downloaded by <a href="http://ffmpeg.org/" target="_blank">ffmpeg.org</a></div><div style="font-size:12.8000001907349px"><br></div><div><span style="font-size:12.8000001907349px">I can't seem to find a solution at the moment, can anyone help?</span> </div></div><br></div></div>