• Jueves 28 de Marzo de 2024, 16:17

Autor Tema:  C++ Con Dll De Fortran  (Leído 5823 veces)

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
C++ Con Dll De Fortran
« en: Lunes 26 de Noviembre de 2007, 17:40 »
0
Hola,
estoy generando en C++ una DLL para exponer métodos JNI y llamarlos desde Java. Esta parte me funciona correctamente. El problema lo tengo cuando desde el código C++ quiero hacer llamadas a unos métodos que existen en una DLL de Fortran que incluyo dentro de mi proyecto en C++ (MS Visual Studio)
Despues de leer la documentación al respecto mi código C++:
Código: Text
  1.  
  2. // HBVMODELAPI.cpp : Defines the entry point for the DLL application.
  3. //
  4. #include "stdafx.h"
  5. #include "edu_uji_aware_hbv_HBVModel.h"
  6.  
  7. extern "C" {void tuwhbv(long,float&,float&,float&,float&,float&,float&,float&,float&,long,float&,float&,float&,float&);}
  8.  
  9. JNIEXPORT void JNICALL Java_edu_uji_aware_hbv_HBVModel_hbv
  10. (JNIEnv *env, jobject obj, jlong flag, jfloat ages, jfloat incon, jfloat inputt, jfloat gobs, jfloat modisa, jfloat param, jfloat lb, jfloat ub, jlong calid, jfloat weight, jfloat parfin, jfloat effin, jfloat output)
  11. {
  12.   tuwhbv(flag, ages, incon,inputt,gobs,modisa,param,lb,ub,calid,weight,parfin,effin,output);
  13. }
  14.  
  15.  
Al crear la DLL, obtengo el siguiente error:
Linking...
   Creating library Release/HBVMODELAPI.lib and object Release/HBVMODELAPI.exp
HBVMODELAPI.obj : error LNK2001: unresolved external symbol _tuwhbv

Mi pregunta es la siguiente. además de haber incluido mi libreria dll de fortran con "Añadir fichero" al proyecto, debería hacer algo más? como inlcuir esta dll en algún "path".

alguna idea?

gracias y un saludo.
Laura.

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #1 en: Lunes 26 de Noviembre de 2007, 18:07 »
0
Necesitas enlazar contra el archivo de importacion (.lib) para que pueda resolver la funcion esa que no encuentra (tal vez tambien tengas que cambiar la convencion de llamada C por STDCALL).

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

JuanK

  • Miembro de ORO
  • ******
  • Mensajes: 5393
  • Nacionalidad: co
    • Ver Perfil
    • http://juank.io
Re: C++ Con Dll De Fortran
« Respuesta #2 en: Lunes 26 de Noviembre de 2007, 19:51 »
0
Creo que este hilo debería estar en el foro de java. Aunque dudo que alguien de ahi le hubiera podido ayudar. En fin, dejo sembrada la inquietud.  :ph34r:
[size=109]Juan Carlos Ruiz Pacheco
[/size]
Microsoft Technical Evangelist
@JuanKRuiz
http://juank.io

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #3 en: Lunes 26 de Noviembre de 2007, 20:09 »
0
Cita de: "JuanK"
Creo que este hilo debería estar en el foro de java. Aunque dudo que alguien de ahi le hubiera podido ayudar. En fin, dejo sembrada la inquietud.  :ph34r:
No realmente, la primera parte de Java dice que le funciona. El problema es con una DLL escrita en Fortran  :lol:

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #4 en: Martes 27 de Noviembre de 2007, 12:50 »
0
hola de nuevo y gracias,
no he puesto mi problema en el foro de java porque la parte de enlazar java con C++ me esta funcionando correctamente, el problema lo tengo tratando de generar una Dll con visual studio que incluye unas librerias generadas en fortran.

bueno, el caso es que los binarios que tengo generados en fortran (me los pasa un compañero de proyecto) son un monton de obj, un dll, un lib y un exp. La cuestión es que independientemente de si añado todos o solo obj o solo dll y lib. sigo teniendo el mismo problema.
El metodo que llamo, si que se llama así por eso no se muy bien que esta pasando. He probado también a cambiar la llamada usando STDCall y tengo lo mismo.
Me pregunto si en las opciones de proyecto hay alguna forma de decirle que linke con alguna otra librería aparte de haber hecho Project-Add files...

alguna idea?

Laura.

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #5 en: Martes 27 de Noviembre de 2007, 12:59 »
0
Eso de Add-Files no sirve y como decis tenes que cambiar las opciones del proyecto para que use el .lib en el enlazado:

Properties>>Linker>>Input>>Additional Dependencies

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #6 en: Martes 27 de Noviembre de 2007, 13:20 »
0
Entonces,
acabo de añadir en "Project-Settings-Link-Input" en "aditional library path" la ruta a mis binarios de fortran, y en object/library modules el nombre del fichero .lib
Sería eso suficiente? Porque sigo teniendo el mismo error.
Lo que no me queda entonces claro es: hay que añadir ficheros al proyecto con el Project-Add files? o no? el lib ya incluye todos los obj? o añado el dll y el .lib en el las opciones de "linkado"?

gracias y un saludo!
Laura.

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #7 en: Martes 27 de Noviembre de 2007, 16:33 »
0
El error puede deberse a muchas cosas. Para enlazar estaticamente unicamente necesitas el archivo de importacion (.lib).

No estaria mal que comprobaras las funciones exportadas con el Dependency Walker. Copialas aca de paso.

Por ejemplo aca estas buscando esta: _tuwhbv y tal vez sea tuwhbv o _tuwhbv@4, vaya uno a saber.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #8 en: Martes 27 de Noviembre de 2007, 17:00 »
0
Pues ya estaba usando el PE explorer y al igual que ahora con el Dependency Walker veo, que elúnico método expuesto en la libreria se llama tuwhbv. Es el mismo nombre que utilizo desde el código de C++. No se porque el mensaje del "linker" agrega el "_"

Ahora mismo tengo en el proyecto de VS, agregado el .lib. En el link-Input he añadido el directorio y el la lista de *.lib he añadido el mio. Obtengo el mismo "unresolved external symbol"

No se si el problema esta en el .lib y en la forma en que ha sido creado, quizás el que me ha pasado la libreria deberia compilar en fortran con alguna configuración concreta. He leido algo sobre compilar con "single threading o multiple" no se si puede ir por ahí la cosa. No se como comprobar que mi proyecto encuentra o no la librería y que el error esta en encontrarla o con el método en sí. Alguna idea de como puedo probar esto?

gracias de nuevo  :)

Laura.

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #9 en: Martes 27 de Noviembre de 2007, 19:08 »
0
El enlazador trata de decorar el nombre con _ como toda funcion de C, para ver que lleva el .lib usa dumpbin /all archivo.lib y de paso copianos el resultado. Es posible que tenga que exportar la funcion con algunos modificadores especiales o que termine usando la decoracion (_).

