Compiling C++ file to *.mex64 leads to "unresolved external symbol" (conversion from size_t to int most likely the reason"

I have an old C++ source code which was successfully compiled to *.mex32 years ago (with MSVC8.0). With the help of the old optionsfile and the example file MSVC90OPTS.BAT I managed to write a new options file for 64-bit and the MSVC 9.0 compiler.
During the compilation process there are several warnings: warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
And at the end the error message: filename.obj : error LNK2019: unresolved external symbol "float * * _cdecl Subfunction::filename(char *,struct std::pair<int,int> *,int,unsigned _int64 &,float &,float &)" (?_filename@Subfunction@@YAPEAPEAMPEADPEAU?$pair@HH@std@@HAEA_KAEAM3@Z) referenced in function mexFunction filename.mexw64 : fatal error LNK1120: 1 unresolved externals
From previous answers I learned, that the size_t to int causes troubles in 64 bit systems only.
But as I am neither used to C or C++ I do not really know what to do.
Any more detailed suggestions?!
THANKS

Réponses (1)

From your error message, the program not working has nothing to do with the conversion from size_t to int. That in itself might make your program run funny, especially since size_t is unsigned. You will have problems with large and negative integers. You should avoid that even in 32 bits. But that is just a warning: you could ignore it, but in this case it's probably a bad idea.
Your program is refusing to run because of an unresolved external function:
float * * _cdecl Subfunction::filename(char *,struct std::pair<int,int> *,int,unsigned _int64 &,float &,float &)
I can only speculate as to why the function is unresolved. You might be linking to the wrong library or, and judging from the rest of your message I would guess that is the problem, you might be linking to a 32 bit library and trying to compile a 64 bit app. That's a no-no.

1 commentaire

Thanks for your answer.
I double checked that I am only using 64-bit libraries. My files seems to be ok but maybe my command is wrong?!
What I am doing is:
mex -v -g src\filename.cpp -f mexopts.bat
I also tried: mex -v -g -compatibleArrayDims src\filename.cpp -f mexopts.bat which leads to the same error message
and mex -v -g -largeArrayDims src\filename.cpp -f mexopts.bat which leads to the following error message cannot convert parameter 2 from 'int [2]' to 'const mwSize *'
As I do not want to change the code I assume I have to stay with the -compatibleArrayDims switch, which is still the default.
Do I have to add any additional filenames or is it sufficient to have all the libraries and headerfiles to include defined in the option file?

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Compiler SDK dans Centre d'aide et File Exchange

Produits

Question posée :

le 6 Déc 2012

Community Treasure Hunt

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

Start Hunting!

Translated by