Foros del Web » Programación para mayores de 30 ;) » C/C++ »

Problemas con DLL en C++

Estas en el tema de Problemas con DLL en C++ en el foro de C/C++ en Foros del Web. Buenas, soy nuevo en C++ y he aprendido un poco lo básico para hacer un trabajito puntual. Estoy haciendo un programa para enviar un e-mail. ...
  #1 (permalink)  
Antiguo 07/09/2011, 11:09
 
Fecha de Ingreso: septiembre-2011
Mensajes: 22
Antigüedad: 12 años, 7 meses
Puntos: 1
Problemas con DLL en C++

Buenas, soy nuevo en C++ y he aprendido un poco lo básico para hacer un trabajito puntual.

Estoy haciendo un programa para enviar un e-mail. Me he basado en [URL="http://www.marshallsoft.com/"]SEE4C SMTP/POP3/IMAP Email Engine Library for C/C++ and .NET[/URL] que contiene un DLL.
Bueno, he hecho este esbozo del futuro programa con los ejemplos que da pero al compilar me dice "[linker error] undefined reference to" y a continuacion todas las funciones ejecutadas que tendrían que salir del DLL.

(*)


He estado buscando pero no he encontrado salucion para arreglar el error.

(*) Es muy grande el código y no me deja publicarlo, ¿cómo lo puedo subir?
  #2 (permalink)  
Antiguo 07/09/2011, 11:11
 
Fecha de Ingreso: septiembre-2011
Mensajes: 22
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: Problemas con DLL en C++

PARTE 1