"single threading o multiple" no tiene nada que ver.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #10 en: Miércoles 28 de Noviembre de 2007, 10:16 »
0
hola,
a ver te pego el resultado del dumpbin que me has comentado:
Código: Text
  1.  
  2. Microsoft (R) COFF Binary File Dumper Version 6.00.8168
  3. Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
  4.  
  5.  
  6. Dump of file tuwhbv.lib
  7.  
  8. File Type: LIBRARY
  9.  
  10. Archive member name at 8: /              
  11. 474ABFC0 time/date Mon Nov 26 13:44:48 2007
  12.          uid
  13.          gid
  14.        0 mode
  15.       78 size
  16. correct header end
  17.  
  18.     5 public symbols
  19.  
  20.       17A __IMPORT_DESCRIPTOR_tuwhbv
  21.       482 __NULL_IMPORT_DESCRIPTOR
  22.       5B8 tuwhbv_NULL_THUNK_DATA
  23.       70A __imp_tuwhbv
  24.       70A tuwhbv
  25.  
  26. Archive member name at BC: /              
  27. 474ABFC0 time/date Mon Nov 26 13:44:48 2007
  28.          uid
  29.          gid
  30.        0 mode
  31.       82 size
  32. correct header end
  33.  
  34.     4 offsets
  35.  
  36.         1      17A
  37.         2      482
  38.         3      5B8
  39.         4      70A
  40.  
  41.     5 public symbols
  42.  
  43.         1 __IMPORT_DESCRIPTOR_tuwhbv
  44.         2 __NULL_IMPORT_DESCRIPTOR
  45.         4 __imp_tuwhbv
  46.         4 tuwhbv
  47.         3 tuwhbv_NULL_THUNK_DATA
  48.  
  49. Archive member name at 17A: tuwhbv.dll/    
  50. 474ABFC0 time/date Mon Nov 26 13:44:48 2007
  51.          uid
  52.          gid
  53.        0 mode
  54.      2CB size
  55. correct header end
  56.  
  57. FILE HEADER VALUES
  58.              14C machine (i386)
  59.                3 number of sections
  60.         474ABFC0 time date stamp Mon Nov 26 13:44:48 2007
  61.              1EB file pointer to symbol table
  62.                8 number of symbols
  63.               E0 size of optional header
  64.              100 characteristics
  65.                    32 bit word machine
  66.  
  67. OPTIONAL HEADER VALUES
  68.              10B magic #
  69.             6.00 linker version
  70.                0 size of code
  71.                0 size of initialized data
  72.                0 size of uninitialized data
  73.                0 RVA of entry point
  74.                0 base of code
  75.                0 base of data
  76.                0 image base
  77.             1000 section alignment
  78.              200 file alignment
  79.             4.00 operating system version
  80.             0.00 image version
  81.             0.00 subsystem version
  82.                0 Win32 version
  83.                0 size of image
  84.                0 size of headers
  85.                0 checksum
  86.                3 subsystem (Windows CUI)
  87.                0 DLL characteristics
  88.           100000 size of stack reserve
  89.             1000 size of stack commit
  90.           100000 size of heap reserve
  91.             1000 size of heap commit
  92.                0 loader flags
  93.               10 number of directories
  94.                0 [       0] RVA [size] of Export Directory
  95.                0 [       0] RVA [size] of Import Directory
  96.                0 [       0] RVA [size] of Resource Directory
  97.                0 [       0] RVA [size] of Exception Directory
  98.                0 [       0] RVA [size] of Certificates Directory
  99.                0 [       0] RVA [size] of Base Relocation Directory
  100.                0 [       0] RVA [size] of Debug Directory
  101.                0 [       0] RVA [size] of Architecture Directory
  102.                0 [       0] RVA [size] of Special Directory
  103.                0 [       0] RVA [size] of Thread Storage Directory
  104.                0 [       0] RVA [size] of Load Configuration Directory
  105.                0 [       0] RVA [size] of Bound Import Directory
  106.                0 [       0] RVA [size] of Import Address Table Directory
  107.                0 [       0] RVA [size] of Delay Import Directory
  108.                0 [       0] RVA [size] of Reserved Directory
  109.                0 [       0] RVA [size] of Reserved Directory
  110.  
  111.  
  112. SECTION HEADER #1
  113. .debug$S name
  114.        0 physical address
  115.        0 virtual address
  116.       41 size of raw data
  117.      16C file pointer to raw data
  118.        0 file pointer to relocation table
  119.        0 file pointer to line numbers
  120.        0 number of relocations
  121.        0 number of line numbers
  122. 42100040 flags
  123.          Initialized Data
  124.          Discardable
  125.          1 byte align
  126.          Read Only
  127.  
  128. RAW DATA #1
  129.   00000000: 02 00 00 00 11 00 09 00 00 00 00 00 0A 74 75 77  .............tuw
  130.   00000010: 68 62 76 2E 64 6C 6C 28 00 13 10 07 00 00 00 03  hbv.dll(........
  131.   00000020: 00 00 00 00 00 00 00 06 00 00 00 FF 20 12 4D 69  ...........ÿ .Mi
  132.   00000030: 63 72 6F 73 6F 66 74 20 28 52 29 20 4C 49 4E 4B  crosoft (R) LINK
  133.   00000040: 00                                               .
  134.  
  135. SECTION HEADER #2
  136. .idata$2 name
  137.        0 physical address
  138.        0 virtual address
  139.       14 size of raw data
  140.      1AD file pointer to raw data
  141.      1C1 file pointer to relocation table
  142.        0 file pointer to line numbers
  143.        3 number of relocations
  144.        0 number of line numbers
  145. C0300040 flags
  146.          Initialized Data
  147.          4 byte align
  148.          Read Write
  149.  
  150. RAW DATA #2
  151.   00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  152.   00000010: 00 00 00 00                                      ....
  153.  
  154. RELOCATIONS #2
  155.                                                 Symbol    Symbol
  156.  Offset    Type              Applied To         Index     Name
  157.  --------  ----------------  -----------------  --------  ------
  158.  0000000C  DIR32NB                    00000000         3  .idata$6
  159.  00000000  DIR32NB                    00000000         4  .idata$4
  160.  00000010  DIR32NB                    00000000         5  .idata$5
  161.  
  162. SECTION HEADER #3
  163. .idata$6 name
  164.        0 physical address
  165.        0 virtual address
  166.        C size of raw data
  167.      1DF file pointer to raw data
  168.      1C1 file pointer to relocation table
  169.        0 file pointer to line numbers
  170.        0 number of relocations
  171.        0 number of line numbers
  172. C0200040 flags
  173.          Initialized Data
  174.          2 byte align
  175.          Read Write
  176.  
  177. RAW DATA #3
  178.   00000000: 74 75 77 68 62 76 2E 64 6C 6C 00 00              tuwhbv.dll..
  179.  
  180. COFF SYMBOL TABLE
  181. 000 000420FF ABS    notype       Static       | @comp.id
  182. 001 00000000 SECT2  notype       External     | __IMPORT_DESCRIPTOR_tuwhbv
  183. 002 C0000040 SECT2  notype       Section      | .idata$2
  184. 003 00000000 SECT3  notype       Static       | .idata$6
  185. 004 C0000040 UNDEF  notype       Section      | .idata$4
  186. 005 C0000040 UNDEF  notype       Section      | .idata$5
  187. 006 00000000 UNDEF  notype       External     | __NULL_IMPORT_DESCRIPTOR
  188. 007 00000000 UNDEF  notype       External     | tuwhbv_NULL_THUNK_DATA
  189.  
  190. String Table Size = 0x50 bytes
  191.  
  192. Archive member name at 482: tuwhbv.dll/    
  193. 474ABFC0 time/date Mon Nov 26 13:44:48 2007
  194.          uid
  195.          gid
  196.        0 mode
  197.       FA size
  198. correct header end
  199.  
  200. FILE HEADER VALUES
  201.              14C machine (i386)
  202.                2 number of sections
  203.         474ABFC0 time date stamp Mon Nov 26 13:44:48 2007
  204.               B9 file pointer to symbol table
  205.                2 number of symbols
  206.                0 size of optional header
  207.              100 characteristics
  208.                    32 bit word machine
  209.  
  210. SECTION HEADER #1
  211. .debug$S name
  212.        0 physical address
  213.        0 virtual address
  214.       41 size of raw data
  215.       64 file pointer to raw data
  216.        0 file pointer to relocation table
  217.        0 file pointer to line numbers
  218.        0 number of relocations
  219.        0 number of line numbers
  220. 42100040 flags
  221.          Initialized Data
  222.          Discardable
  223.          1 byte align
  224.          Read Only
  225.  
  226. RAW DATA #1
  227.   00000000: 02 00 00 00 11 00 09 00 00 00 00 00 0A 74 75 77  .............tuw
  228.   00000010: 68 62 76 2E 64 6C 6C 28 00 13 10 07 00 00 00 03  hbv.dll(........
  229.   00000020: 00 00 00 00 00 00 00 06 00 00 00 FF 20 12 4D 69  ...........ÿ .Mi
  230.   00000030: 63 72 6F 73 6F 66 74 20 28 52 29 20 4C 49 4E 4B  crosoft (R) LINK
  231.   00000040: 00                                               .
  232.  
  233. SECTION HEADER #2
  234. .idata$3 name
  235.        0 physical address
  236.        0 virtual address
  237.       14 size of raw data
  238.       A5 file pointer to raw data
  239.        0 file pointer to relocation table
  240.        0 file pointer to line numbers
  241.        0 number of relocations
  242.        0 number of line numbers
  243. C0300040 flags
  244.          Initialized Data
  245.          4 byte align
  246.          Read Write
  247.  
  248. RAW DATA #2
  249.   00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  250.   00000010: 00 00 00 00                                      ....
  251.  
  252. COFF SYMBOL TABLE
  253. 000 000420FF ABS    notype       Static       | @comp.id
  254. 001 00000000 SECT2  notype       External     | __NULL_IMPORT_DESCRIPTOR
  255.  
  256. String Table Size = 0x1D bytes
  257.  
  258. Archive member name at 5B8: tuwhbv.dll/    
  259. 474ABFC0 time/date Mon Nov 26 13:44:48 2007
  260.          uid
  261.          gid
  262.        0 mode
  263.      115 size
  264. correct header end
  265.  
  266. FILE HEADER VALUES
  267.              14C machine (i386)
  268.                3 number of sections
  269.         474ABFC0 time date stamp Mon Nov 26 13:44:48 2007
  270.               D5 file pointer to symbol table
  271.                2 number of symbols
  272.                0 size of optional header
  273.              100 characteristics
  274.                    32 bit word machine
  275.  
  276. SECTION HEADER #1
  277. .debug$S name
  278.        0 physical address
  279.        0 virtual address
  280.       41 size of raw data
  281.       8C file pointer to raw data
  282.        0 file pointer to relocation table
  283.        0 file pointer to line numbers
  284.        0 number of relocations
  285.        0 number of line numbers
  286. 42100040 flags
  287.          Initialized Data
  288.          Discardable
  289.          1 byte align
  290.          Read Only
  291.  
  292. RAW DATA #1
  293.   00000000: 02 00 00 00 11 00 09 00 00 00 00 00 0A 74 75 77  .............tuw
  294.   00000010: 68 62 76 2E 64 6C 6C 28 00 13 10 07 00 00 00 03  hbv.dll(........
  295.   00000020: 00 00 00 00 00 00 00 06 00 00 00 FF 20 12 4D 69  ...........ÿ .Mi
  296.   00000030: 63 72 6F 73 6F 66 74 20 28 52 29 20 4C 49 4E 4B  crosoft (R) LINK
  297.   00000040: 00                                               .
  298.  
  299. SECTION HEADER #2
  300. .idata$5 name
  301.        0 physical address
  302.        0 virtual address
  303.        4 size of raw data
  304.       CD file pointer to raw data
  305.        0 file pointer to relocation table
  306.        0 file pointer to line numbers
  307.        0 number of relocations
  308.        0 number of line numbers
  309. C0300040 flags
  310.          Initialized Data
  311.          4 byte align
  312.          Read Write
  313.  
  314. RAW DATA #2
  315.   00000000: 00 00 00 00                                      ....
  316.  
  317. SECTION HEADER #3
  318. .idata$4 name
  319.        0 physical address
  320.        0 virtual address
  321.        4 size of raw data
  322.       D1 file pointer to raw data
  323.        0 file pointer to relocation table
  324.        0 file pointer to line numbers
  325.        0 number of relocations
  326.        0 number of line numbers
  327. C0300040 flags
  328.          Initialized Data
  329.          4 byte align
  330.          Read Write
  331.  
  332. RAW DATA #3
  333.   00000000: 00 00 00 00                                      ....
  334.  
  335. COFF SYMBOL TABLE
  336. 000 000420FF ABS    notype       Static       | @comp.id
  337. 001 00000000 SECT2  notype       External     | tuwhbv_NULL_THUNK_DATA
  338.  
  339. String Table Size = 0x1C bytes
  340.  
  341. Archive member name at 70A: tuwhbv.dll/    
  342. 474ABFC0 time/date Mon Nov 26 13:44:48 2007
  343.          uid
  344.          gid
  345.        0 mode
  346.       26 size
  347. correct header end
  348.  
  349.   Version      : 0
  350.   Machine      : 14C (i386)
  351.   TimeDateStamp: 474ABFC0 Mon Nov 26 13:44:48 2007
  352.   SizeOfData   : 00000012
  353.   DLL name     : tuwhbv.dll
  354.   Symbol name  : tuwhbv
  355.   Type         : code
  356.   Name type    : name
  357.   Hint         : 0
  358.   Name         : tuwhbv
  359.  
  360.      Exports
  361.  
  362.        ordinal    name
  363.  
  364.                   tuwhbv
  365.  
  366.   Summary
  367.  
  368.           C3 .debug$S
  369.           14 .idata$2
  370.           14 .idata$3
  371.            4 .idata$4
  372.            4 .idata$5
  373.            C .idata$6
  374.  
  375.  

debería llamar a la función con otro nombre "decorado"? algo así como imp_tuwhbv??
gracias!

Laura.

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #11 en: Miércoles 28 de Noviembre de 2007, 11:11 »
0
Cita de: "LauraDiaz"
debería llamar a la función con otro nombre "decorado"? algo así como imp_tuwhbv??

Es probable, la manera normal es hacer esto:
Código: Text
  1.  
  2. extern "C"
  3. {
  4.   [B]__declspec(dllimport)[/B] void tuwhbv(long,float&,float&,float&,float&,float&,float&,float&,float&,long,float&,float&,float&,float&);
  5. };
  6. [/quote]
  7.  
  8. Pero en teoria no deberia funcionar por ser lo que busca:
  9. __imp[COLOR=red]__[/COLOR]tuwhbv
  10. y lo que hay en el lib:
  11. __imp[COLOR=red]_[/COLOR]tuwhbv
  12.  
  13. Asi que tal vez una forma sea:
  14. extern "C"
  15. {
  16.   void _imp_tuwhbv(long,float&,float&,float&,float&,float&,float&,float&,float&,long,float&,float&,float&,float&);
  17.   #define tuwhbv _imp_tuwhbv
  18. };
  19.  
  20.  

No se que convencion de llamada usa FORTRAN ... asi que puede fallar tranquilamente sino usa C. La persona encargada de esta DLL seguramente sabra mas al respecto, por cierto ese prototipo es vomitivo ...

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #12 en: Miércoles 28 de Noviembre de 2007, 13:59 »
0
Pues al final ha funcionado, con la declaracion
extern "C"
{
 void _imp_tuwhbv(long,float&,float&,float&,float&,float&,float&,float&,float&,long,float&,float&,float&,float&);
};

ha linkado bien y me ha generado la DLL. Ahora ya estoy en "otro nivel" :)
despues de general esta DLL y ejecutar el código desde java que llama indirectamente a l de fortran a traves de este método obtengo un "EXCEPTION_ACCESS_VIOLATION" que creo que debe ser algo con el paso de parametros y punteros con los que no trabajaba desde hace mucho tiempo.

bueno, pues muchas gracias por la ayuda!

Laura.

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #13 en: Miércoles 28 de Noviembre de 2007, 14:27 »
0
Cita de: "LauraDiaz"
Pues al final ha funcionado, con la declaracion
extern "C"
{
 void _imp_tuwhbv(long,float&,float&,float&,float&,float&,float&,float&,float&,long,float&,float&,float&,float&);
};

ha linkado bien y me ha generado la DLL. Ahora ya estoy en "otro nivel" :)
despues de general esta DLL y ejecutar el código desde java que llama indirectamente a l de fortran a traves de este método obtengo un "EXCEPTION_ACCESS_VIOLATION" que creo que debe ser algo con el paso de parametros y punteros con los que no trabajaba desde hace mucho tiempo.
Si, me imagine que con eso la iba a resolver si o si pero como decis tenes una excepcion no controlada que tal vez este relacionada con lo que te decia antes: la convencion de llamada de fortran.

Tal vez un dumpbin /disasm de la DLL nos de una idea mas clara de que convencion de llamada usa.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #14 en: Miércoles 28 de Noviembre de 2007, 17:05 »
0
Haciendo lo que me dices del dumpbin /disasm tuwhbv.lib (la libreria de fortran) obtengo esto, te copio solo una parte del principio
Código: Text
  1.  
  2. Microsoft (R) COFF Binary File Dumper Version 6.00.8168
  3. Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
  4.  
  5.  
  6. Dump of file tuwhbv.dll
  7.  
  8. File Type: DLL
  9.  
  10.   10001000: 55                 push        ebp
  11.   10001001: 8B EC              mov         ebp,esp
  12.   10001003: 83 EC 14           sub         esp,14h
  13.   10001006: 53                 push        ebx
  14.   10001007: 56                 push        esi
  15.   10001008: 57                 push        edi
  16.   10001009: 8B 05 B8 80 00 10  mov         eax,dword ptr ds:[100080B8h]
  17.   1000100F: 8B 75 0C           mov         esi,dword ptr [ebp+0Ch]
  18.   10001012: 89 45 FC           mov         dword ptr [ebp-4],eax
  19.   10001015: BF 64 00 00 00     mov         edi,64h
  20.   1000101A: BB 01 00 00 00     mov         ebx,1
  21.   1000101F: 89 5D F8           mov         dword ptr [ebp-8],ebx
  22.   10001022: 89 5D F4           mov         dword ptr [ebp-0Ch],ebx
  23.   10001025: DB 45 F8           fild        dword ptr [ebp-8]
  24.   10001028: 8D 45 F8           lea         eax,[ebp-8]
  25.   1000102B: D8 0D 98 80 00 10  fmul        dword ptr ds:[10008098h]
  26.   10001031: D8 35 C4 80 00 10  fdiv        dword ptr ds:[100080C4h]
  27.   10001037: D9 5D F8           fstp        dword ptr [ebp-8]
  28.   1000103A: DB 45 F4           fild        dword ptr [ebp-0Ch]
  29.   1000103D: D8 25 98 80 00 10  fsub        dword ptr ds:[10008098h]
  30.   10001043: D8 35 C4 80 00 10  fdiv        dword ptr ds:[100080C4h]
  31.   10001049: D9 5D F4           fstp        dword ptr [ebp-0Ch]
  32.   1000104C: 83 EC 04           sub         esp,4
  33.   1000104F: DD C0              ffree       st(0)
  34.   10001051: 50                 push        eax
  35.   10001052: 56                 push        esi
  36.   10001053: FF 75 08           push        dword ptr [ebp+8]
  37.   10001056: E8 27 04 00 00     call        10001482
  38.   1000105B: D9 5D F0           fstp        dword ptr [ebp-10h]
  39.   1000105E: 8D 45 F4           lea         eax,[ebp-0Ch]
  40.   10001061: 50                 push        eax
  41.   10001062: 56                 push        esi
  42.   10001063: FF 75 08           push        dword ptr [ebp+8]
  43.   10001066: E8 17 04 00 00     call        10001482
  44.   1000106B: 83 C4 04           add         esp,4
  45.   1000106E: B8 00 00 00 00     mov         eax,0
  46.   10001073: D8 6D F0           fsubr       dword ptr [ebp-10h]
  47.   10001076: D8 0D C0 80 00 10  fmul        dword ptr ds:[100080C0h]
  48.   1000107C: DD D1              fst         st(1)
  49.   1000107E: D8 5D FC           fcomp       dword ptr [ebp-4]
  50.   10001081: DF E0              fnstsw      ax
  51.   10001083: 80 E4 41           and         ah,41h
  52.   10001086: 75 03              jne         1000108B
  53.   10001088: D9 55 FC           fst         dword ptr [ebp-4]
  54.   1000108B: 43                 inc         ebx
  55.   1000108C: 4F                 dec         edi
  56.   1000108D: 85 FF              test        edi,edi
  57.   1000108F: 7F 8E              jg          1000101F
  58.   10001091: 8B 4D 18           mov         ecx,dword ptr [ebp+18h]
  59.   10001094: 8B 45 14           mov         eax,dword ptr [ebp+14h]
  60.   10001097: 8B 55 10           mov         edx,dword ptr [ebp+10h]
  61.   1000109A: 8B 5D 14           mov         ebx,dword ptr [ebp+14h]
  62.   1000109D: D9 01              fld         dword ptr [ecx]
  63.   1000109F: BF 01 00 00 00     mov         edi,1
  64.   100010A4: D8 20              fsub        dword ptr [eax]
  65.   100010A6: DD D9              fstp        st(1)
  66.   100010A8: D9 02              fld         dword ptr [edx]
  67.   100010AA: D8 23              fsub        dword ptr [ebx]
  68.   100010AC: D8 F1              fdiv        st,st(1)
  69.   100010AE: D8 0D C0 80 00 10  fmul        dword ptr ds:[100080C0h]
  70.   100010B4: 66 D9 7D EC        fnstcw      word ptr [ebp-14h]
  71.   100010B8: 8B 45 EC           mov         eax,dword ptr [ebp-14h]
  72.   100010BB: 0D 00 0C 00 00     or          eax,0C00h
  73.   100010C0: 66 89 45 EE        mov         word ptr [ebp-12h],ax
  74.   100010C4: 66 D9 6D EE        fldcw       word ptr [ebp-12h]
  75.   100010C8: DB 5D F0           fistp       dword ptr [ebp-10h]
  76.   100010CB: 8B 45 F0           mov         eax,dword ptr [ebp-10h]
  77.   100010CE: 85 C0              test        eax,eax
  78.   100010D0: 66 D9 6D EC        fldcw       word ptr [ebp-14h]
  79.   100010D4: 7E 02              jle         100010D8
  80.   100010D6: 8B F8              mov         edi,eax
  81.   100010D8: 83 FF 64           cmp         edi,64h
  82.   100010DB: 7E 05              jle         100010E2
  83.   100010DD: BF 64 00 00 00     mov         edi,64h
  84.   100010E2: 8D 55 F8           lea         edx,[ebp-8]
  85.   100010E5: 89 7D F0           mov         dword ptr [ebp-10h],edi
  86.   100010E8: DB 45 F0           fild        dword ptr [ebp-10h]
  87.   100010EB: 89 7D F0           mov         dword ptr [ebp-10h],edi
  88.   100010EE: 8D 7D F4           lea         edi,[ebp-0Ch]
  89.   100010F1: D8 0D 98 80 00 10  fmul        dword ptr ds:[10008098h]
  90.   100010F7: D8 35 C4 80 00 10  fdiv        dword ptr ds:[100080C4h]
  91.   100010FD: D9 5D F8           fstp        dword ptr [ebp-8]
  92.   10001100: DB 45 F0           fild        dword ptr [ebp-10h]
  93.   10001103: D8 25 98 80 00 10  fsub        dword ptr ds:[10008098h]
  94.   10001109: D8 35 C4 80 00 10  fdiv        dword ptr ds:[100080C4h]
  95.   1000110F: D9 5D F4           fstp        dword ptr [ebp-0Ch]
  96.   10001112: 83 EC 04           sub         esp,4
  97.   10001115: DD C0              ffree       st(0)
  98.   10001117: 52                 push        edx
  99.   10001118: 56                 push        esi
  100.   10001119: FF 75 08           push        dword ptr [ebp+8]
  101.   1000111C: E8 61 03 00 00     call        10001482
  102.   10001121: D9 5D F8           fstp        dword ptr [ebp-8]
  103.   10001124: 57                 push        edi
  104.   10001125: 56                 push        esi
  105.   10001126: FF 75 08           push        dword ptr [ebp+8]
  106.   10001129: E8 54 03 00 00     call        10001482
  107.   1000112E: 83 C4 04           add         esp,4
  108.   10001131: 8B 5D 1C           mov         ebx,dword ptr [ebp+1Ch]
  109.   10001134: D8 6D F8           fsubr       dword ptr [ebp-8]
  110.   10001137: D8 0D C0 80 00 10  fmul        dword ptr ds:[100080C0h]
  111.   1000113D: D8 6D FC           fsubr       dword ptr [ebp-4]
  112.   10001140: 5F                 pop         edi
  113.   10001141: 5E                 pop         esi
  114.   10001142: D9 1B              fstp        dword ptr [ebx]
  115.   10001144: 5B                 pop         ebx
  116.   10001145: 8B E5              mov         esp,ebp
  117.   10001147: 5D                 pop         ebp
  118.   10001148: C2 18 00           ret         18h
  119.   1000114B: 55                 push        ebp
  120.   1000114C: 8B EC              mov         ebp,esp
  121.   1000114E: 83 EC 14           sub         esp,14h
  122.   10001151: 53                 push        ebx
  123.   10001152: 56                 push        esi
  124.   10001153: 57                 push        edi
  125.   10001154: 8B 05 B8 80 00 10  mov         eax,dword ptr ds:[100080B8h]
  126.   1000115A: 8B 75 0C           mov         esi,dword ptr [ebp+0Ch]
  127.   1000115D: 89 45 FC           mov         dword ptr [ebp-4],eax
  128.   10001160: BF 64 00 00 00     mov         edi,64h
  129.   10001165: BB 01 00 00 00     mov         ebx,1
  130.   1000116A: 89 5D F8           mov         dword ptr [ebp-8],ebx
  131.   1000116D: 89 5D F4           mov         dword ptr [ebp-0Ch],ebx
  132.   10001170: DB 45 F8           fild        dword ptr [ebp-8]
  133.   10001173: 8D 45 F8           lea         eax,[ebp-8]
  134.   10001176: D8 0D 98 80 00 10  fmul        dword ptr ds:[10008098h]
  135.   1000117C: D8 35 C4 80 00 10  fdiv        dword ptr ds:[100080C4h]
  136.   10001182: D9 5D F8           fstp        dword ptr [ebp-8]
  137.   10001185: DB 45 F4           fild        dword ptr [ebp-0Ch]
  138.   10001188: D8 25 98 80 00 10  fsub        dword ptr ds:[10008098h]
  139.   1000118E: D8 35 C4 80 00 10  fdiv        dword ptr ds:[100080C4h]
  140.   10001194: D9 5D F4           fstp        dword ptr [ebp-0Ch]
  141.   10001197: 83 EC 04           sub         esp,4
  142.   1000119A: DD C0              ffree       st(0)
  143.   1000119C: 50                 push        eax
  144.   1000119D: 56                 push        esi
  145.   1000119E: FF 75 08           push        dword ptr [ebp+8]
  146.   100011A1: E8 DC 02 00 00     call        10001482
  147.   100011A6: D9 5D F0           fstp        dword ptr [ebp-10h]
  148.   100011A9: 8D 45 F4           lea         eax,[ebp-0Ch]
  149.   100011AC: 50                 push        eax
  150.   100011AD: 56                 push        esi
  151.   100011AE: FF 75 08           push        dword ptr [ebp+8]
  152.   100011B1: E8 CC 02 00 00     call        10001482
  153.   100011B6: 83 C4 04           add         esp,4
  154.   100011B9: B8 00 00 00 00     mov         eax,0
  155.   100011BE: D8 6D F0           fsubr       dword ptr [ebp-10h]
  156.   100011C1: D8 0D C0 80 00 10  fmul        dword ptr ds:[100080C0h]
  157.   100011C7: DD D1              fst         st(1)
  158.   100011C9: D8 5D FC           fcomp       dword ptr [ebp-4]
  159.   100011CC: DF E0              fnstsw      ax
  160.   100011CE: 80 E4 41           and         ah,41h
  161.   100011D1: 75 03              jne         100011D6
  162.   100011D3: D9 55 FC           fst         dword ptr [ebp-4]
  163.   100011D6: 43                 inc         ebx
  164.   100011D7: 4F                 dec         edi
  165.   100011D8: 85 FF              test        edi,edi
  166.   100011DA: 7F 8E              jg          1000116A
  167.   100011DC: 8B 4D 18           mov         ecx,dword ptr [ebp+18h]
  168.   100011DF: 8B 45 14           mov         eax,dword ptr [ebp+14h]
  169.   100011E2: 8B 55 10           mov         edx,dword ptr [ebp+10h]
  170.   100011E5: 8B 5D 14           mov         ebx,dword ptr [ebp+14h]
  171.   100011E8: D9 01              fld         dword ptr [ecx]
  172.   100011EA: BF 01 00 00 00     mov         edi,1
  173.   100011EF: D8 20              fsub        dword ptr [eax]
  174.   100011F1: DD D9              fstp        st(1)
  175.   100011F3: D9 02              fld         dword ptr [edx]
  176.   100011F5: D8 23              fsub        dword ptr [ebx]
  177.   100011F7: D8 F1              fdiv        st,st(1)
  178.   100011F9: D8 0D C0 80 00 10  fmul        dword ptr ds:[100080C0h]
  179.   100011FF: 66 D9 7D F0        fnstcw      word ptr [ebp-10h]
  180.   10001203: 8B 45 F0           mov         eax,dword ptr [ebp-10h]
  181.   10001206: 0D 00 0C 00 00     or          eax,0C00h
  182.   1000120B: 66 89 45 F2        mov         word ptr [ebp-0Eh],ax
  183.   1000120F: 66 D9 6D F2        fldcw       word ptr [ebp-0Eh]
  184.   10001213: DB 5D FC           fistp       dword ptr [ebp-4]
  185.   10001216: 8B 45 FC           mov         eax,dword ptr [ebp-4]
  186.   10001219: 85 C0              test        eax,eax
  187.   1000121B: 66 D9 6D F0        fldcw       word ptr [ebp-10h]
  188.   1000121F: 7E 02              jle         10001223
  189.   10001221: 8B F8              mov         edi,eax
  190.   10001223: 83 FF 64           cmp         edi,64h
  191.   10001226: 7E 05              jle         1000122D
  192.   10001228: BF 64 00 00 00     mov         edi,64h
  193.   1000122D: 8D 55 F8           lea         edx,[ebp-8]
  194.   10001230: 89 7D FC           mov         dword ptr [ebp-4],edi
  195.   10001233: DB 45 FC           fild        dword ptr [ebp-4]
  196.   10001236: 89 7D FC           mov         dword ptr [ebp-4],edi
  197.   10001239: 8D 7D F4           lea         edi,[ebp-0Ch]
  198.   1000123C: D8 0D 98 80 00 10  fmul        dword ptr ds:[10008098h]
  199.   10001242: D8 35 C4 80 00 10  fdiv        dword ptr ds:[100080C4h]
  200.   10001248: D9 5D F8           fstp        dword ptr [ebp-8]
  201.   1000124B: DB 45 FC           fild        dword ptr [ebp-4]
  202.   1000124E: D8 25 98 80 00 10  fsub        dword ptr ds:[10008098h]
  203.   10001254: D8 35 C4 80 00 10  fdiv        dword ptr ds:[100080C4h]
  204.   1000125A: D9 5D F4           fstp        dword ptr [ebp-0Ch]
  205.   1000125D: 83 EC 04           sub         esp,4
  206.   10001260: DD C0              ffree       st(0)
  207.   10001262: 52                 push        edx
  208.   10001263: 56                 push        esi
  209.   10001264: FF 75 08           push        dword ptr [ebp+8]
  210.   10001267: E8 16 02 00 00     call        10001482
  211.   1000126C: DD C0              ffree       st(0)
  212.   1000126E: D9 F7              fincstp
  213.   10001270: 57                 push        edi
  214.   10001271: 56                 push        esi
  215.   10001272: FF 75 08           push        dword ptr [ebp+8]
  216.   10001275: E8 08 02 00 00     call        10001482
  217.   1000127A: DD C0              ffree       st(0)
  218.   1000127C: D9 F7              fincstp
  219.   1000127E: 83 C4 04           add         esp,4
  220.   10001281: 8B 5D 1C           mov         ebx,dword ptr [ebp+1Ch]
  221.   10001284: 8B 7D F8           mov         edi,dword ptr [ebp-8]
  222.   10001287: 89 3B              mov         dword ptr [ebx],edi
  223.   10001289: 5F                 pop         edi
  224.   1000128A: 5E                 pop         esi
  225.   1000128B: 5B                 pop         ebx
  226.   1000128C: 8B E5              mov         esp,ebp
  227.   1000128E: 5D                 pop         ebp
  228.   1000128F: C2 18 00           ret         18h
  229.   10001292: 55                 push        ebp
  230.   10001293: 8B EC              mov         ebp,esp
  231.   10001295: 83 EC 0C           sub         esp,0Ch
  232.   10001298: 53                 push        ebx
  233.   10001299: 56                 push        esi
  234.   1000129A: 57                 push        edi
  235.   1000129B: 8B 7D 10           mov         edi,dword ptr [ebp+10h]
  236.   1000129E: 8B 05 B8 80 00 10  mov         eax,dword ptr ds:[100080B8h]
  237.   100012A4: BB E8 03 00 00     mov         ebx,3E8h
  238.   100012A9: 89 07              mov         dword ptr [edi],eax
  239.   100012AB: BE 01 00 00 00     mov         esi,1
  240.   100012B0: 89 75 FC           mov         dword ptr [ebp-4],esi
  241.   100012B3: 89 75 F8           mov         dword ptr [ebp-8],esi
  242.   100012B6: DB 45 FC           fild        dword ptr [ebp-4]
  243.   100012B9: 8D 45 FC           lea         eax,[ebp-4]
  244.   100012BC: D8 0D 98 80 00 10  fmul        dword ptr ds:[10008098h]
  245.   100012C2: D8 35 BC 80 00 10  fdiv        dword ptr ds:[100080BCh]
  246.   100012C8: D9 5D FC           fstp        dword ptr [ebp-4]
  247.   100012CB: DB 45 F8           fild        dword ptr [ebp-8]
  248.   100012CE: D8 25 98 80 00 10  fsub        dword ptr ds:[10008098h]
  249.   100012D4: D8 35 BC 80 00 10  fdiv        dword ptr ds:[100080BCh]
  250.   100012DA: D9 5D F8           fstp        dword ptr [ebp-8]
  251.   100012DD: 83 EC 04           sub         esp,4
  252.   100012E0: DD C0              ffree       st(0)
  253.   100012E2: 50                 push        eax
  254.   100012E3: FF 75 0C           push        dword ptr [ebp+0Ch]
  255.   100012E6: FF 75 08           push        dword ptr [ebp+8]
  256.   100012E9: E8 94 01 00 00     call        10001482
  257.   100012EE: D9 5D F4           fstp        dword ptr [ebp-0Ch]
  258.   100012F1: 8D 45 F8           lea         eax,[ebp-8]
  259.   100012F4: 50                 push        eax
  260.   100012F5: FF 75 0C           push        dword ptr [ebp+0Ch]
  261.   100012F8: FF 75 08           push        dword ptr [ebp+8]
  262.   100012FB: E8 82 01 00 00     call        10001482
  263.   10001300: 83 C4 04           add         esp,4
  264.   10001303: B8 00 00 00 00     mov         eax,0
  265.   10001308: D8 6D F4           fsubr       dword ptr [ebp-0Ch]
  266.   1000130B: 8B 4D 14           mov         ecx,dword ptr [ebp+14h]
  267.   1000130E: DD D1              fst         st(1)
  268.   10001310: D8 1F              fcomp       dword ptr [edi]
  269.   10001312: DF E0              fnstsw      ax
  270.   10001314: 80 E4 41           and         ah,41h
  271.   10001317: 75 07              jne         10001320
  272.   10001319: D9 17              fst         dword ptr [edi]
  273.   1000131B: 8B 45 FC           mov         eax,dword ptr [ebp-4]
  274.   1000131E: 89 01              mov         dword ptr [ecx],eax
  275.   10001320: 46                 inc         esi
  276.   10001321: 4B                 dec         ebx
  277.   10001322: 85 DB              test        ebx,ebx
  278.   10001324: 7F 8A              jg          100012B0
  279.   10001326: DD C0              ffree       st(0)
  280.   10001328: 5F                 pop         edi
  281.   10001329: 5E                 pop         esi
  282.   1000132A: 5B                 pop         ebx
  283.   1000132B: 8B E5              mov         esp,ebp
  284.   1000132D: 5D                 pop         ebp
  285.   1000132E: C2 10 00           ret         10h
  286.   10001331: 55                 push        ebp
  287.   10001332: 8B EC              mov         ebp,esp
  288.   10001334: 83 EC 1C           sub         esp,1Ch
  289.   10001337: 53                 push        ebx
  290.   10001338: 8B 45 08           mov         eax,dword ptr [ebp+8]
  291.   1000133B: D9 05 98 80 00 10  fld         dword ptr ds:[10008098h]
  292.   10001341: 8B 55 0C           mov         edx,dword ptr [ebp+0Ch]
  293.   10001344: 8B 4D 10           mov         ecx,dword ptr [ebp+10h]
  294.   10001347: DD D9              fstp        st(1)
  295.   10001349: D9 05 98 80 00 10  fld         dword ptr ds:[10008098h]
  296.   1000134F: 8B 1D 98 80 00 10  mov         ebx,dword ptr ds:[10008098h]
  297.   10001355: DD DA              fstp        st(2)
  298.  
  299.  

y la DLL en C++ que genero y que hace referencia a esta de fortran con el dumpbin
Código: Text
  1.  
  2. Microsoft (R) COFF Binary File Dumper Version 6.00.8168
  3. Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
  4.  
  5.  
  6. Dump of file hbvmodelapi.dll
  7.  
  8. File Type: DLL
  9.  
  10.   10001000: 56                 push        esi
  11.   10001001: 8B 74 24 08        mov         esi,dword ptr [esp+8]
  12.   10001005: 57                 push        edi
  13.   10001006: 8B 7C 24 14        mov         edi,dword ptr [esp+14h]
  14.   1000100A: 8B 06              mov         eax,dword ptr [esi]
  15.   1000100C: 6A 00              push        0
  16.   1000100E: 57                 push        edi
  17.   1000100F: 56                 push        esi
  18.   10001010: FF 90 A4 02 00 00  call        dword ptr [eax+000002A4h]
  19.   10001016: 50                 push        eax
  20.   10001017: 68 30 80 00 10     push        10008030h
  21.   1000101C: E8 9F 00 00 00     call        100010C0
  22.   10001021: 8B 0E              mov         ecx,dword ptr [esi]
  23.   10001023: 83 C4 08           add         esp,8
  24.   10001026: 6A 00              push        0
  25.   10001028: 57                 push        edi
  26.   10001029: 56                 push        esi
  27.   1000102A: FF 91 A8 02 00 00  call        dword ptr [ecx+000002A8h]
  28.   10001030: 5F                 pop         edi
  29.   10001031: B0 01              mov         al,1
  30.   10001033: 5E                 pop         esi
  31.   10001034: C2 0C 00           ret         0Ch
  32.   10001037: 90                 nop
  33.   10001038: 90                 nop
  34.   10001039: 90                 nop
  35.   1000103A: 90                 nop
  36.   1000103B: 90                 nop
  37.   1000103C: 90                 nop
  38.   1000103D: 90                 nop
  39.   1000103E: 90                 nop
  40.   1000103F: 90                 nop
  41.   10001040: 68 4C 80 00 10     push        1000804Ch
  42.   10001045: E8 76 00 00 00     call        100010C0
  43.   1000104A: 68 34 80 00 10     push        10008034h
  44.   1000104F: E8 6C 00 00 00     call        100010C0
  45.   10001054: DD 44 24 1C        fld         qword ptr [esp+1Ch]
  46.   10001058: 83 C4 08           add         esp,8
  47.   1000105B: C2 18 00           ret         18h
  48.   1000105E: 90                 nop
  49.   1000105F: 90                 nop
  50.   10001060: 8D 44 24 48        lea         eax,[esp+48h]
  51.   10001064: 8D 4C 24 44        lea         ecx,[esp+44h]
  52.   10001068: 50                 push        eax
  53.   10001069: 8D 54 24 44        lea         edx,[esp+44h]
  54.   1000106D: 51                 push        ecx
  55.   1000106E: 8B 4C 24 3C        mov         ecx,dword ptr [esp+3Ch]
  56.   10001072: 8D 44 24 44        lea         eax,[esp+44h]
  57.   10001076: 52                 push        edx
  58.   10001077: 50                 push        eax
  59.   10001078: 8D 54 24 40        lea         edx,[esp+40h]
  60.   1000107C: 51                 push        ecx
  61.   1000107D: 8D 44 24 40        lea         eax,[esp+40h]
  62.   10001081: 52                 push        edx
  63.   10001082: 8D 4C 24 40        lea         ecx,[esp+40h]
  64.   10001086: 50                 push        eax
  65.   10001087: 8D 54 24 40        lea         edx,[esp+40h]
  66.   1000108B: 51                 push        ecx
  67.   1000108C: 8D 44 24 40        lea         eax,[esp+40h]
  68.   10001090: 52                 push        edx
  69.   10001091: 8D 4C 24 40        lea         ecx,[esp+40h]
  70.   10001095: 50                 push        eax
  71.   10001096: 8D 54 24 40        lea         edx,[esp+40h]
  72.   1000109A: 51                 push        ecx
  73.   1000109B: 8B 4C 24 38        mov         ecx,dword ptr [esp+38h]
  74.   1000109F: 8D 44 24 40        lea         eax,[esp+40h]
  75.   100010A3: 52                 push        edx
  76.   100010A4: 50                 push        eax
  77.   100010A5: 51                 push        ecx
  78.   100010A6: E8 29 60 00 00     call        100070D4
  79.   100010AB: 83 C4 38           add         esp,38h
  80.   100010AE: C2 48 00           ret         48h
  81.   100010B1: 90                 nop
  82.   100010B2: 90                 nop
  83.   100010B3: 90                 nop
  84.   100010B4: 90                 nop
  85.   100010B5: 90                 nop
  86.   100010B6: 90                 nop
  87.   100010B7: 90                 nop
  88.   100010B8: 90                 nop
  89.   100010B9: 90                 nop
  90.   100010BA: 90                 nop
  91.   100010BB: 90                 nop
  92.   100010BC: 90                 nop
  93.   100010BD: 90                 nop
  94.   100010BE: 90                 nop
  95.   100010BF: 90                 nop
  96.   100010C0: 53                 push        ebx
  97.   100010C1: 56                 push        esi
  98.   100010C2: BE A0 80 00 10     mov         esi,100080A0h
  99.   100010C7: 57                 push        edi
  100.   100010C8: 56                 push        esi
  101.   100010C9: 6A 01              push        1
  102.   100010CB: E8 15 03 00 00     call        100013E5
  103.   100010D0: 56                 push        esi
  104.   100010D1: E8 84 03 00 00     call        1000145A
  105.   100010D6: 8B F8              mov         edi,eax
  106.   100010D8: 8D 44 24 20        lea         eax,[esp+20h]
  107.   100010DC: 50                 push        eax
  108.   100010DD: FF 74 24 20        push        dword ptr [esp+20h]
  109.   100010E1: 56                 push        esi
  110.   100010E2: E8 2A 04 00 00     call        10001511
  111.   100010E7: 56                 push        esi
  112.   100010E8: 57                 push        edi
  113.   100010E9: 8B D8              mov         ebx,eax
  114.   100010EB: E8 F7 03 00 00     call        100014E7
  115.   100010F0: 56                 push        esi
  116.   100010F1: 6A 01              push        1
  117.   100010F3: E8 3F 03 00 00     call        10001437
  118.   100010F8: 83 C4 28           add         esp,28h
  119.   100010FB: 8B C3              mov         eax,ebx
  120.   100010FD: 5F                 pop         edi
  121.   100010FE: 5E                 pop         esi
  122.   100010FF: 5B                 pop         ebx
  123.   10001100: C3                 ret
  124.   10001101: E8 13 00 00 00     call        10001119
  125.   10001106: E8 60 0C 00 00     call        10001D6B
  126.   1000110B: A3 F4 8F 00 10     mov         [10008FF4],eax
  127.   10001110: E8 06 0C 00 00     call        10001D1B
  128.   10001115: DB E2              fnclex
  129.   10001117: C3                 ret
  130.  
  131.  

yo sinceramente, no soy capaz de ver en este código lo de la convención de llamada que comentas, si pudieras apuntarme algo sería genial.

y gracias de nuevo!

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #15 en: Miércoles 28 de Noviembre de 2007, 18:52 »
0
Es simple hasta cierto punto, fijate los ret, aunque al no estar completa no puedo estar 100% seguro. En este caso esta claro que las funciones de la DLL de Fortran estan usando stdcall (las que se ven al menos) y por lo tanto cuando tu ejecutable intente acomodar la pila en realidad la jodera ...

En tu ejecutable, convencion de llamada C:
//primero se pasan todos los parametros en la pila
//se llama a la funcion (se que es esta por la cantidad ENORME - por eso decia que ese prototipo era vomitivo - de parametros)
100010A6: E8 29 60 00 00     call        100070D4
//intenta arreglar la pila pero como no es una funcion de convencion C la termina jodiendo
100010AB: 83 C4 38           add         esp,38h (56/4=14 parametros)

Para comprobar esta teoria podrias hacer esto en la siguiente linea justo tras llamar esta funcion:
Código: Text
  1.  
  2. __asm sub esp, 0x38
  3.  
  4.  

Si eso lo soluciona evidentemente NO es la forma de hacerlo y tendrias que pedirle mas explicaciones a tu amigo (si esta usando un .DEF, si puede cambiar la convencion de llamada, como esta enlazando, etc, etc, etc) o usar enlazado dinamico  :kicking: De esta manera:

typedef void (__stdcall *tuwhbv_ptr)(long,float&,float&,float&,float&,float&,float&,float&,float&,long,float&,float&,float&,float&);
tuwhbv_ptr tuwhbv = 0;

Despues en donde inicies usas LoadLibrary para cargar la DLL en cuestion y GetProcAddress para obtener la direccion de la funcion que se la asignaras a tuwhbv. De esa manera al usar stdcall no deberia dar ningun fallo.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #16 en: Jueves 29 de Noviembre de 2007, 11:52 »
0
Pues he puesta la linea esta de ensamblador delante de la llamada a la función externa y obtengo el mismo error. He optado por probar el enlace dinámico y en lugar de enlazar el .lib, llamar directamente a la DLL como me has comentado.
Al hacer esto, y generando mi DLL en C++, la llamo desde mi código de Java y sigo teniendo el ACCESS VIOLATION, el cambio es que el "Problematic Frame" que me da el error cambia: usando el enlace estático el problema de java apunta a la DLL que genero en C++, y usando el enlace dinámico el error de la VM me apunta como problema a la DLL de fortran.
La persona que ha hecho el código fortran es un hidrólogo sin muchos conocimientos informaticos y me ha pasado el log que le genera su entorno visual cuando genera la DLL.
Código: Text
  1.  
  2. # Microsoft Developer Studio Generated NMAKE File, Based on tuwhbv.dsp
  3. !IF "$(CFG)" == ""
  4. CFG=tuwhbv - Win32 Debug
  5. !MESSAGE No configuration specified. Defaulting to tuwhbv - Win32 Debug.
  6. !ENDIF
  7.  
  8. !IF "$(CFG)" != "tuwhbv - Win32 Release" && "$(CFG)" != "tuwhbv - Win32 Debug"
  9. !MESSAGE Invalid configuration "$(CFG)" specified.
  10. !MESSAGE You can specify a configuration when running NMAKE
  11. !MESSAGE by defining the macro CFG on the command line. For example:
  12. !MESSAGE
  13. !MESSAGE NMAKE /f "tuwhbv.mak" CFG="tuwhbv - Win32 Debug"
  14. !MESSAGE
  15. !MESSAGE Possible choices for configuration are:
  16. !MESSAGE
  17. !MESSAGE "tuwhbv - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
  18. !MESSAGE "tuwhbv - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
  19. !MESSAGE
  20. !ERROR An invalid configuration is specified.
  21. !ENDIF
  22.  
  23. !IF "$(OS)" == "Windows_NT"
  24. NULL=
  25. !ELSE
  26. NULL=nul
  27. !ENDIF
  28.  
  29. !IF  "$(CFG)" == "tuwhbv - Win32 Release"
  30.  
  31. OUTDIR=.\Release
  32. INTDIR=.\Release
  33. # Begin Custom Macros
  34. OutDir=.\Release
  35. # End Custom Macros
  36.  
  37. ALL : "$(OUTDIR)\tuwhbv.dll"
  38.  
  39.  
  40. CLEAN :
  41.   -@erase "$(INTDIR)\BETAFUNC.mod"
  42.   -@erase "$(INTDIR)\betafunc.obj"
  43.   -@erase "$(INTDIR)\datetrans.mod"
  44.   -@erase "$(INTDIR)\datetrans.obj"
  45.   -@erase "$(INTDIR)\hbvmodel.mod"
  46.   -@erase "$(INTDIR)\hbvmodel.obj"
  47.   -@erase "$(INTDIR)\Parameters.mod"
  48.   -@erase "$(INTDIR)\parameters.obj"
  49.   -@erase "$(INTDIR)\SCECALIB.mod"
  50.   -@erase "$(INTDIR)\scecalib.obj"
  51.   -@erase "$(INTDIR)\tuwhbv.obj"
  52.   -@erase "$(OUTDIR)\tuwhbv.dll"
  53.   -@erase "$(OUTDIR)\tuwhbv.exp"
  54.   -@erase "$(OUTDIR)\tuwhbv.lib"
  55.  
  56. "$(OUTDIR)" :
  57.     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
  58.  
  59. F90=df.exe
  60. F90_PROJ=/compile_only /dbglibs /dll /nologo /warn:nofileopt /module:"Release/" /object:"Release/"
  61. F90_OBJS=.\Release/
  62.  
  63. .SUFFIXES: .fpp
  64.  
  65. .for{$(F90_OBJS)}.obj:
  66.    $(F90) $(F90_PROJ) $<  
  67.  
  68. .f{$(F90_OBJS)}.obj:
  69.    $(F90) $(F90_PROJ) $<  
  70.  
  71. .f90{$(F90_OBJS)}.obj:
  72.    $(F90) $(F90_PROJ) $<  
  73.  
  74. .fpp{$(F90_OBJS)}.obj:
  75.    $(F90) $(F90_PROJ) $<  
  76.  
  77. CPP=cl.exe
  78. CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Fp"$(INTDIR)\tuwhbv.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
  79.  
  80. .c{$(INTDIR)}.obj::
  81.    $(CPP) @<<
  82.    $(CPP_PROJ) $<
  83. <<
  84.  
  85. .cpp{$(INTDIR)}.obj::
  86.    $(CPP) @<<
  87.    $(CPP_PROJ) $<
  88. <<
  89.  
  90. .cxx{$(INTDIR)}.obj::
  91.    $(CPP) @<<
  92.    $(CPP_PROJ) $<
  93. <<
  94.  
  95. .c{$(INTDIR)}.sbr::
  96.    $(CPP) @<<
  97.    $(CPP_PROJ) $<
  98. <<
  99.  
  100. .cpp{$(INTDIR)}.sbr::
  101.    $(CPP) @<<
  102.    $(CPP_PROJ) $<
  103. <<
  104.  
  105. .cxx{$(INTDIR)}.sbr::
  106.    $(CPP) @<<
  107.    $(CPP_PROJ) $<
  108. <<
  109.  
  110. MTL=midl.exe
  111. MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
  112. RSC=rc.exe
  113. BSC32=bscmake.exe
  114. BSC32_FLAGS=/nologo /o"$(OUTDIR)\tuwhbv.bsc"
  115. BSC32_SBRS= \
  116.  
  117. LINK32=link.exe
  118. LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\tuwhbv.pdb" /machine:I386 /out:"$(OUTDIR)\tuwhbv.dll" /implib:"$(OUTDIR)\tuwhbv.lib"
  119. LINK32_OBJS= \
  120.   "$(INTDIR)\betafunc.obj" \
  121.   "$(INTDIR)\datetrans.obj" \
  122.   "$(INTDIR)\hbvmodel.obj" \
  123.   "$(INTDIR)\parameters.obj" \
  124.   "$(INTDIR)\scecalib.obj" \
  125.   "$(INTDIR)\tuwhbv.obj"
  126.  
  127. "$(OUTDIR)\tuwhbv.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
  128.     $(LINK32) @<<
  129.   $(LINK32_FLAGS) $(LINK32_OBJS)
  130. <<
  131.  
  132. !ELSEIF  "$(CFG)" == "tuwhbv - Win32 Debug"
  133.  
  134. OUTDIR=.\Debug
  135. INTDIR=.\Debug
  136. # Begin Custom Macros
  137. OutDir=.\Debug
  138. # End Custom Macros
  139.  
  140. ALL : "$(OUTDIR)\tuwhbv.dll"
  141.  
  142.  
  143. CLEAN :
  144.   -@erase "$(INTDIR)\BETAFUNC.mod"
  145.   -@erase "$(INTDIR)\betafunc.obj"
  146.   -@erase "$(INTDIR)\datetrans.mod"
  147.   -@erase "$(INTDIR)\datetrans.obj"
  148.   -@erase "$(INTDIR)\DF60.PDB"
  149.   -@erase "$(INTDIR)\hbvmodel.mod"
  150.   -@erase "$(INTDIR)\hbvmodel.obj"
  151.   -@erase "$(INTDIR)\Parameters.mod"
  152.   -@erase "$(INTDIR)\parameters.obj"
  153.   -@erase "$(INTDIR)\SCECALIB.mod"
  154.   -@erase "$(INTDIR)\scecalib.obj"
  155.   -@erase "$(INTDIR)\tuwhbv.obj"
  156.   -@erase "$(OUTDIR)\tuwhbv.dll"
  157.   -@erase "$(OUTDIR)\tuwhbv.exp"
  158.   -@erase "$(OUTDIR)\tuwhbv.lib"
  159.   -@erase "$(OUTDIR)\tuwhbv.pdb"
  160.  
  161. "$(OUTDIR)" :
  162.     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
  163.  
  164. F90=df.exe
  165. F90_PROJ=/check:bounds /compile_only /dbglibs /debug:full /dll /libs:static /nologo /traceback /warn:argument_checking /warn:nofileopt /winapp /module:"Debug/" /object:"Debug/" /pdbfile:"Debug/DF60.PDB"
  166. F90_OBJS=.\Debug/
  167.  
  168. .SUFFIXES: .fpp
  169.  
  170. .for{$(F90_OBJS)}.obj:
  171.    $(F90) $(F90_PROJ) $<  
  172.  
  173. .f{$(F90_OBJS)}.obj:
  174.    $(F90) $(F90_PROJ) $<  
  175.  
  176. .f90{$(F90_OBJS)}.obj:
  177.    $(F90) $(F90_PROJ) $<  
  178.  
  179. .fpp{$(F90_OBJS)}.obj:
  180.    $(F90) $(F90_PROJ) $<  
  181.  
  182. CPP=cl.exe
  183. CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Fp"$(INTDIR)\tuwhbv.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
  184.  
  185. .c{$(INTDIR)}.obj::
  186.    $(CPP) @<<
  187.    $(CPP_PROJ) $<
  188. <<
  189.  
  190. .cpp{$(INTDIR)}.obj::
  191.    $(CPP) @<<
  192.    $(CPP_PROJ) $<
  193. <<
  194.  
  195. .cxx{$(INTDIR)}.obj::
  196.    $(CPP) @<<
  197.    $(CPP_PROJ) $<
  198. <<
  199.  
  200. .c{$(INTDIR)}.sbr::
  201.    $(CPP) @<<
  202.    $(CPP_PROJ) $<
  203. <<
  204.  
  205. .cpp{$(INTDIR)}.sbr::
  206.    $(CPP) @<<
  207.    $(CPP_PROJ) $<
  208. <<
  209.  
  210. .cxx{$(INTDIR)}.sbr::
  211.    $(CPP) @<<
  212.    $(CPP_PROJ) $<
  213. <<
  214.  
  215. MTL=midl.exe
  216. MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
  217. RSC=rc.exe
  218. BSC32=bscmake.exe
  219. BSC32_FLAGS=/nologo /o"$(OUTDIR)\tuwhbv.bsc"
  220. BSC32_SBRS= \
  221.  
  222. LINK32=link.exe
  223. LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\tuwhbv.pdb" /debug /machine:I386 /out:"$(OUTDIR)\tuwhbv.dll" /implib:"$(OUTDIR)\tuwhbv.lib" /pdbtype:sept
  224. LINK32_OBJS= \
  225.   "$(INTDIR)\betafunc.obj" \
  226.   "$(INTDIR)\datetrans.obj" \
  227.   "$(INTDIR)\hbvmodel.obj" \
  228.   "$(INTDIR)\parameters.obj" \
  229.   "$(INTDIR)\scecalib.obj" \
  230.   "$(INTDIR)\tuwhbv.obj"
  231.  
  232. "$(OUTDIR)\tuwhbv.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
  233.     $(LINK32) @<<
  234.   $(LINK32_FLAGS) $(LINK32_OBJS)
  235. <<
  236.  
  237. !ENDIF
  238.  
  239.  
  240. !IF "$(NO_EXTERNAL_DEPS)" != "1"
  241. !IF EXISTS("tuwhbv.dep")
  242. !INCLUDE "tuwhbv.dep"
  243. !ELSE
  244. !MESSAGE Warning: cannot find "tuwhbv.dep"
  245. !ENDIF
  246. !ENDIF
  247.  
  248.  
  249. !IF "$(CFG)" == "tuwhbv - Win32 Release" || "$(CFG)" == "tuwhbv - Win32 Debug"
  250. SOURCE=.\betafunc.for
  251. F90_MODOUT=\
  252.   "BETAFUNC"
  253.  
  254.  
  255. "$(INTDIR)\betafunc.obj"  "$(INTDIR)\BETAFUNC.mod" : $(SOURCE) "$(INTDIR)"
  256.   $(F90) $(F90_PROJ) $(SOURCE)
  257.  
  258.  
  259. SOURCE=.\datetrans.for
  260. F90_MODOUT=\
  261.   "DATETRANS"
  262.  
  263.  
  264. "$(INTDIR)\datetrans.obj"  "$(INTDIR)\datetrans.mod" : $(SOURCE) "$(INTDIR)"
  265.   $(F90) $(F90_PROJ) $(SOURCE)
  266.  
  267.  
  268. SOURCE=.\hbvmodel.for
  269. F90_MODOUT=\
  270.   "HBVMODEL"
  271.  
  272.  
  273. "$(INTDIR)\hbvmodel.obj"  "$(INTDIR)\hbvmodel.mod" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\Parameters.mod"
  274.   $(F90) $(F90_PROJ) $(SOURCE)
  275.  
  276.  
  277. SOURCE=.\parameters.f90
  278. F90_MODOUT=\
  279.   "PARAMETERS"
  280.  
  281.  
  282. "$(INTDIR)\parameters.obj"  "$(INTDIR)\Parameters.mod" : $(SOURCE) "$(INTDIR)"
  283.   $(F90) $(F90_PROJ) $(SOURCE)
  284.  
  285.  
  286. SOURCE=.\scecalib.for
  287. F90_MODOUT=\
  288.   "SCECALIB"
  289.  
  290.  
  291. "$(INTDIR)\scecalib.obj"  "$(INTDIR)\SCECALIB.mod" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\Parameters.mod" "$(INTDIR)\hbvmodel.mod" "$(INTDIR)\BETAFUNC.mod"
  292.   $(F90) $(F90_PROJ) $(SOURCE)
  293.  
  294.  
  295. SOURCE=..\tuwhbv.f90
  296.  
  297. "$(INTDIR)\tuwhbv.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\SCECALIB.mod" "$(INTDIR)\Parameters.mod" "$(INTDIR)\hbvmodel.mod" "$(INTDIR)\datetrans.mod" "$(INTDIR)\BETAFUNC.mod"
  298.   $(F90) $(F90_PROJ) $(SOURCE)
  299.  
  300.  
  301.  
  302. !ENDIF
  303.  
  304.  
  305.  

puedes ver en esto a lo que te refererias de la convencion de llamada? no se bien como continuar?
Crees que seria una buena idea, que el cambie su proyecto para que le genere una libreria estática? de forma que quizas se cambie la forma de llamar a las librerias que utiliza?
He comprobado que las DLL que el utiliza dentro de su DLL estan todas en el path, así que en principio ese no debería ser el problema, verdad?

y gracias por tu tiempo, a este paso te voy a deber unas cervezas! :)

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #17 en: Jueves 29 de Noviembre de 2007, 16:12 »
0
Cita de: "LauraDiaz"
Pues he puesta la linea esta de ensamblador delante de la llamada a la función externa y obtengo el mismo error.

