• middlepedal

    okay it's short, and it only has one alphanumeric character, but shouldn't "C++" return some hits? I know I used it recently.

    Of course, I still think the forum is awesome.
    middlepedal

    posted in this forum read more
  • middlepedal

    I'm having trouble getting the helloworld external to compile properly on Windows.

    The main resource is apparently this: HOWTO write an External for puredata, and some previous posts on this topic are here: Compiling new external, Max/MSP microtuning externals to convert to pd

    Bear with me, because working with the C compiler is still rather mysterious to me, so I may be making some obvious mistakes. I've installed the djgpp compiler, and followed all the instructions as best as I could. I'm working on XP. I put "m_pd.h" (from the pd/src/ folder) and "helloworld.c" in the same folder and from that directory on the command line (in a DOS "Command Prompt" window) typed:

    gcc -c helloworld.c -o helloworld.o

    As far as I can tell, this successfully produced the "helloworld.o" object file in the same directory as the "helloworld.c" file. Then I typed:

    ld -export_dynamic -shared -o helloworld.dll helloworld.o -lc -lm

    Which, as I understand, is the "linking" step, and the only difference between this command and the command for linux is that ".pd_linux" is replaced with ".dll". Anyway, the compiler responded with:

    c:/progra~1/djgpp/bin/ld.exe: -shared not supported

    So, not having any other ideas, I tried omitting the -shared flag:

    ld -export_dynamic -o helloworld.dll helloworld.o -lc -lm

    That produced this response:

    c:/progra~1/djgpp/bin/ld.exe: warning: cannot find entry symbol xport_dynamic; defaulting to 000018d0
    helloworld.o:helloworld.c:(.text+0x1e): undefined reference to `post'
    helloworld.o:helloworld.c:(.text+0x37): undefined reference to `pd_new'
    helloworld.o:helloworld.c:(.text+0x60): undefined reference to `gensym'
    helloworld.o:helloworld.c:(.text+0x79): undefined reference to `class_new'
    helloworld.o:helloworld.c:(.text+0x96): undefined reference to `class_addbang'

    Why is -shared not supported and what can I do to fix that? I tried Microsoft Visual C++ Express Edition, but found the interface bewildering. I don't think I could even find the words "compile" and "link" in any menu...

    Then I looked in the "0.README" file located in the pd/doc/6.externs/ directory, and found this line (in reference to the 3 example enternals in that folder):

    To compile, type "make pd_linux", "nmake pd_nt", "make pd_irix5" or "make pd_irix6".

    If I wanted to compile these, where would I even type this? Is "nmake" an actual command?

    Then I tried poking around the GNU info files, and saw some vague information about "binutils" and "dlltool" but it is so beyond me right now that I'm turning here. Could someone please enumerate the steps required to take the C source file "helloworld.c" and make it into a usable object in pd without skipping any steps? I (and I'm sure many others) would greatly appreciate that.

    Thanks in advance!

    posted in extra~ read more
  • middlepedal

    These are two abbreviated versions of a patch I'm working on.

    As far as I can tell, these two patches do the exact same thing. In both patches, after the right inlet is set, changing the left inlet will either a) send 1's to the object boxes when the inlets are different, or b) send 0's to the object boxes and then trigger the bangs when the inlets are the same.

    Some questions I have:

    1. Am I overlooking anything? Are they really exactly the same (in terms of function)?

    2. [sel] and [sel 0] apparently work the same if the right inlet is avoided. Is there a good reason to use one and not the other?

    3. Which of the two (if any) is cheaper processor-wise, or which of the two is faster (and why)?

    4. Is there an even better way to do this?

    5. I'm working on Windows XP and I tried using [cputime] but either I don't really know how to use it, or it doesn't work the way I expect it to. I guess what confuses me is that the right inlet is hot, not cold... anyway, any clarification will be appreciated.

    This part of the patch will have to fire thousands of times very fast, so speed is definitely a priority. Thanks very much in advance -- this forum is great!

    http://www.pdpatchrepo.info/hurleur/which-is-faster.pd

    posted in patch~ read more
  • middlepedal

    Is there a list of all the Pd error messages (with explanations, troubleshooting, etc.) anywhere?
    It would be nice to see all the possible error messages defined in one place.
    If no such resource exists, someone should create it...
    Thanks.

    posted in technical issues read more
  • middlepedal

    @AlbertoZ said:

    @jogistar said:

    Where can I find the pd.lib file? I'm using pd-extended, and there is not a single .lib file in my pd/bin directory.

    Mmmh, I was not able to find it too in my pletora of win PD distributions.
    I suspect pd.lib is:

    a) pd.dll, which is a "dynamically linked library" in windows (and by chance
    it is referred as pd.lib), which is located in pd/bin
    b) pd.dll as seen by MSVC integrated environment (???).

    Hi all,

    I don't think pd.lib is the same as pd.dll. pd.lib, as appears in pd-vanilla, also does not appear to be in the CVS repository. I've included pd.lib as an attachment with this post, but you must be a member to download the attachment (membership is free).

    Hope it helps,
    middlepedal

    http://www.pdpatchrepo.info/hurleur/pd.lib

    posted in extra~ read more
  • middlepedal

    AlbertoZ,

    here's the info on formatting your forum posts:
    http://puredata.hurleur.com/help.php.

    Have fun!
    middlepedal

    posted in extra~ read more
  • middlepedal

    Alberto,

    I figured it out. I made a few changes to your makefile, though:
    1. added a path to m_pd.h
    2. changed "rm -f $*.o ../$*.dll" to "rm -f $*.o $*.dll"
    (the .dll file wasn't being removed from the working directory)
    3. forced DEST to the pd/extra directory
    4. removed CSYM since it's not being used
    5. removed "current: pd_win"; changed "pd_win: $(NAME).dll" to "all: $(NAME).dll"
    6. removed non-win stuff
    7. removed the clean and install targets for right now
    Hopefully these changes make it easier for the complete newbie. Anyway, with enormous thanks to AlbertoZ, here's a mini-tutorial for using my makefile.

    1. if you're using pd-extended, save this as "m_pd.h" (into the same directory with
    helloworld.c). If you're using pd-vanilla, you can skip this step.
    2. save this code as "mk.mk" (into the same directory with helloworld.c):

    # mk.mk -- invoke with "make -f mk.mk"
    
          NAME = helloworld
        PDPATH = "c:/Progra~1/pd"
       LDFLAGS = --export-dynamic -shared
    WININCLUDE = -I $(PDPATH)/src
     WINCFLAGS = -DPD -DNT -W3 -WX -Werror -Wno-unused          \
                 -mms-bitfields -Wno-parentheses -Wno-switch    \
                 -O6 -funroll-loops -fomit-frame-pointer
    
    all: $(NAME).dll
    .SUFFIXES: .dll
    .c.dll:
        gcc $(WINCFLAGS) $(WININCLUDE) -c -o $*.o $*.c
        gcc $(LDFLAGS) -o $*.dll $*.o $(PDPATH)/bin/pd.dll  
        strip --strip-unneeded $*.dll
        cp $*.dll $(PDPATH)/extra
        rm -f $*.o $*.dll
    

    2. modify the PDPATH variable if needed to reflect the actual location of pd on your
    system (MSYS will interpret c:/Program Files/pd as C:/Program, so use
    c:/Progra~1/pd instead)
    3. if you're using pd-extended, remove line 6 (WININCLUDE = -I $(PDPATH)/src) and
    remove $(WININCLUDE) from line 14.
    4. close all pd windows if any are open
    5. in MSYS, navigate to the directory with helloworld.c and type: make -f mk.mk
    (type make -s -f mk.mk if you want to hide the lengthy shell response)
    6. the shell should respond with something like:
    gcc -DPD -DNT -W3 -WX -Werror -Wno-unused -mms-bitfields -Wno-parentheses
    -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -I "c:/Progra~1/pd"/src -c -o
    helloworld.o helloworld.c
    gcc --export-dynamic -shared -o helloworld.dll helloworld.o
    "c:/Progra~1/pd"/bin/pd.dll
    strip --strip-unneeded helloworld.dll
    cp helloworld.dll "c:/Progra~1/pd"/extra
    rm -f helloworld.o helloworld.dll
    7. a new helloworld.dll file should be saved into the pd/extra folder, and you should be
    able to create the "helloworld" object in a new pd window.

    Good luck!
    middlepedal

    posted in extra~ read more
  • middlepedal

    Alberto,

    Awesome contribution to the forum! Thanks to your post, I've gotten things to work with MinGW. In fact, the helloworld.dll file produced with the MinGW method was only 6.19 KB, tiny compared to MSVC's 52 Kb file. Not exactly sure why this is, perhaps MSVC uses a bunch of unnecessary default settings that eat up space?

    Anyway, I'd like to add a note of caution to readers about to download and install MinGW and MSYS: read this. Main points:

    1. install MinGW first, then MSYS.
    2. before installing MSYS, make sure you know where MinGW is (eg.
    C://Program Files/MinGW).
    3. when MSYS asks you where MinGW is, use only lowercase letters,
    and convert directory-names with spaces to shorter forms (eg. type
    c:/progra~1/mingw instead of C://Program Files/MinGW).
    4. if the "normalizing" step fails for any reason, uninstall MSYS, and
    reinstall it "with greater care"...

    Also, I tried using your makefile as you said, but got the response:

    make: Nothing to be done for `current'.

    I'm not so smart about makefiles (yet), and I'm confused by your suggestion to "Modify it according to your path in". I changed 2 lines:

    DEST = "c:/Progra~1/pd/extra"
    PDPATH = "c:/Progra~1/pd"

    and the got the response above.

    Two more things: about the difference between MSVC and MSVC Express, I have no idea. And finally, where is MSYS-1.0.11.exe, mentioned here?

    Thanks again,
    Middlepedal

    posted in extra~ read more
  • middlepedal

    Hey,

    thanks to everyone who responded to my posts both here and in the mailing list. Since then, I've figured out how to compile externals written in C using Microsoft Visual C++ 2005. There's more to document, however, such as how to compile externals using some of the other Windows compilers (Borland, djgpp, etc.), and also how to compile externals written in C++ in Windows. But one thing at a time.

    one little thing to note... steps 4 and 7 may seem a little roundabout, but they account for the fact that MSVC sometimes has trouble with spaces in directory names (eg. C://Program Files/). If anyone knows how to override this behavior, post a reply, and I'll try to simplify the steps accordingly.

    Updated June 29, 2007:
    use [b]C://Progra~1/[/b] instead of [b]C://Program Files/[/b],
    use [b]C://Docume~1/[/b] instead of [b]C://Documents and Settings/[/b], etc.

    So, without further ado...

    How to compile a pd external written in C using Microsoft Visual C++ 2005:

    Compared to Windows, linux offers a much more user-friendly environment for compiling pd externals. However, with a little patience, a usable environment can be set up in Windows, and the good news is that everything you need is available for free. There are several reputable Windows-compatible C/C++ compilers out there, but here I'll discuss compiling externals with Microsoft Visual C++ 2005 (MSVC for short).

    1. Download and Install Microsoft Visual C++ 2005 Express Edition.
    a. Click the link above, then click Go! in the Visual C++ box.
    b. Run vcsetup.exe to install the program
    (the setup wizard should guide you through the process).

    2. Download [url=http://download.microsoft.com/download/7/7/3/7737290f-98e8-45bf-9075-85cc6ae34bf1/VS80sp1-KB9267
    ]Visual C++ 2005 Express Service Pack 1.
    a. Click the link above to download the Service Pack.
    b. Run VS80sp1-KB926748-X86-INTL.exe to install the program.

    3. Create a new project:
    a. Open Visual C++.
    b. Open the New Project window (Ctrl+Shift+N).
    c. In the Project Types pane, select Visual C++.
    d. In the Templates pane, select emptyproj.
    e. Enter object name (helloworld).
    f. Leave Create directory for solution unchecked, and click OK.

    4. Import the pd header file:
    a. Get m_pd.h here, or, using pd-vanilla (not pd-extended):
    1. Open Windows Explorer or My Computer.
    2. Navigate to the pd/src/ directory on your system.
    3. Open m_pd.h in a text editor (file type is: C/C++ header).
    b. Select all (Ctrl+A).
    c. Copy selection to the clipboard (Ctrl+C).
    d. Back in Visual C++, open the New File window (Ctrl+N).
    e. In the Categories pane, select General.
    f. In the Templates pane, select Text File, and click Open.
    g. Copy the contents of m_pd.h into the editor window (Ctrl+V).
    h. Open the Save File As Window (Ctrl+S).
    i. Save as m_pd.h.
    j. From the File Menu, select Move m_pd.h into; select helloworld.

    5. Write the source code for the external in C.
    a. Open the New File window (Ctrl+N).
    b. In the Categories pane, select General.
    c. In the Templates pane, select Text File, and click Open.
    d. Write your source code in the editor window.

    The following example is taken from the tutorial by Johannes M. Zmoelnig.

    #include "m_pd.h"
    
    static t_class *helloworld_class;
    
    typedef struct _helloworld {
      t_object  x_obj;
    } t_helloworld;
    
    void helloworld_bang(t_helloworld *x)
    {
      post("Hello world !!");
    }
    
    void *helloworld_new(void)
    {
      t_helloworld *x = (t_helloworld *)pd_new(helloworld_class);
    
      return (void *)x;
    }
    
    void helloworld_setup(void) {
      helloworld_class = class_new(gensym("helloworld"),
            (t_newmethod)helloworld_new,
            0, sizeof(t_helloworld),
            CLASS_DEFAULT, 0);
      class_addbang(helloworld_class, helloworld_bang);
    }
    

    6. Save and import the source code into the project:
    a. Open the Save File As Window (Ctrl+S).
    b. Save as helloworld.c.
    c. From the File Menu, select Move helloworld.c into; select helloworld.

    7. Access the pd library file:
    a. Open Windows Explorer or My Computer.
    b. Navigate to the pd/bin/ directory on your system.
    c. Right-click on pd.lib (file type is: Object File Library) and select Copy.
    d. Navigate to the C://TEMP/ directory on your system.
    e. Paste the copy of pd.lib in the C://TEMP/ directory (right-click or Ctrl-V).

    8. Set configuration properties:
    a. Set configuration type to .dll:
    1. Back in Visual C++, open the helloworld Property Pages window (Alt+F7).
    2. In the left pane, select Configuration Properties >> General.
    3. In the right pane, under Project Defaults, click on
    Configuration Type, and select Dynamic Library (.dll)
    (using the arrow on the right).

    b. Add MSW to preprocessor definitions:
    1. In the left pane, select
    Configuration Properties >> C/C++ >> Preprocessor.
    2. In the right pane, type MSW in the Preprocessor Definitions field.

    c. Tell compiler which language to use:
    1. In the left pane, select
    Configuration Properties >> C/C++ >> Advanced.
    2. In the right pane, select Compile As.
    3. Select Compile as C Code (/TC) by clicking the arrow on the right.

    d. Tell linker where to find pd.lib:
    1. In the left pane, select Configuration Properties >> Linker >> Input.
    2. In the right pane, select Additional Dependencies and enter
    C://TEMP/pd.lib.

    e. Tell linker to export the setup function:
    1. In the left pane, select
    Configuration Properties >> Linker >> Command Line.
    2. In the right pane, type
    /export:helloworld_setup in the Additional options field.
    3. Click OK.

    9. Compile and link:
    a. Use the Build Solution command (F7).

    10. Copy the new helloworld.dll file into pd.
    a. Open Windows Explorer or My Computer.
    b. Navigate to the
    My Documents/Visual Studio 2005/Projects/helloworld/Debug/
    directory on your system.
    c. Right-click on helloworld.dll (file type is: Application Extension)
    and select Copy.
    d. Navigate to the pd/extra directory on your system.
    e. Paste the copy of helloworld.dll in the pd/extra directory
    (right-click or Ctrl-V).

    11. Test the external in pd.
    a. the external should now be a useable object in pd.
    b. open a new pd patch and try to create a helloworld object.
    c. add a bang to the left inlet and test it out.
    d. if the main pd console window displays "Hello world !!",
    the external has succeeded.

    Hope this helps!
    -- middlepedal

    posted in extra~ read more
  • middlepedal

    obiwannabe,

    thanks so much. I tried your suggestion, and using "exponential" copy-and-paste (if you know what I mean), compared 256 instances of one to 256 instances of the other (in the original expanded version). In case you're curious, you were right, the speed difference is negligible.

    The reason I have 3 connections coming out of 1 outlet is because the order doesn't matter there ... they all go to cold inlets of objects which are later banged on the hot side by the bangs on the left.

    I've decided to use the patch on the left, because it's less cluttered with connection lines.

    Thanks for your help!

    posted in patch~ read more
Internal error.

Oops! Looks like something went wrong!