BookmarkSubscribeRSS Feed
andrnev
Fluorite | Level 6

Hi,

 

I have tried one method of calling a C++ dll created in Visual Studio 2010.

 

myexceldll.cpp

int __stdcall myPower(int myValue)
{
return myValue * myValue;
}

 

 

 

defFile.def

LIBRARY "myExcelDll"
EXPORTS
myPower @1

 

 

When trying to load the dll in SAS Enterprise guide 5.1 or even in SAS foundations 9.3 I get the following error

 

15 %let root=E:\C++\myExcelDll\Release;

16 libname lib "&root";

NOTE: Libref LIB was successfully assigned as follows:

Engine: V9

Physical Name: E:\C++\myExcelDll\Release

17

18 proc proto package=lib.Proto_ds.cfcns stdcall;

19 link '&root\myExcelDll.dll';

20

21 run;

WARNING: STDCALL option is only supported on the PC platform.

ERROR: Unable to load 'myExcelDll.dll'.

ERROR: Extension nicht gefunden: &root\myExcelDll.dll

ERROR: Extension nicht gefunden: myExcelDll.dll

ERROR: Extension nicht gefunden: myExcelDll.dll

ERROR: Datei LIB.PROTO_DS kann nicht aktualisiert werden. Die Codierung stimmt nicht mit der Codierung der Sitzung überein, oder

die Datei besitzt das systemeigene Format eines anderen Hosts, z.B. WINDOWS_64.

NOTE: PROZEDUR PROTO used (Total process time):

real time 0.04 seconds

cpu time 0.03 seconds

 

 

Any idea what the warning means? I am working on a Windows platform and both Enterprise guide and Foundations are installed on Windows.

Another issue I looked at was that SAS Foundations was 64 bit whereas my code is a Win32 dll. So I tried to compile with gcc using 64 bit settings and I still get the same error.

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, no, never found a reason to call C++ dll's (and can be quite dangerous if you don't know what your doing).  Why are you needing to do this?  SAS offers all the functionality you could need, the only reason I could think of is a historical program that is a requirement, otherwise just do it in SAS, or do it in C++, no need for both.

andrnev
Fluorite | Level 6

Yep, I could do it in either. Just an academic question rather.

jklaverstijn
Rhodochrosite | Level 12

In your statement 

 

link '&root\myExcelDll.dll';

you are using single quotes. Therefore &root will not be resolved. Use double quoutes and you will be in much better shape.

 

link "&root\myExcelDll.dll";

 

Regards, Jan.

andrnev
Fluorite | Level 6

Thanks Jan. Tried it, and now reveals another error. i.e. not a valid Win32 application.

 

I ran this code on SAS Foundations 64 bit in windows. The dll is compiled 32 bit. I am confused now.

 

1. This error is stated after the "Unable to load 'myExcelDll.dll' error. So is SAS able to read the dll and find that its not a valid Win32 application thus throwing the 2 errors?

2. The dll was compiled as 32 bit. Still why does SAS complain?

2. The first warning of STDCALL option being supported only on PC platform (which I assume means Windows??). If it does then this warning does not make sense since I am running SAS on Windows.

 

WARNING: STDCALL option is only supported on the PC platform.
ERROR: Unable to load 'myExcelDll.dll'.
ERROR: Fehler beim Laden der Extension: OS-Fehler: 193 (E:\C++\myExcelDll\Release\myExcelDll.dll
is not a valid Win32 application.)
ERROR: Extension kann nicht geladen werden: (E:\C++\myExcelDll\Release\myExcelDll.dll)
ERROR: Extension nicht gefunden: myExcelDll.dll
ERROR: Extension nicht gefunden: myExcelDll.dll
NOTE: Prototypes saved to LIB.PROTO_DS.CFCNS.
NOTE: PROCEDURE PROTO used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You have typed your answer there, you are trying to run a 32bit compilation on a 64bit system.  Some information (it wont solve your problem, but may explain it):

https://blog.mattmags.com/2007/06/30/accessing-32-bit-dlls-from-64-bit-code/

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1418 views
  • 0 likes
  • 3 in conversation