¿Antes o despues lo pusiste? Tiene que ser asi:
Código: Text
  1.  
  2. tuwhbv(params);
  3. __asm sub esp, 0x38
  4.  
  5.  

Cita de: "LauraDiaz"
He optado por probar el enlace dinámico y en lugar de enlazar el .lib, llamar directamente a la DLL como me has comentado.
Al hacer esto, y generando mi DLL en C++, la llamo desde mi código de Java y sigo teniendo el ACCESS VIOLATION, el cambio es que el "Problematic Frame" que me da el error cambia: usando el enlace estático el problema de java apunta a la DLL que genero en C++, y usando el enlace dinámico el error de la VM me apunta como problema a la DLL de fortran.

Por favor deja fuera del problema a Java, hace un programa simple que use la DLL de C++ que a su vez usa la DLL de Fortran.

Cita de: "LauraDiaz"
puedes ver en esto a lo que te refererias de la convencion de llamada? no se bien como continuar?
Crees que seria una buena idea, que el cambie su proyecto para que le genere una libreria estática? de forma que quizas se cambie la forma de llamar a las librerias que utiliza?

Si, me imagino que ese es el problema, al menos entre C++ y Fortran. No se si servira que genere una libreria estatica realmente, pueden hacer la prueba pero no lo se.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #18 en: Viernes 30 de Noviembre de 2007, 12:32 »
0
la línea que me comentaste la he probado delante y detras de la función externa y lo mismo. En cuanto a dejar Java fuera, eso he hecho, es un programa de pocas lineas que simplemente carga la DLL y con eso no hay problema.
Ahora mismo, el programa en C++ ha quedado así:
Código: Text
  1.  
  2. typedef void (__stdcall *tuwhbv_ptr)(long,float&,float&,float&,float&,float&,float&,float&,float&,long,float&,float&,float&,float&);
  3. tuwhbv_ptr tuwhbv = 0;
  4.  
  5. JNIEXPORT void JNICALL Java_edu_uji_aware_hbv_HBVModel_hbv
  6. (JNIEnv *env, jobject obj, jlong flag, jfloat ages, jfloat incon, jfloat inputt, jfloat gobs, jfloat modisa, jfloat param, jfloat lb, jfloat ub, jlong calid, jfloat weight, jfloat parfin, jfloat effin, jfloat output)
  7. {
  8.     HINSTANCE hLib;      
  9.     hLib = LoadLibrary("tuwhbv.dll");
  10.      if(hLib!=0){
  11.          tuwhbv = (void (__stdcall *)(long,float&,float&,float&,float&,float&,float&,float&,float&,long,float&,float&,float&,float&)) GetProcAddress(hLib,"tuwhbv");
  12.          tuwhbv(flag, ages, incon,inputt,gobs,modisa,param,lb,ub,calid,weight,parfin,effin,output);                                      
  13.      }
  14.      FreeLibrary(hLib);
  15. }
  16.  
  17.  


