add jpeg toolbox in matlab 2014a
Show older comments
hi.please help me to correct these errors.
os :win7 x64
matlab 2014a
i did steps that introduced in https://sol2prob.blogspot.com/2012/12/add-jpeg-toolbox-to-matlab-in-windows-7.html successfully.
>> mex -setup
MEX configured to use 'Microsoft Visual C++ 2010 Professional (C)' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different C compiler, select one from the following:
lcc-win32 mex -setup:'C:\Program Files (x86)\MATLAB\R2014a\bin\win32\mexopts\lcc-win32.xml' C
Microsoft Visual C++ 2010 Professional (C) mex -setup:C:\Users\#NeGaR\AppData\Roaming\MathWorks\MATLAB\R2014a\mex_C_win32.xml C
Microsoft Windows SDK 7.1 (C) mex -setup:'C:\Program Files (x86)\MATLAB\R2014a\bin\win32\mexopts\winsdk-7.1_c.xml' C
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
>> mex -I'C:\Program Files (x86)\MATLAB\R2014a\bin\jpegprj' jpeg_write.c 'C:\Program Files (x86)\MATLAB\R2014a\bin\jpegprj\libjpeg.lib'
Building with 'Microsoft Visual C++ 2010 Professional (C)'.
Error using mex
Creating library jpeg_write.lib and object jpeg_write.exp
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_finish_compress referenced in
function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_write_marker referenced in
function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_alloc_huff_table referenced in
function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_alloc_quant_table referenced in
function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_write_coefficients referenced
in function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jround_up referenced in function
_mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_simple_progression referenced
in function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_set_defaults referenced in
function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_stdio_dest referenced in
function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_CreateCompress referenced in
function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_destroy_compress referenced in
function _mexFunction
jpeg_write.obj : error LNK2019: unresolved external symbol _jpeg_std_error referenced in
function _mexFunction
jpeg_write.mexw32 : fatal error LNK1120: 12 unresolved externals
>> mex -I'C:\Program Files (x86)\MATLAB\R2014a\bin\jpegprj' jpeg_read.c 'C:\Program Files (x86)\MATLAB\R2014a\bin\jpegprj\libjpeg.lib'
Building with 'Microsoft Visual C++ 2010 Professional (C)'.
Error using mex
Creating library jpeg_read.lib and object jpeg_read.exp
jpeg_read.obj : error LNK2019: unresolved external symbol _jpeg_finish_decompress referenced
in function _mexFunction
jpeg_read.obj : error LNK2019: unresolved external symbol _jpeg_read_coefficients referenced
in function _mexFunction
jpeg_read.obj : error LNK2019: unresolved external symbol _jpeg_read_header referenced in
function _mexFunction
jpeg_read.obj : error LNK2019: unresolved external symbol _jpeg_save_markers referenced in
function _mexFunction
jpeg_read.obj : error LNK2019: unresolved external symbol _jpeg_stdio_src referenced in
function _mexFunction
jpeg_read.obj : error LNK2019: unresolved external symbol _jpeg_CreateDecompress referenced in
function _mexFunction
jpeg_read.obj : error LNK2019: unresolved external symbol _jpeg_destroy_decompress referenced
in function _mexFunction
jpeg_read.obj : error LNK2019: unresolved external symbol _jpeg_std_error referenced in
function _mexFunction
jpeg_read.mexw32 : fatal error LNK1120: 8 unresolved externals
>>
1 Comment
Steven Lord
on 18 Nov 2019
I'm coming to this a bit late, but is there a reason you're not just using the imwrite function included in MATLAB? I checked the documentation in release R2014a and it can write JPEG files (either "8-bit, 12-bit, and 16-bit Baseline JPEG images" or "1-bit, 8-bit, and 16-bit JPEG 2000 images" depending on the fmt input you pass into imwrite.)
Answers (2)
Guillaume
on 29 Jul 2019
0 votes
I know nothing about that toolbox but all these missing symbols looks like symbols from libjpeg. I assume it's a dependency of that toolbox, perhaps the 404 file from step 2. So, have you done that step 2? If you've skipped step 2 or 3, it's no suprise that the installation doesn't work.
15 Comments
negar zamani
on 30 Jul 2019
Guillaume
on 30 Jul 2019
I didn't see that the first time: you shouldn't put any file under C:\Program Files (x86)\MATLAB\, that's a sure way of making matlab stop working properly. I would recommend you move the libjpeg files to a completely different directory (such as My Documents\libjpeg)
However, that's not the cause of the linking error. If C:\Program Files (x86)\MATLAB\R2014a\bin\jpegprj\jpegsr6\jpeg-6b is where you put the libjpeg file, then you've passed the correct flags to mex.
Did you get warning during the compilation of libjpeg?
Where did you get actually download the toolbox from? The link on the website you refer to above leads to a website that is blocked by my browser as a high-risk website attempting to install a virus.
negar zamani
on 31 Jul 2019
Guillaume
on 31 Jul 2019
I was asking where you got the source for the toolbox itself, not libjpeg (which indeed can be downloaded from a number of reliable sources).
The error you've got is fine (the makefile asks to delete any testout* file and the error tells you there aren't any to delete) and it looks like the compilation of libjpeg completed succesfully. You do have a libjpeg.lib file?
There are a lot of warning which can be expected from such an old library.
Guillaume
on 1 Aug 2019
negar zamani's comment posted as an answer moved here:
i recieved this toolbox from a person.(mailed me).yes i have libjpeg.lib. i test the solution that sugested by here the subject of "Get MinGW with MSYS" successfully.i tried this for jpegsrc.v6b but happened error. i attached the result but i don't know how use it in matlab.
Guillaume
on 1 Aug 2019
I've just spotted that you've built libpjeg.lib as 64 bit but you're building the mex as 32-bit (since your matlab is 32-bit). That's most likely the reason for the linker errors.
For step 3, since you're building 32-bit you need a 32-bit command prompt, not a x64 command prompt. Once you're on a 32-bit command prompt, (it should say x86 somewhere in the title, sorry don't have VS2010 to know the exact name), run nmake again. Then try step 4.
negar zamani
on 2 Aug 2019
Guillaume
on 2 Aug 2019
Ironically (considering the age of that toolbox), the m file is meant for newer versions of matlab (>R2016b) with the new string type.
It's easily fixed, replace the double quotes " by single quotes ', so:
error('Mex routine jpeg_write.c not compiled\n');
in jpeg_write.m
and
error("Mex routine jpeg_read.c not compiled\n");
in jpeg_read.m
As far as I can tell, none of the other m files use anything that requires later versions.
Note that jpeg_read.m and jpeg_write.m are not important as long as you have the mw64 files. Their only purpose is to give an error message if the mw64 files don't exist and to provide function hints.
negar zamani
on 2 Aug 2019
Guillaume
on 3 Aug 2019
No, all I said is to replace the " by ' in the files jpeg_read.m and jpeg_write.m. This would make these files compatible with your version of matlab. As far as I can tell all the other files are compatible.
If you have succesfully compiled the mex files, you should then be able to use the toolbox.
Guillaume
on 3 Aug 2019
negar zamani comment mistakenly posted as an answer moved here:
i could compile jpeg_read correctly but have an error in jpeg_write:

i checked include folder and didn't find this .h but in jpeg-8d folder, i found it and copied to include forlder in mingw_w64 path. but have this error yet.????
Guillaume
on 3 Aug 2019
Stop switching compiler just to solve some basic errors. You're not helping yourself. Spend some time trying to understand the errors first.
Your initial problem is that you were compiling libjpeg as a 64-bit library while your mex was 32-bit. The fix for that was to compile libpjeg as 32-bit, which simply required a different command prompt.
The next problem is that somebody upgraded jpeg_read.m and jpeg_write.m to use the new string syntax of matlab R2016b. That meant you didn't get function hint. The fix for that was to simply replace " by ' in each file. Nothing else required.
Now, I've no idea if you're 64-bit or 32-bit and which compiler you're using. Earlier you showed a screenshot where both jpeg_read and jpeg_write compiled succesfully, so go back to that version and change the " and ' in the m files. Everything should work then.
negar zamani
on 8 Aug 2019
Royi Avital
on 18 Nov 2019
Does anyone knows which JPEG library MATLAB uses?
Walter Roberson
on 18 Nov 2019
MATLAB uses a number of different jpeg related libraries (for reasons that are not clear.)
On Mac, the most obvious libraries it uses are version 0.0.0.0 (which is to say no version has been assigned.) Those are probably Mathworks library.
/Applications/MATLAB_R2019b.app/sys/java/jre/maci64/jre/lib/libjpeg.dylib is marked as version 1.0.0.0
negar zamani
on 3 Aug 2019
Edited: negar zamani
on 3 Aug 2019
0 votes
9 Comments
negar zamani
on 4 Aug 2019
Walter Roberson
on 4 Aug 2019
That would concern me. long long int * is a pointer like int * is, but the sizes being pointed to are so different that I would worry that one side is expecting 64 bit numbers but the other side might only be providing 32 bit numbers.
negar zamani
on 4 Aug 2019
Guillaume
on 4 Aug 2019
Again, in this screenshot you show jpeg_read.c and jpeg_write.c compiling succesfully. Why don't you use that?
Again, trying even more variations of compiler and source code is not going to help.
The download of libjpeg you had was perfectly fine. Using a completely different library such as that libjpeg turbo master is only going to make things worse.
It doesn't matter if you use 32-bit or 64-bit, as long as both libjpeg and the mex are compiled with the same bitness. If they're not the same bitness you'll see the linker errors that you wrote in your question.
negar zamani
on 4 Aug 2019
negar zamani
on 7 Aug 2019
Walter Roberson
on 7 Aug 2019
Do you have write access to stg.jpg in the current directory ? For example you would expect problems if your current directory is under the MATLAB installation folders.
negar zamani
on 8 Aug 2019
Venus R
on 19 Nov 2020
hi negar
did you solve your "Error writing to file" error?
can you tell me how?
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