Código C++:
Ver original
  1. #include <windows.h>
  2. #include <stdio.h>
  3.  
  4. #ifdef STATIC_LIBRARY
  5.    #define DLL_IMPORT_EXPORT
  6. #else
  7.    #ifdef DLL_SOURCE_CODE
  8.       #define DLL_IMPORT_EXPORT __declspec(dllexport) __stdcall
  9.    #else
  10.       #define DLL_IMPORT_EXPORT __declspec(dllimport) __stdcall
  11.    #endif
  12. #endif
  13.  
  14. #ifdef __cplusplus
  15.   #define NoMangle extern "C"
  16. #else
  17.   #define NoMangle
  18. #endif
  19.  
  20. #define SEE_MIN_RESPONSE_WAIT   1
  21. #define SEE_MAX_RESPONSE_WAIT   2
  22. #define SEE_CONNECT_WAIT        3
  23. #define SEE_DISABLE_MIME        4
  24. #define SEE_QUOTED_PRINTABLE    8
  25. #define SEE_AUTO_CALL_DRIVER    9
  26. #define SEE_FILE_PREFIX        10
  27. #define SEE_SLEEP_TIME         13
  28. #define SEE_DECODE_UNNAMED     14
  29. #define SEE_SMTP_PORT          15
  30. #define SEE_POP3_PORT          16
  31. #define SEE_MAX_LINE_LENGTH    17
  32. #define SEE_BLOCKING_MODE      18
  33. #define SEE_ALLOW_8BITS        19
  34. #define SEE_LOG_FILE           20
  35. #define SEE_HIDE_SAVED_MSG     21
  36. #define SEE_HIDE_TO_ADDR       22
  37. #define SEE_ADDRESS_DELIMITER  23
  38. #define SEE_WSACLEANUP         24
  39. #define SEE_PATH_DELIMITER     25
  40. #define SEE_ATTACH_DELIMITER   26
  41. #define SEE_ENABLE_IMAGE       27
  42. #define SEE_RAW_MODE           28
  43. #define SEE_ENABLE_ESMTP       29
  44. #define SEE_ENABLE_APOP        30
  45. #define SEE_ATTACH_BASE_NUMBER 31
  46. #define SEE_IGNORE_REJECTED    32
  47. #define SEE_WRITE_CONTENT_TYPE 33
  48. #define SEE_SET_FILE_PREFIX    34
  49. #define SEE_HTML_CHARSET       35
  50. #define SEE_HIDE_HEADERS       36
  51. #define SEE_KEEP_RFC822_INTACT 37
  52. #define SEE_IMAP_PORT          38
  53. #define SEE_EXPUNGE_ON_CLOSE   39
  54. #define SEE_GUT_ATTACHMENTS    40
  55.  
  56. #define CHARSET_BLANK        0
  57. #define CHARSET_US_ASCII     1
  58. #define CHARSET_8859         4
  59. #define CHARSET_ISO_8859_1   4
  60. #define CHARSET_ISO_8859_8   5
  61. #define CHARSET_WIN_1252     6
  62. #define CHARSET_WIN_1255     7
  63. #define CHARSET_UTF8         8
  64. #define CHARSET_ISO_8859_2  10
  65. #define CHARSET_ISO_8859_7  11
  66. #define CHARSET_WIN_1250    12
  67. #define CHARSET_ISO_8859_3  13
  68. #define CHARSET_ISO_8859_4  14
  69.  
  70. #define SEE_GET_ERROR_TEXT     1
  71. #define SEE_GET_COUNTER        2
  72. #define SEE_GET_RESPONSE       3
  73. #define SEE_GET_SOCK_ERROR     4
  74.  
  75. #define SEE_GET_MESSAGE_BYTES_READ  10
  76. #define SEE_GET_ATTACH_BYTES_READ   11
  77. #define SEE_GET_TOTAL_BYTES_READ    12
  78. #define SEE_GET_MESSAGE_BYTES_SENT  13
  79. #define SEE_GET_ATTACH_BYTES_SENT   14
  80. #define SEE_GET_TOTAL_BYTES_SENT    15
  81. #define SEE_GET_VERSION             16
  82.  
  83. #define SEE_GET_MSG_COUNT           17
  84. #define SEE_GET_MSG_SIZE            18
  85. #define SEE_GET_BUFFER_COUNT        19
  86.  
  87. #define SEE_GET_CONNECT_STATUS      20
  88. #define SEE_GET_REGISTRATION        21
  89. #define SEE_GET_ATTACH_COUNT        22
  90. #define SEE_GET_LAST_RESPONSE       23
  91. #define SEE_GET_VERIFY_STATUS       24
  92. #define SEE_GET_SERVER_IP           25
  93. #define SEE_GET_BUILD               26
  94. #define SEE_GET_SOCKET              27
  95. #define SEE_GET_LOCAL_IP            28
  96. #define SEE_GET_ATTACH_NAMES        29
  97. #define SEE_GET_LAST_RECIPIENT      30
  98. #define SEE_GET_AUTH_PROTOCOLS      31
  99. #define SEE_GET_ATTACH_TYPES        32
  100. #define SEE_GET_ATTACH_IDS          33
  101.  
  102. #define SEE_COPY_BUFFER             40
  103. #define SEE_WRITE_BUFFER            41
  104.  
  105. #define SEE_SET_REPLY               50
  106. #define SEE_SET_HEADER              51
  107. #define SEE_WRITE_TO_LOG            52
  108. #define SEE_SET_FROM                53
  109. #define SEE_SET_CONTENT_TYPE        54
  110. #define SEE_SET_TRANSFER_ENCODING   55
  111. #define SEE_ADD_HEADER              56
  112. #define SEE_SET_SECRET              57
  113. #define SEE_SET_USER                58
  114. #define SEE_SET_TEXT_MESSAGE        59
  115. #define SEE_FORCE_INLINE            60
  116. #define SEE_SET_ATTACH_CONTENT_TYPE 61
  117. #define SEE_AUTHENTICATE_PROTOCOL   62
  118. #define SEE_SET_CONTENT_TYPE_PREFIX 63
  119. #define SEE_ENABLE_XMAILER          64
  120. #define SEE_SET_DEFAULT_ZONE        65
  121. #define SEE_SET_ATTACH_DESCRIPTION  66
  122. #define SEE_REPLACE_WITH_COMMAS     67
  123. #define SEE_SET_MULTIPART           68
  124. #define SEE_SET_TIME_ZONE           69
  125. #define SEE_SET_RAWFILE_PREFIX      70
  126. #define SEE_SET_IMAP_LIST_ARG       71
  127. #define SEE_SET_FOOTER              72
  128. #define SEE_SET_LOCAL_IP            73
  129. #define SEE_SET_HELO_STRING         74
  130.  
  131. #define QUOTED_OFF          0
  132. #define QUOTED_PLAIN        1
  133. #define QUOTED_HTML         2
  134. #define QUOTED_RICH         3
  135. #define QUOTED_8859         4
  136. #define QUOTED_ISO_8859_1   4
  137. #define QUOTED_ISO_8859_8   5
  138. #define QUOTED_WIN_1252     6
  139. #define QUOTED_WIN_1255     7
  140. #define QUOTED_USER         9
  141. #define QUOTED_ISO_8859_2  10
  142. #define QUOTED_ISO_8859_7  11
  143. #define QUOTED_WIN_1250    12
  144. #define QUOTED_ISO_8859_3  13
  145. #define QUOTED_ISO_8859_4  14
  146.  
  147. #define INLINE_TEXT_OFF         0
  148. #define INLINE_TEXT_INLINE      1
  149. #define INLINE_TEXT_ATTACHMENT  2
  150.  
  151. #define AUTHENTICATE_CRAM    1
  152. #define AUTHENTICATE_LOGIN   2
  153. #define AUTHENTICATE_PLAIN   4
  154.  
  155. #define CONTENT_TYPE_DEFAULT       0
  156. #define CONTENT_TYPE_MIXED         1
  157. #define CONTENT_TYPE_ALTERNATIVE   2
  158. #define CONTENT_TYPE_RELATED       3
  159.  
  160. #define BYTE  unsigned char
  161.  
  162. #define IMAP_FLAG_SEEN         1
  163. #define IMAP_FLAG_ANSWERED     2
  164. #define IMAP_FLAG_FLAGGED      4
  165. #define IMAP_FLAG_DELETED      8
  166. #define IMAP_FLAG_DRAFT       16
  167. #define IMAP_FLAG_RECENT      32
  168.  
  169. #define IMAP_GET_FLAGS         1
  170. #define IMAP_SET_FLAGS         2
  171. #define IMAP_DEL_FLAGS         3
  172.  
  173. #define IMAP_SEARCH_MSG_COUNT  1
  174. #define IMAP_SEARCH_FIRST_MSG  2
  175. #define IMAP_SEARCH_NEXT_MSG   3
  176.  
  177. #define SEE_USE_STUNNEL        1
  178.  
  179. #define SEE_PROXY_MANUAL_START 1
  180. #define SEE_PROXY_AUTO_START   2
  181.  
  182. NoMangle int  DLL_IMPORT_EXPORT  seeAbort(int);
  183. NoMangle int  DLL_IMPORT_EXPORT  seeAttach(int, unsigned);
  184. NoMangle int  DLL_IMPORT_EXPORT  seeAttachmentParams(char *,char *,char *,char *);
  185. NoMangle int  DLL_IMPORT_EXPORT  seeByteToShort(char *);
  186. NoMangle int  DLL_IMPORT_EXPORT  seeClose(int);
  187. NoMangle int  DLL_IMPORT_EXPORT  seeCommand(int,char *);
  188. NoMangle int  DLL_IMPORT_EXPORT  seeDebug(int,int,char *,int);
  189. NoMangle int  DLL_IMPORT_EXPORT  seeDecodeBuffer(char *,char *,int);
  190. NoMangle int  DLL_IMPORT_EXPORT  seeDecodeUTF8(char *,char *);
  191. NoMangle int  DLL_IMPORT_EXPORT  seeDecodeUU(char *, char *);
  192. NoMangle int  DLL_IMPORT_EXPORT  seeDeleteEmail(int,int);
  193. NoMangle int  DLL_IMPORT_EXPORT  seeDriver(int);
  194. NoMangle int  DLL_IMPORT_EXPORT  seeEncodeBuffer(char *,char *,int);
  195. NoMangle int  DLL_IMPORT_EXPORT  seeEncodeUTF8(int,char *);
  196. NoMangle int  DLL_IMPORT_EXPORT  seeErrorText(int,int,char *,int);
  197. NoMangle int  DLL_IMPORT_EXPORT  seeExtractLine(char *,int,char *,int);
  198. NoMangle int  DLL_IMPORT_EXPORT  seeExtractText(char *,char *,char *,int);
  199. NoMangle int  DLL_IMPORT_EXPORT  seeForwardEmail(int,char *,char *,char *,char *,char *,char *);
  200. NoMangle int  DLL_IMPORT_EXPORT  seeGetEmailCount(int);
  201. NoMangle int  DLL_IMPORT_EXPORT  seeGetEmailFile(int,int,char *,char *,char *);
  202. NoMangle int  DLL_IMPORT_EXPORT  seeGetEmailLines(int,int,int,char *,int);
  203. NoMangle unsigned DLL_IMPORT_EXPORT  seeGetEmailSize(int,int);
  204. NoMangle int  DLL_IMPORT_EXPORT  seeGetEmailUID(int,int,char *,int);
  205. NoMangle unsigned DLL_IMPORT_EXPORT seeGetTicks(int);
  206. NoMangle int  DLL_IMPORT_EXPORT  seeImapConnect(int,char *,char *,char *);
  207. NoMangle int  DLL_IMPORT_EXPORT  seeImapCopyMBmail(int,int,char *);
  208. NoMangle int  DLL_IMPORT_EXPORT  seeImapCreateMB(int,char *);
  209. NoMangle int  DLL_IMPORT_EXPORT  seeImapDeleteMB(int,char *);
  210. NoMangle int  DLL_IMPORT_EXPORT  seeImapFlags(int,int,int,int);
  211. NoMangle int  DLL_IMPORT_EXPORT  seeImapListMB(int,char *,int);
  212. NoMangle int  DLL_IMPORT_EXPORT  seeImapMsgNumber(int,int);
  213. NoMangle int  DLL_IMPORT_EXPORT  seeImapRenameMB(int,char *,char *);
  214. NoMangle int  DLL_IMPORT_EXPORT  seeImapSearch(int,char *,char *,int);
  215. NoMangle int  DLL_IMPORT_EXPORT  seeImapSelectMB(int,char *);
  216. NoMangle int  DLL_IMPORT_EXPORT  seeImapSource(int,char *);
  217. NoMangle int  DLL_IMPORT_EXPORT  seeIntegerParam(int,int,unsigned);
  218. NoMangle int  DLL_IMPORT_EXPORT  seeKillProgram(unsigned,int);
  219. NoMangle int  DLL_IMPORT_EXPORT  seePop3Connect(int,char *,char *,char *);
  220. NoMangle int  DLL_IMPORT_EXPORT  seePop3Source(int,char *);
  221. NoMangle int  DLL_IMPORT_EXPORT  seeQuoteBuffer(char *,char *,int);
  222. NoMangle int  DLL_IMPORT_EXPORT  seeReadQuoted(char *,char *,int,int);
  223. NoMangle int  DLL_IMPORT_EXPORT  seeRelease(void);
  224. NoMangle int  DLL_IMPORT_EXPORT  seeSendEmail(int,char *,char *,char *,char *,char *,char *);
  225. NoMangle int  DLL_IMPORT_EXPORT  seeSendHTML(int,char *,char *,char *,char *,char *,char *,char *,char *);
  226. NoMangle int  DLL_IMPORT_EXPORT  seeSetErrorText(int, char *);
  227. NoMangle int  DLL_IMPORT_EXPORT  seeShortToByte(char *);
  228. NoMangle int  DLL_IMPORT_EXPORT  seeSleep(int);
  229. NoMangle int  DLL_IMPORT_EXPORT  seeSmtpConnect(int,char *,char *,char *);
  230. NoMangle int  DLL_IMPORT_EXPORT  seeSmtpTarget(int,char *,char *,char *);
  231. NoMangle unsigned DLL_IMPORT_EXPORT seeStartProgram(char *);
  232. NoMangle unsigned DLL_IMPORT_EXPORT seeStatistics(int,int);
  233. NoMangle int  DLL_IMPORT_EXPORT  seeStringParam(int,int,char *);
  234. NoMangle int  DLL_IMPORT_EXPORT  seeTestFileSet(int, char *,char *,int);
  235. NoMangle int  DLL_IMPORT_EXPORT  seeVerifyFormat(char *);
  236. NoMangle int  DLL_IMPORT_EXPORT  seeVerifyUser(int,char *);
  #3 (permalink)  
