Thread: convert executable in dll

  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    3

    convert executable in dll

    Hello everybody,

    I work usually with Fortran. We have a Fortran program that we want upgrade using a opensource program which is write in c. We want to convert it into dll that we can load that in our fortran application.
    The main function of the c program is

    Code:
    int main( int argc, char **argv ){}
    The c program is a command line tool. To computes the program, the usage is:

    ProgramName <inputfile> <outputfile>

    I have look a lot of manuals in internet about generate a dll in c/c++. I am not sure what I am doing is right or wrong.

    I define a macro that declares the main function to be exported when building our dll-config, and not to be exported, when building the exe. like:

    Code:
    #ifdef DLLCONFIG
    #define VIEW3D_API __declspec(dllexports)
    #else
    #define VIEW3D_API
    #endif
    
    VIEW3D_API int main(int argc, char **argv){
      return;
    }
    Is that correct?
    Thanks,
    Laura

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Does Fortran have the ability to run another process?

    Because that's probably the easiest way to go, where you do something like
    system("programname infile outfile");

    What opensource licence does the new program have? If your Fortran program is commercial, you need to be careful what you do.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2019
    Posts
    3
    Quote Originally Posted by Salem View Post
    Does Fortran have the ability to run another process?
    In Fortran exist the possibility to run another process. Only for curiosity is correct the code that I wrote before?

    Quote Originally Posted by Salem View Post
    What opensource licence does the new program have? If your Fortran program is commercial, you need to be careful what you do.
    The version of the opensource programm that we want use has a public domain licence. We already informed about the possibles problems with our commercial Fortran program.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Either of these.

    As a DLL Function.
    Code:
    #ifdef DLLCONFIG
    #define VIEW3D_API __declspec(dllexports)
    #else
    #define VIEW3D_API
    #endif
     
    VIEW3D_API int some_function(const char *infile, const char *outfile){
      return 0;
    }

    Or as a separate process.
    Code:
    int some_function(const char *infile, const char *outfile){
      return 0;
    }
    
    int main ( int argc, char *argv[] ) {
      return some_function(argv[1],argv[2]);
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    I've never worked with FORTRAN. I wouldn't know how to declare an external SUBROUTINE and which calling convention to use.

    The SysV ABI says something about interfacing C (gcc) and FORTRAN (gfortran)... You can download the specs here. But, most probably, it doesn't apply to Windows applications...

    PS: The complete supplements for SysV ABI is here.
    Last edited by flp1969; 03-27-2019 at 01:44 AM.

  6. #6
    Registered User
    Join Date
    Mar 2019
    Posts
    3
    Thank you for your reply I have learned something new for me.

    Anyway, I have already implemented the command to run the opensource program in my fortran program.

    Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 17
    Last Post: 07-26-2012, 09:32 PM
  2. how convert c pgm to executable file
    By arul in forum C Programming
    Replies: 3
    Last Post: 10-12-2008, 05:10 AM
  3. calling an executable from an executable
    By dee in forum C Programming
    Replies: 4
    Last Post: 01-10-2004, 01:32 PM
  4. Command line executable not a KDE executable?
    By FillYourBrain in forum Linux Programming
    Replies: 3
    Last Post: 10-03-2003, 12:01 PM
  5. big executable, no bmp's
    By GanglyLamb in forum Game Programming
    Replies: 5
    Last Post: 07-18-2003, 10:51 PM

Tags for this Thread