Home > Community > Forums > PCB SKILL > Link C++ - SKILL

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Link C++ - SKILL 

Last post Wed, Jan 16 2013 10:51 AM by Yann00. 16 replies.
Started by Yann00 12 Jan 2013 11:24 AM. Topic has 16 replies and 2788 views
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts:
  • Sat, Jan 12 2013 11:24 AM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    Link C++ - SKILL Reply

    hi,

     

    Could someone explain to me how to make a link between C++ and SKILL?

    I have to develop a program in SKILL. But I do some text treatment in C++. So how I can load my SKILL program, and then lunch my C++ program? I have, in the SKILL program, to have a position with text file from C++.

    Ask me if you want more details.

    Best regards

    • Post Points: 50
  • Sun, Jan 13 2013 12:56 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 707
    • Points 15,395
    Re: Link C++ - SKILL Reply
    This is well documented in the Skill help files. Look for the DLL functions.
    Dave Elder, Tait Communications
    • Post Points: 5
  • Mon, Jan 14 2013 5:31 AM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 290
    • Points 4,620
    Re: Link C++ - SKILL Reply

    It depends upon the integration needed. If your C++program can run as a batch operation with well established I/O with Skill, I would treat it is a seperate binary and have your Skill program launch it via something link the Skill system API. The I/O would typically be based upon files and/or command line arguments. This appoach is typically the fastest to get running and is pretty easy to debug. Also if you have never written Skill before it would be the best approach.

    If your C++ code needs to tightly interact with your Skill code then the axlDll approach might be the best. It requires that you turn your C++ code into a dll. See the Allegro Skill reference manual for more info.

    • Post Points: 20
  • Mon, Jan 14 2013 10:56 AM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    Re: Link C++ - SKILL Reply

     

     

    • Post Points: 5
  • Tue, Jan 15 2013 6:44 AM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    Re: Link C++ - SKILL Reply
    My program C++ is to recover a text file which contains a position (X=...,Y=...).

    Then in my skill program I put this position in a variable in order to use it in a function.

    So I would automatize that. My program SKILL begin, do the first function, and then for the second SKILL function i need the position wrote in text file with my program C++.

    I put my C++ program. I don't know really how to convert it into a DLL file.

    And I don't really understand how to insert it in my SKILL program.

    Could you help me please?

    Thanks a lot
    • Post Points: 20
  • Tue, Jan 15 2013 7:03 AM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 290
    • Points 4,620
    Re: Link C++ - SKILL Reply

    To create a dll go to google and type in the following search term "creating a dll", then select "I'm feeling lucky". This assumes you have a copy of Visual Net 2005  from Microsoft, you need this IDE to create a dll that is compatible with Allegro

     To bind the dll to Skill read the chapter in the Allegro Skill Reference manual. Search cdsdoc for axlDllOpen and read that entire section.

     

    • Post Points: 5
  • Tue, Jan 15 2013 7:09 AM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 290
    • Points 4,620
    Re: Link C++ - SKILL Reply

    Looking at your C program it would be easier to have your C program write a file of x/y coordinates that can be easily read by your Skill code. Your Skill code would call your C program via the "system" API and read the file produced by your C program. Unless you need to do this hundreds of times a second, I wouldn't go to all of the extra work to use the axl dll binding method unless you are doing this as a learning experience.

    • Post Points: 20
  • Tue, Jan 15 2013 11:18 AM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    Re: Link C++ - SKILL Reply

    Every way is ok for me if I could run my C program in my SKILL program.

    The problem is that all of my C code is in my main. And I don't know how to convert it in a function with (File.h and File.c). I am not really good in fact in programming.

    I understood how to create a dll. That was a good tutorial.

    But I keep my problem with the transformation from my main to a function (with .h and .c).

    When I debug my C++ program, it creates a file called Centre_Cartouche.txt and it works really nice. But I wanna run it during my Skill program running. Because the input of my C++ program is the output of my first function in my SKILL program. My second function in my SKILL program need the output of my C++ program (Centre_Cartouche.txt) to take as an input.

    • Post Points: 20
  • Tue, Jan 15 2013 12:58 PM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 290
    • Points 4,620
    Re: Link C++ - SKILL Reply

     Calling other programs from skill is pretty easy. In your Skill code just do a:

         system("my_C_program my_arguments")

     The main issue is dealing where the program exists on disks. You can ask the user or install it in a "well known" location.

    What you want to end up with is invoking the system API with the actual location on disk. The alternative method is either modifing the Windows PATH variable to sticking the program into a directory that currently exists in the PATH variable. For example invoking the program via an absolute directory location:

         system("d:\bin\my_C_program my_arguments)

    • Post Points: 20
  • Tue, Jan 15 2013 1:44 PM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    Re: Link C++ - SKILL Reply

    In fact my C++ program has in input the brd.txt ans sym.txt files. This two text files come from the extraction of my fichier.brd in SKILL.

    And the C++ program creates in output Centre_Cartouche.txt.

    And I need for my next SKILL function to use this Centre_Cartouche.txt to read x and y.

     

    I tried to called my program with system("my_C_program my_arguments") and even if the program is well specified with path it does not work.

    Does it turn on yours?

     

    • Post Points: 20
  • Tue, Jan 15 2013 1:59 PM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 290
    • Points 4,620
    Re: Link C++ - SKILL Reply

    It works for me. I assume you compile/link your program 32bit?

    • Post Points: 20
  • Tue, Jan 15 2013 3:13 PM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    Re: Link C++ - SKILL Reply

    Yes I do.

    What did you write in system("??")?

    Does it create a file text "Centre_Cartouche.txt"? Because I give you the file Centre_Cartouche.txt just for you to have a look wath it seems like.

    (brd.txt,   sym.txt ) is the two files read by the C++ at the beginning. Centre_Cartouche.txt will be create after treatment on this two files. So  Centre_Cartouche.txt is my output. 

    • Post Points: 5
  • Tue, Jan 15 2013 3:55 PM

    • ztzg
    • Not Ranked
    • Joined on Fri, Dec 31 2010
    • München, Bavaria
    • Posts 15
    • Points 225
    Re: Link C++ - SKILL Reply
    Hi Yann00,

    As fxffxf wrote, system("program arg1 arg2...") should to work.

    One thing which *might* be going wrong is that if you are working under
    Windows, reverse solidus (\) characters have to be doubled in literal
    strings, as they clash with the SKILL escape mechanism:

    system("e:\\work\\program.exe arg1 arg2...")

    Another thing to watch out for is spaces in the path to the binary; I'm
    not even sure about the proper quoting mechanism under Windows… this
    *might* work, but I'd double check the docs for cmd.exe:

    system("\"c:\\Program Files\\My\\Program.exe\" arg1 arg2...")

    (And similarly for the arguments.)

    Another solution, which offers more control—but suffers from the same
    quoting madness—would be to use the ipc* family of functions
    (ipcBeginProcess, etc.). I have put together a small example at:

    s.crosstwine.com/spb/d2692740

    and you will find a complete package attached to this message (tested
    under Linux).

    Hope this helps,
    Damien
    http://www.crosstwine.com tel: +49 89 2189 2939 cell: +49 174 3489 428
    • Post Points: 5
  • Tue, Jan 15 2013 4:45 PM

    • ztzg
    • Not Ranked
    • Joined on Fri, Dec 31 2010
    • München, Bavaria
    • Posts 15
    • Points 225
    Re: Link C++ - SKILL Reply

    So it seems attachments to email replies get eaten by the system.

    Trying again, using the web interface; I have also uploaded an unpacked version to:

     http://crosstwine.com/misc/letters/2013/01/16/SKILL-C++-Interaction/c-delegate/ 

    http://www.crosstwine.com tel: +49 89 2189 2939 cell: +49 174 3489 428
    • Post Points: 35
  • Wed, Jan 16 2013 6:43 AM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    Re: Link C++ - SKILL Reply

    I tried your example and it seems to be ok.

    But there is something wrong when I try to do the same for me...  (every time (: )

    So I won to create my DLL program. I put files there and it works, it creates my Centre_Cartouche.txt when I Test my DLL.

    I tried to import it in my skill program. And strange, ... It doesn't work!

    I read the allegro pdf on that but I have some problems to identify my problem.

    Did someone already load a dll on his skill program?

     

    • Post Points: 5
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts:
Started by Yann00 at 12 Jan 2013 11:24 AM. Topic has 16 replies.