Antiguo 07/09/2011, 11:11
 
Fecha de Ingreso: septiembre-2011
Mensajes: 22
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: Problemas con DLL en C++

PARTE 2

Código C++:
Ver original
  1. NoMangle int DLL_IMPORT_EXPORT seeSmtpConnectSSL(int,int,char *,char *,char *,char *);
  2. NoMangle int DLL_IMPORT_EXPORT seePop3ConnectSSL(int,int,char *,char *);                
  3. NoMangle int DLL_IMPORT_EXPORT seeIsConnected(int);
  4.  
  5.  
  6. int main(int argc, char *argv )
  7. {int Code;
  8. // attach SEE library
  9. Code = seeAttach(1, 0); // evaluation keycode is 0
  10. if(Code<0)
  11. {printf("Cannot attach SEE\n");
  12. exit(1);
  13. }
  14. // connect to SMTP mail server
  15. Code = seeSmtpConnect(
  16. 0, // channel 0
  17. (char *)"smtp.live.com:587", // your SMTP server
  18. (char *)"<[email protected]>", // your email address
  19. (char *)"<[email protected]>"); // Reply-To header
  20. if(Code<0)
  21. {printf("Connect failed\n");
  22. seeRelease();
  23. exit(1);
  24. }
  25. // send email
  26. Code = seeSendEmail(
  27. 0, // channel 0
  28. (char *)"<[email protected]>", // To list
  29. (char *)NULL, // CC list
  30. (char *)NULL, // BCC list
  31. (char *)"SEE Test", // Subject
  32. (char *)"This is a test.", // Message text
  33. (char *)NULL); // MIME attachment
  34. if(Code<0) printf("email NOT sent\n");
  35. // close connection to server
  36. seeClose(0);
  37. seeRelease();
  38. }