y el error sigue siendo el mismo:

# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0b186404, pid=3592, tid=2516
#
# Java VM: Java HotSpot™ Client VM (1.5.0_08-b03 mixed mode)
# Problematic frame:
# C  [tuwhbv.dll+0x6404]

las librerias que usa el tuwhbv.dll estan todas disponibles,y abriendolo con el dependency walker todo tiene buena pinta. Alguna idea de como quitarme de encima este access violation?
gracias y un saludo!

Eternal Idol

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #19 en: Viernes 30 de Noviembre de 2007, 13:39 »
0
Si la parte de Fortran y C++ funciona bien y el problema ahora es con Java yo no te puedo ayudar, no tengo experiencia ni tiempo para conseguirla. Proba a preguntar en el subforo de Java, tal vez ahi alguien sepa.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #20 en: Lunes 3 de Diciembre de 2007, 15:12 »
0
Hola,
el problema no es con Java, sigue siendo con la llamada al método de fortran desde C++. Después de estar mirando algunas cosas, creo que  el problema puede ser el paso de punteros en la llamada a la función del .lib de fortran. Muchas gracias por toda tu ayuda  en cuanto lo tenga solucionado os contaré cual era el problema.

txalupa

  • Nuevo Miembro
  • *
  • Mensajes: 3
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #21 en: Lunes 10 de Diciembre de 2007, 15:35 »
0
Hola Laura,
oye, ¿te importaría explicarme cómo has hecho para crear una DLL en Visual C++?

