Author Topic: Compile Error using DLL  (Read 3276 times)

0 Members and 1 Guest are viewing this topic.

Offline dzeek

  • Newbie
  • Posts: 7
    • View Profile
Compile Error using DLL
« on: June 08, 2020, 11:15:52 am »
I'm getting the following compile error when trying to use a DLL and .h file that was provided to me. I can't seem to figure out what is causing the error. Any help would be appreciated.

Error file
Code: QB64: [Select]
  1. In file included from ..\\temp\\regsf.txt:2,
  2.                  from qbx.cpp:1076:
  3. D:/STITCHORI/Windows/v1/DPPanoMakerProDLLMain.h:8:29: error: expected constructor, destructor, or type conversion before '(' token
  4.  #define DLL_EXPORT _declspec(dllexport)
  5.                              ^
  6. D:/STITCHORI/Windows/v1/DPPanoMakerProDLLMain.h:16:12: note: in expansion of macro 'DLL_EXPORT'
  7.  extern "C" DLL_EXPORT int ProMakePanoramaBuf(int threadNum, int memType, void* hRawFileReader, const char* outputDir, const char* fileNo,
  8.             ^~~~~~~~~~
  9. compilation terminated due to -Wfatal-errors.
  10.  

My QB64 Program:
Code: QB64: [Select]
  1. _TITLE "STITCH v1 - Stitch ORI files"
  2.  
  3. DECLARE DYNAMIC LIBRARY ".\PanoMakerPro"
  4.  
  5. DECLARE LIBRARY ".\DPPanoMakerProDLLMain"
  6.     FUNCTION ProInitRawFileReader& (fileBuf AS STRING, BYVAL fileSize)
  7.     FUNCTION ProMakePanoramaBuf& (BYVAL threadNum AS INTEGER, BYVAL memType AS INTEGER, BYVAL hRawFileReader, outputDir AS STRING, fileNo AS STRING, BYVAL hdrSel AS INTEGER, BYVAL outputType AS INTEGER, BYVAL colorMode AS INTEGER, BYVAL extendMode AS INTEGER, BYVAL outputJpgType AS INTEGER, BYVAL outputQuality AS INTEGER, BYVAL stitchMode AS INTEGER, BYVAL gyroMode AS INTEGER, BYVAL templateMode AS INTEGER, templateFileName AS STRING, BYVAL logoAngle AS DOUBLE, BYVAL luminance AS DOUBLE, BYVAL contrastRatio AS DOUBLE, BYVAL gammaMode AS INTEGER, BYVAL wbMode AS INTEGER, BYVAL wbConfB AS DOUBLE, BYVAL wbConfG AS DOUBLE, BYVAL wbConfR AS DOUBLE, BYVAL saturation AS DOUBLE, dbgData AS STRING)
  8.  
  9. DIM outputDir AS STRING
  10. DIM fileNo AS STRING
  11. DIM dbgData AS STRING
  12. DIM result AS LONG
  13. DIM handle AS LONG
  14. DIM fileBuf AS STRING
  15. DIM fileSize AS LONG
  16.  
  17.  
  18. outputDir = ".\"
  19. fileNo = "2020-05-18_07.20.51"
  20.  
  21. fileBuf = ""
  22. OPEN fileNo + ".ori" FOR BINARY AS #F%
  23.     GET #F%, , Dat$
  24.     fileBuf = fileBuf + Dat$
  25.  
  26. fileSize = LEN(fileBuf)
  27.  
  28. handle = ProInitRawFileReader(fileBuf, fileSize)
  29. result = ProMakePanoramaBuf(4, 0, handle, outputDir, fileNo, 10, 0, 1, 0, 1, 90, 0, 0, 0, "", -1, 1.2, 1.3, 1, 0, 1.0, 1.0, 1.0, 1.0, dbgData)
  30.  
  31.  

DPPanoMakerProDLLMain.h file
Code: QB64: [Select]
  1. //#ifndef EXE_OUT
  2.  
  3. #ifndef __PANOMAKERPRODLLMAIN_H__
  4. #define __PANOMAKERPRODLLMAIN_H__
  5.  
  6. #if defined WIN32
  7.  
  8. #define DLL_EXPORT _declspec(dllexport)
  9.  
  10. #else
  11.  
  12. #define DLL_EXPORT __attribute__ ((visibility("default")))
  13.  
  14. #endif
  15.  
  16. extern "C" DLL_EXPORT int ProMakePanoramaBuf(int threadNum, int memType, void* hRawFileReader, const char* outputDir, const char* fileNo,
  17.         int hdrSel, int outputType, int colorMode, int extendMode, int outputJpgType, int outputQuality, int stitchMode, int gyroMode, int templateMode, const char* templateFileName,
  18.         double logoAngle, double luminance, double contrastRatio, int gammaMode, int wbMode, double wbConfB, double wbConfG, double wbConfR, double saturation, unsigned char* dbgData);
  19.  
  20. extern "C" DLL_EXPORT void* ProInitRawFileReader(unsigned char* fileBuf, int fileSize);
  21.  
  22. extern "C" DLL_EXPORT int ProUpdateRawFileReader(void* hRawFileReader, int bufWrPos);
  23.  
  24. extern "C" DLL_EXPORT int ProCleanRawFileReader(void* hRawFileReader);
  25.  
  26. extern "C" DLL_EXPORT double ProGetProgress(double lastProgress, unsigned char* dbgData);
  27.  
  28. #endif
  29.  
  30. //#endif
  31.  
« Last Edit: June 08, 2020, 12:44:39 pm by dzeek »

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: Compile Error using DLL
« Reply #1 on: June 09, 2020, 07:05:44 am »
have you tried without the C(++) header and only with the dll?

Marked as best answer by dzeek on June 09, 2020, 04:19:04 am

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: Compile Error using DLL
« Reply #2 on: June 09, 2020, 07:18:28 am »
"_declspec(dllexport)" is MSVC-specific syntax. QB64 always uses gcc/clang, so just fiddle with that #if on line 6 to use the other version (the __attribute__ one).

Then you can deal with whatever the next error is :)

Offline dzeek

  • Newbie
  • Posts: 7
    • View Profile
Re: Compile Error using DLL
« Reply #3 on: June 09, 2020, 08:19:19 am »
"_declspec(dllexport)" is MSVC-specific syntax. QB64 always uses gcc/clang, so just fiddle with that #if on line 6 to use the other version (the __attribute__ one).

Then you can deal with whatever the next error is :)

Thanks. That worked.