Última edición por RootK; 07/09/2011 a las 15:34 Razón: solicitud usuario
  #4 (permalink)  
Antiguo 07/09/2011, 12:03
Avatar de Eternal Idol  
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años
Puntos: 74
Respuesta: Problemas con DLL en C++

No es un problema con el codigo propiamente dicho, no estas enlazando la libreria de importacion (see32.lib o see64.lib).

PD. Lee el "_READ_ME_NOW.TXT" en \APPS\, ahi figuran los proyectos, makefiles, etc. para usar con cada entorno, el tuyo por el error que dio debe ser este: GCC.ZIP : Command batch files for MinGW GCC.
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO
  #5 (permalink)  
Antiguo 07/09/2011, 12:42
 
Fecha de Ingreso: septiembre-2011
Mensajes: 22
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: Problemas con DLL en C++

Pero cual de todos tengo que utilizar?
  #6 (permalink)  
Antiguo 07/09/2011, 12:45
Avatar de Eternal Idol  
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años
Puntos: 74
Respuesta: Problemas con DLL en C++

¿Estas haciendo un programa de 32 bits? see32.lib
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO
  #7 (permalink)  
Antiguo 07/09/2011, 13:16
 
Fecha de Ingreso: septiembre-2011
Mensajes: 22
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: Problemas con DLL en C++