¿Cómo has conseguido que dicha DLL enlace con la librería de Fortran?

Te agradecería tu ayuda.

Muchas gracias.

Txalupa.

LauraDiaz

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #22 en: Martes 11 de Diciembre de 2007, 17:37 »
0
Hola Txalupa,

1. Usando Visual C++ puedes crear un proyecto nuevo (una DLL) donde añadas una libreria (*.lib) en fortran, enlace estático, si lo que tienes es una dll en fortran, tienes que cargarlo dinamicamente y creo que anteriormente en esta mismo hilo hay un ejemplo de como hacerlo
3.El código en C que realiza una llamada a una funcion dentro de la libreria de fortran es algo así:
Código: Text
  1.  
  2. #include "stdafx.h"
  3.  
  4. extern "C"
  5. {
  6.  void _sumaf(double, double);
  7. };
  8.  
  9. JNIEXPORT jdouble JNICALL Java_suma
  10.   (JNIEnv *env, jobject obj, jdouble a, jdouble B)
  11. {
  12.  return sumaf(a,B);
  13. }
  14.  
  15.  

Segun el compilador de fortran que se haya utilizado le pondra a las funciones exportadas algun que otro sufijo o prefijo, para asegurarte que pones en nombre bien en tu código C, puedes utilizar algunos de los consejos que Eternal Idol sugirió en mensajes previos también en este mismo hilo.
 
bueno,  espero que te sirva de ayuda.

suerte.
Laura.

jara81

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Re: C++ Con Dll De Fortran
« Respuesta #23 en: Viernes 26 de Noviembre de 2010, 20:55 »
0
Hola Laura

tengo el mismo problema que tú con la dll de fortran. Al final pudiste solucionar el problema? còmo??? estoy desesperada porque llevo ya unos cuantos días anclada en  el mismo problema....

gracias y un saludo