Error using loadlibrary - error C2059

7 views (last 30 days)
Roimeh
Roimeh on 9 Apr 2013
Answered: Divyanshu on 15 Jan 2025
Hi,
I'm trying to run a dll file from a matlab script. When using loadlibrary, I get the following error:
Building CC3_thunk_pcwin64 failed. Compiler output is: cl -I"C:\Program Files\MATLAB\R2012a\extern\include" /W3 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo -I"D:\CCSW PACK\MATLAB\20130408" -I"D:\CCSW PACK\CC3\CC3" "CC3_thunk_pcwin64.c" -LD -Fe"CC3_thunk_pcwin64.dll" CC3_thunk_pcwin64.c D:\CCSW PACK\CC3\CC3\CC3.h(146) : error C2059: syntax error : 'string' D:\CCSW PACK\CC3\CC3\CC3.h(154) : error C2059: syntax error : 'string'
Last two lines continue in the same pattern (not shown) - each corresponds to the line that holds a function definition in 'CC3.h'. All of them look more or less like: extern "C" __declspec(dllexport) int FuncName
I'm using a 64 bit environment, matlab version R2012a, VS 2010 express, latest SDK and its patch.
In VS it builds successfully. I've used the 'mex -setup' prior to running the matlab script.
In matlab I call the function as so: loadlibrary([dllPath,'\x64\Debug\CC3.dll'],[dllPath,'\Proj\CC3.h']);
It worked fine before trying to switch to the 64 bit architecture.
I'd appreciate any help, Roi

Answers (1)

Divyanshu
Divyanshu on 15 Jan 2025
Hello @Roimeh,
You can refer the following MATLAB answer thread which addresses a similar issue of getting error 'C2059: syntax error: "string"' using loadlibrary:
Hope it helps!

Community Treasure Hunt

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

Start Hunting!