Pero hablo del zip que me has mencionado antes, ¿cual de los bat debo utilizar y como?

==

Siento que puede que te maree un poco pero es que yo programo de normal PHP y HTML y en C++ estoy un poco en el vacio.
  #8 (permalink)  
Antiguo 07/09/2011, 13:38
Avatar de Eternal Idol  
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años
Puntos: 74
Respuesta: Problemas con DLL en C++

Si te fijas son todos mas o menos iguales, cambia el .c y el .exe:

gcc -Wall gb2312.c see32.lib -o gb2312.exe

Usa una linea de comandos como esa o agrega el .lib al proyecto en el IDE que uses.
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO
  #9 (permalink)  
Antiguo 08/09/2011, 08:07
 
Fecha de Ingreso: septiembre-2011
Mensajes: 22
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: Problemas con DLL en C++

me sale el mismo error.

He probado la línea de comandos esa pero me dice que no es un archivo por lotes y el agregar el dll (que por cierto se llama see32.dll, por si tiene eso la culpa) no ayuda...

==

Pd.: Uso Dev-C++
  #10 (permalink)  
Antiguo 08/09/2011, 08:20
Avatar de Eternal Idol  
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años
Puntos: 74
Respuesta: Problemas con DLL en C++

No tenes que usar la DLL, sino la libreria de importacion (.lib). Proba esto:

http://www.rohitab.com/discuss/topic...evcpp-project/

"try alt-p -> parameters -> add library or object -> navigate to your library -> click ok -> click ok -> F9"

Si la linea de comandos falla por no encontrar el gcc entonces buscalo en el disco, es un ejecutable (gcc.exe).
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO
  #11 (permalink)  
Antiguo 08/09/2011, 08:33
 
Fecha de Ingreso: septiembre-2011
Mensajes: 22
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: Problemas con DLL en C++

Sí, lo encontré!!

Yo estaba encabezonado en el dll y era el lib.

Gracias!!!
  #12 (permalink)  
Antiguo 08/09/2011, 08:46
Avatar de Eternal Idol  
Fecha de Ingreso: mayo-2004
Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años
Puntos: 74
Respuesta: Problemas con DLL en C++

De nadas
__________________
¡Peron cumple, Evita dignifica! VIVA PERON CARAJO

Etiquetas: dll
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:08.