add jpeg toolbox in matlab 2014a

hi.please help me to correct these errors.
os :win7 x64
matlab 2014a
>> 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

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.)

Sign in to comment.

Answers (2)

Guillaume
Guillaume on 29 Jul 2019
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.
Note: libjpeg can be downloaded from a number of places, including sourceforge.

15 Comments

i did 4 steps completly. if i skip from step2, i can not have jpeglib.lib.that's ok. i guess the way of addressing may be incorrect.
in step 4:
Step 4: Now open the matlab and choose the workfolder as jpeg, created in step 1.
Now in the command windows run the following commands,
mex -I<IJGPATH> jpeg_read.c <LIBJPEG>
mex -I<IJGPATH> jpeg_write.c <LIBJPEG>
Replace <IJGPATH> with the path to the IJG jpeg-6b directory created in step 2, and
<LIBJPEG> with the full path to the IJG code library file (libjpeg.lib).
To use the jpeg_read and jpeg_write functions copy jpeg_read.mexw64 and jpeg_write.mexw64 files created above to your work directory. Dont uninstall visual c++ compiler or it wont work.
so i replace this two path by:
<IJGPATH> : ' C:\Program Files (x86)\MATLAB\R2014a\bin\jpegprj\jpegsr6\jpeg-6b '
and
<LIBJPEG> : ' C:\Program Files (x86)\MATLAB\R2014a\bin\jpegprj\jpegsr6\jpeg-6b\libjpeg.lib '
are these ok?
libjpeg.lib i located in jpeg-6b folder
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.
the link that used for jpegsr6b.zip:
in attached file you can see the warning resulted from compile in Windows SDK cmd.
at thr first of it,you can see that the making of library can not complete.
"Could Not Find C:\Users\#NeGaR\Pictures\jcompile\jpeg-6b\testout*"
when i try edit code to solve warning some of them convert to error so i turn back.
i tried this in other path too.
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.
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.
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.
i needed to use gcc and it work for x86. so installed matlab x86. i removed it and installed x64.
MEX completed successfully. thanks your help
Capture.JPG
but now i must copy two .mexw64 files in work directory.i made a new script their directory and try to jpeg_read but...
pic2.jpg
in jpeg_read.m:
pic3.jpg
is it common?
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.
are u suggest me to improve version of matlab?
is it the reson of 'can not display function hit' in pic 2?
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.
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.????
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.
before your answer, i had changed my matlab from 2014b(32 bit) to 2018a(64 bit). my computer is 64 bit. in matlab 2018a, when type 'mex -setup' (withot qoute) it's forced me to dowload and install MinGW64 compiler (c) for it's basic compiler. is it true that mex become 32 or 64 if matlab be 32 or 64? if it's true so my compiled libjpeg and mex are both 64. about replacing " bt ', i did.
now i write for you, i use matlab 2018a 64 bit.
after all, i can run jpeg_read correctly and recieve a structure that the one of it's member is array of DCT coeficiets. (coef_arrays)
after i run my algorithm on it, i should run jpeg_write. but happen this error:
write error.JPG
i need to solve it immediately . :(
Does anyone knows which JPEG library MATLAB uses?
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

Sign in to comment.

negar zamani
negar zamani on 3 Aug 2019
Edited: negar zamani on 3 Aug 2019
see pics please. i did convert ' to " in jpeg_read.m and jpeg_write.m
in 2014a but errors didn't refine.

9 Comments

i downloaded libjpeg-turbo-master and copied jpegint.h to: include folder in mingw-w64 and visualstudio and repeat mex jpeg_read.c '%libpath%' and mex jpeg_write.c '%libpath%'.
The result is:
correct.jpg
are you think every thing is ok?
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.
so what's your suggestion?
is it correct to install matlab 32 bit and compile code in 32 bit mode and go on others?
please answer me as soon as possible
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.
i didn't use all of libjpeg turbo master just use jpegint.h of it.there wasn't in lib folder and during jpeg_write happened error just for it. is that warning ralated to this include file or just about system(32 or 64).i did no search about.
and about two times using mex: i read : first do mex completation. after that repeat it without first address for both,jpeg_read and write.
i just warned about that warning in jpeg_read.
new error :(((((((((((((((((((((((
i can jpeg_read and it return a structure but jpeg_write don't work .
write error.JPG
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.
stg.jpg or every jpg filename that use in jpeg_write create in directory as same as directory that run the program(.m file) . it is necessary to create .m file in same directory by toolbox directory.
i changed the directory of my program and tried again.
no change. The error is exist yet
hi negar
did you solve your "Error writing to file" error?
can you tell me how?

Sign in to comment.

Categories

Asked:

on 29 Jul 2019

Commented:

on 19 Nov 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!